Class LnsSolver<T>

java.lang.Object
org.ddolib.layered.solving.lns.core.solver.LnsSolver<T>
Type Parameters:
T - type of states manipulated by the underlying problem
All Implemented Interfaces:
Solver

public final class LnsSolver<T> extends Object implements Solver
Large Neighborhood Search (LNS) solver based on restricted decision diagrams.

The solver iteratively destroys part of the incumbent solution, recompiles a restricted decision diagram on the residual subproblem, and accepts strict improvements on the objective value.

Statuses. LNS is a heuristic: it only reports a proof when it has a global dual bound.

  • SearchStatus.OPTIMAL: either the restricted DD compiled from the root (no fixed decision) is exact, i.e. it enumerated the whole search space, or the incumbent reaches the global lower bound (the fast lower bound at the root).
  • SearchStatus.UNSAT: the exact DD compiled from the root has no solution.
  • SearchStatus.SAT: a solution is known but its optimality is not proved, in particular when the search is stopped by its limit. The gap is then computed with the global lower bound.
  • SearchStatus.UNKNOWN: no solution is known and infeasibility is not proved.
  • SearchStatus.MEMOUT: the JVM ran out of memory during a compilation, or the limit StopCriterion.maxFrontierSize(int) was reached; the best solution known, if any, is returned. The LNS has no frontier: the size it reports is its number of iterations.

An exact DD is only a proof if the states it prunes are dominated by states of the same DD: the dominance checker of the model is thus cleared before each compilation, whether the model returns a new checker at each call of Model.dominance() or always the same one.

  • Constructor Details

    • LnsSolver

      public LnsSolver(LnsModel<T> model)
      Creates a new LNS solver for the provided model.
      Parameters:
      model - model containing the problem definition and LNS/DD configuration
  • Method Details

    • minimize

      public Solution minimize(Predicate<SearchStatistics> limit, BiConsumer<int[],SearchStatistics> onSolution)
      Minimizes the objective function according to the solver strategy.

      When the memory runs out, either because the JVM throws an OutOfMemoryError or because the frontier reaches the size given to StopCriterion.maxFrontierSize(int), the search stops and returns the best solution found so far with the status SearchStatus.MEMOUT.

      Specified by:
      minimize in interface Solver
      Parameters:
      limit - a Predicate that can limit or stop the search based on current SearchStatistics
      onSolution - a BiConsumer invoked on each new solution found; receives the solution array and current statistics
      Returns:
      the statistics of the search after completion
    • bestValue

      public Optional<Double> bestValue()
      Description copied from interface: Solver
      Returns the value of the best solution found so far by this solver, if any.
      Specified by:
      bestValue in interface Solver
      Returns:
      the value of the best solution in this decision diagram if there is one
    • bestSolution

      public Optional<Set<Decision>> bestSolution()
      Description copied from interface: Solver
      Returns the set of decisions that lead to the best solution found by this solver, if any.
      Specified by:
      bestSolution in interface Solver
      Returns:
      an Optional containing the set of Decision objects representing the best solution, or empty if no solution exists