Package org.ddolib.layered.solver
Interface Solver
- All Known Implementing Classes:
AcsSolver,AStarSolver,AwAstarSolver,ExactSolver,LnsSolver,SequentialSolver
public interface Solver
Interface representing a generic solver for decision diagram based optimization problems.
A solver explores the search space defined by a decision diagram, applies bounds and relaxations, and can return the best solution found along with its value.
Implementations of this interface typically provide algorithms such as:
- Dynamic programming on decision diagrams
- A* search
- Branch-and-bound or anytime search strategies
- See Also:
-
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.default int[]constructSolution(Set<Decision> decisions) Constructs an array representing the values assigned to each variable from a set of decisions.initialSolution(Model<?> model) Returns the initial solution of a model, if it provides a non-empty one.minimize(Predicate<SearchStatistics> limit, BiConsumer<int[], SearchStatistics> onSolution) Minimizes the objective function according to the solver strategy.
-
Method Details
-
initialSolution
Returns the initial solution of a model, if it provides a non-empty one.Its value is trusted. When the debug mode is enabled, it is checked against
Problem.evaluate(int[]).- Parameters:
model- the model providing the initial solution- Returns:
- the initial solution, or an empty
Optionalif the model has none - Throws:
IllegalArgumentException- in debug mode, if the initial solution is invalid or if its value does not match its evaluation
-
minimize
Minimizes the objective function according to the solver strategy.- 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
Returns the value of the best solution found so far by this solver, if any.- Returns:
- the value of the best solution in this decision diagram if there is one
-
bestSolution
Returns the set of decisions that lead to the best solution found by this solver, if any. -
constructSolution
Constructs an array representing the values assigned to each variable from a set of decisions.- Parameters:
decisions- a set ofDecisionobjects representing variable assignments- Returns:
- an array
tsuch thatt[i]is the assigned value of variablei, or an empty array if the solution does not exist
-