Package org.ddolib.examples.tsptw
Class TSPTWWidth
java.lang.Object
org.ddolib.examples.tsptw.TSPTWWidth
- All Implemented Interfaces:
WidthHeuristic<TSPTWState>
Heuristic for computing the width of a layer in the dynamic programming model
for the Traveling Salesman Problem with Time Windows (TSPTW).
The width represents the maximum number of states to keep at a given layer. It is computed based on the number of variables, the current depth, and a user-defined factor.
-
Constructor Summary
ConstructorsConstructorDescriptionTSPTWWidth(int nbVars, int factor) Constructs a width heuristic for TSPTW layers. -
Method Summary
Modifier and TypeMethodDescriptionintmaximumWidth(TSPTWState state) Computes the maximum width of a layer based on the current state.
-
Constructor Details
-
TSPTWWidth
public TSPTWWidth(int nbVars, int factor) Constructs a width heuristic for TSPTW layers.- Parameters:
nbVars- the number of variables/nodes in the problemfactor- a scaling factor for the width calculation
-
-
Method Details
-
maximumWidth
Computes the maximum width of a layer based on the current state.The width is calculated as: (depth + 1) * nbVars * factor. This allows the width to grow with the depth of the state in the DP model.
- Specified by:
maximumWidthin interfaceWidthHeuristic<TSPTWState>- Parameters:
state- the state for which to compute the layer width- Returns:
- the maximum number of states to keep at this layer
-