Package org.ddolib.layered.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.Model.initialSolution()returnsnull(no initial solution by default).probability()returns 0.2 as default destruction probability.useLNS()returnstrueby default.seed()returnsDEFAULT_SEED, so that the search is deterministic.
Configuration methods allow creating modified copies of the model with custom parameters:
fixWidth(int)returns a newLnsModelwith a fixed search width.setInitialSolution(Solution)returns a newLnsModelusing a given initial solution.setProbability(double)returns a newLnsModelwith a specified destruction probability.setSeed(long)returns a newLnsModelwith a specified seed.
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longSeed used by default for the randomized LNS restriction. -
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 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.default longseed()Returns the seed of the random number generator used by the LNS restriction.setInitialSolution(Solution 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.setSeed(long seed) Returns a copy of this model with a specified seed for the random number generator.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.layered.modeling.Model
debugMode, disableDominance, disableLowerBound, dominance, initialSolution, lowerBound, problem, variableHeuristic, verbosityLevel
-
Field Details
-
DEFAULT_SEED
static final long DEFAULT_SEEDSeed used by default for the randomized LNS restriction. A fixed seed makes the search deterministic, as in the original ddo solver.- See Also:
-
-
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
-
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
-
seed
default long seed()Returns the seed of the random number generator used by the LNS restriction. Two runs with the same model and the same seed explore the same neighborhoods. Default isDEFAULT_SEED.- Returns:
- the seed of the random number generator
-
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.- Specified by:
setInitialSolutionin interfaceModel<T>- 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
-
setSeed
Returns a copy of this model with a specified seed for the random number generator.- Parameters:
seed- the seed to use in LNS- Returns:
- a new
LnsModelwith the specified seed
-