Class LnsSolver<T>
- Type Parameters:
T- type of states manipulated by the underlying problem
- All Implemented Interfaces:
Solver
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 limitStopCriterion.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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the set of decisions that lead to the best solution found by this solver, if any.Returns the value of the best solution found so far by this solver, if any.minimize(Predicate<SearchStatistics> limit, BiConsumer<int[], SearchStatistics> onSolution) Minimizes the objective function according to the solver strategy.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ddolib.layered.solver.Solver
constructSolution
-
Constructor Details
-
LnsSolver
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
OutOfMemoryErroror because the frontier reaches the size given toStopCriterion.maxFrontierSize(int), the search stops and returns the best solution found so far with the statusSearchStatus.MEMOUT.- Specified by:
minimizein interfaceSolver- Parameters:
limit- aPredicatethat can limit or stop the search based on currentSearchStatisticsonSolution- aBiConsumerinvoked on each new solution found; receives the solution array and current statistics- Returns:
- the statistics of the search after completion
-
bestValue
Description copied from interface:SolverReturns the value of the best solution found so far by this solver, if any. -
bestSolution
Description copied from interface:SolverReturns the set of decisions that lead to the best solution found by this solver, if any.- Specified by:
bestSolutionin interfaceSolver- Returns:
- an
Optionalcontaining the set ofDecisionobjects representing the best solution, or empty if no solution exists
-