Package org.ddolib.examples.tsp
Class TSPRelax
java.lang.Object
org.ddolib.examples.tsp.TSPRelax
- All Implemented Interfaces:
Relaxation<TSPState>
Implementation of a relaxation for the Traveling Salesman Problem (TSP).
This class implements the Relaxation interface for TSPState.
It provides methods to merge multiple states into a single relaxed state
and to adjust the cost of transitions in a relaxed context.
In this implementation:
mergeStates(Iterator)returns a state where the "toVisit" and "current" sets are the union of the corresponding sets from the input states.relaxEdge(TSPState, TSPState, TSPState, Decision, double)currently returns the original cost without modification.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTSPRelax(TSPProblem problem) Constructs a relaxation for a given TSP problem. -
Method Summary
-
Constructor Details
-
TSPRelax
Constructs a relaxation for a given TSP problem.- Parameters:
problem- the TSP problem instance to be relaxed
-
-
Method Details
-
mergeStates
Merges multipleTSPStateinstances into a single relaxed state.The resulting state has its "toVisit" and "current" sets as the union of the corresponding sets from all input states.
- Specified by:
mergeStatesin interfaceRelaxation<TSPState>- Parameters:
states- an iterator over the states to merge- Returns:
- a new
TSPStaterepresenting the merged state
-
relaxEdge
Relaxes the cost of a transition between states.In this implementation, the cost is not modified and the original cost is returned.
- Specified by:
relaxEdgein interfaceRelaxation<TSPState>- Parameters:
from- the state before the transitionto- the state after the transitionmerged- the merged state (if any)d- the decision causing the transitioncost- the original cost of the transition- Returns:
- the relaxed cost of the transition (same as the original cost)
-