Package org.ddolib.modeling
Interface LnsModel<T>
- Type Parameters:
T- the type of state used in the problem
- All Superinterfaces:
Model<T>
Interface representing a model for Large Neighborhood Search (LNS) problems.
This interface extends Model and provides default implementations
and configuration options specifically for LNS-based search algorithms.
Key responsibilities of an LnsModel include:
- Providing the underlying
Probleminstance. - Specifying a
FastLowerBoundfor efficient lower bound estimation. - Optionally providing a
DominanceCheckerto prune dominated states. - Providing heuristics such as
StateRankingandWidthHeuristicto guide search. - Supporting optional configuration of LNS parameters like initial solution, destruction probability, and width.
Default implementations:
ranking()returns a trivial ranking (no preference).widthHeuristic()defaults to aFixedWidthof 10.exportDot()returnsfalse(no DOT export by default).restrictStrategy()defaults to aCostBasedreduction with zero comparator.stateDistance()returns 0 between any two states.initialSolution()returnsnull(no initial solution by default).probability()returns 0.2 as default destruction probability.useLNS()returnstrueby default.
Configuration methods allow creating modified copies of the model with custom parameters:
fixWidth(int)returns a newLnsModelwith a fixed search width.setInitialSolution(int[])returns a newLnsModelusing a given initial solution.setProbability(double)returns a newLnsModelwith a specified destruction probability.
Example usage:
LnsModel model = new MyLnsModel()
.fixWidth(20)
.setInitialSolution(mySolution)
.setProbability(0.3);
This interface is intended for use with Solvers.minimizeLns(LnsModel, java.util.function.Predicate, java.util.function.BiConsumer)
or similar LNS solvers.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanIndicates whether to export the search tree to DOT format.fixWidth(int width) Returns a copy of this model with a fixed search width.default int[]Returns the initial solution to start the search from.default doubleReturns the probability used to destruct parts of the solution in LNS.default StateRanking<T> ranking()Returns the state ranking heuristic used to guide the search.default ReductionStrategy<T> Returns the strategy used to restrict the search neighborhood.setInitialSolution(int[] solution) Returns a copy of this model with a specified initial solution.setProbability(double proba) Returns a copy of this model with a specified destruction probability.default StateDistance<T> Returns a measure of distance between two states.default booleanuseLNS()Indicates whether LNS should be used.default WidthHeuristic<T> Returns the width heuristic used for tree exploration.Methods inherited from interface org.ddolib.modeling.Model
debugMode, disableDominance, disableLowerBound, dominance, lowerBound, problem, upperBound, variableHeuristic, verbosityLevel
-
Method Details
-
ranking
Returns the state ranking heuristic used to guide the search. Default implementation returns a neutral ranking (all states equal).- Returns:
- the state ranking
-
widthHeuristic
Returns the width heuristic used for tree exploration. Default isFixedWidthwith width 10.- Returns:
- the width heuristic
-
exportDot
default boolean exportDot()Indicates whether to export the search tree to DOT format. Default isfalse.- Returns:
trueif DOT export is enabled,falseotherwise
-
restrictStrategy
Returns the strategy used to restrict the search neighborhood.- Returns:
- the reduction strategy
-
stateDistance
Returns a measure of distance between two states. Default returns 0 for all states.- Returns:
- the state distance
-
initialSolution
default int[] initialSolution()Returns the initial solution to start the search from. Default isnull(no initial solution).- Returns:
- the initial solution as an array of variable assignments
-
probability
default double probability()Returns the probability used to destruct parts of the solution in LNS. Default is 0.2.- Returns:
- destruction probability
-
useLNS
default boolean useLNS()Indicates whether LNS should be used. Default istrue.- Returns:
trueif LNS is enabled,falseotherwise
-
fixWidth
Returns a copy of this model with a fixed search width.- Parameters:
width- the width to fix- Returns:
- a new
LnsModelwith the specified width
-
setInitialSolution
Returns a copy of this model with a specified initial solution.- Parameters:
solution- the initial solution- Returns:
- a new
LnsModelusing the given initial solution
-
setProbability
Returns a copy of this model with a specified destruction probability.- Parameters:
proba- the probability to use in LNS- Returns:
- a new
LnsModelwith the specified probability
-