Interface LnsModel<T>

Type Parameters:
T - the type of state used in the problem
All Superinterfaces:
Model<T>

public interface LnsModel<T> extends 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 Problem instance.
  • Specifying a FastLowerBound for efficient lower bound estimation.
  • Optionally providing a DominanceChecker to prune dominated states.
  • Providing heuristics such as StateRanking and WidthHeuristic to guide search.
  • Supporting optional configuration of LNS parameters like initial solution, destruction probability, and width.

Default implementations:

Configuration methods allow creating modified copies of the model with custom parameters:

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 Details

    • DEFAULT_SEED

      static final long DEFAULT_SEED
      Seed 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

      default StateRanking<T> 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

      default WidthHeuristic<T> widthHeuristic()
      Returns the width heuristic used for tree exploration. Default is FixedWidth with width 10.
      Returns:
      the width heuristic
    • exportDot

      default boolean exportDot()
      Indicates whether to export the search tree to DOT format. Default is false.
      Returns:
      true if DOT export is enabled, false otherwise
    • restrictStrategy

      default ReductionStrategy<T> restrictStrategy()
      Returns the strategy used to restrict the search neighborhood.
      Returns:
      the reduction strategy
    • stateDistance

      default StateDistance<T> 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 is true.
      Returns:
      true if LNS is enabled, false otherwise
    • 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 is DEFAULT_SEED.
      Returns:
      the seed of the random number generator
    • fixWidth

      default LnsModel<T> fixWidth(int width)
      Returns a copy of this model with a fixed search width.
      Parameters:
      width - the width to fix
      Returns:
      a new LnsModel with the specified width
    • setInitialSolution

      default LnsModel<T> setInitialSolution(Solution solution)
      Returns a copy of this model with a specified initial solution.
      Specified by:
      setInitialSolution in interface Model<T>
      Parameters:
      solution - the initial solution
      Returns:
      a new LnsModel using the given initial solution
    • setProbability

      default LnsModel<T> setProbability(double proba)
      Returns a copy of this model with a specified destruction probability.
      Parameters:
      proba - the probability to use in LNS
      Returns:
      a new LnsModel with the specified probability
    • setSeed

      default LnsModel<T> setSeed(long seed)
      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 LnsModel with the specified seed