public interface Solver
The Solver provides a standardized way to implement the following functions:
SearchStrategy s1 = solver.getSearchStrategy(); s1.setVars(types); SearchStrategy s2 = solver.newSearchStrategy(); s2.setVars(counts); s2.setVarSelectorType(VarSelectorType.RANDOM); solver.addStrategy(s2);
Solution
,
SearchStrategy
,
VarSelector
,
ValueSelector
Modifier and Type | Method and Description |
---|---|
void |
addSearchStrategy(SearchStrategy strategy)
This methods adds this strategy
to the end of the strategy execution lists.
|
void |
addSearchStrategy(Var[] vars)
This methods takes the default search strategy, resets its
vars, and adds this strategy to the end of the strategy execution lists.
|
void |
addSearchStrategy(Var[] vars,
ValueSelector valueSelector)
This methods takes the default search strategy, resets its
vars and valueSelector, and adds this strategy to the end of the strategy execution lists.
|
void |
addSearchStrategy(Var[] vars,
ValueSelectorType valueSelectorType)
This methods takes the default search strategy, resets its
vars and valueSelector, and adds this strategy to the end of the strategy execution lists.
|
void |
addSearchStrategy(Var[] vars,
VarSelector varSelector)
This methods takes the default search strategy, resets its
vars and varSelector, and adds this strategy to the end of the strategy execution lists.
|
void |
addSearchStrategy(Var[] vars,
VarSelectorType varSelectorType)
This methods takes the default search strategy, resets its
vars and varSelector, and adds this strategy to the end of the strategy execution lists.
|
void |
addSearchStrategy(Var[] vars,
VarSelectorType varSelectorType,
ValueSelectorType valueSelectorType)
This methods takes the default search strategy, resets its
vars, varSelector, and valueSelector, and then adds this strategy
to the end of the strategy execution lists.
|
void |
addSearchStrategy(Var[] vars,
VarSelector varSelector,
ValueSelector valueSelector)
This methods takes the default search strategy, resets its
vars, varSelector, and valueSelector, and then adds this strategy
to the end of the strategy execution lists.
|
void |
addStrategyLogVariables()
This methods adds the strategy getStrategyLogVariables()
to the end of the strategy execution lists.
|
Solution[] |
findAllSolutions()
This method attempts to find all solutions for the Problem.
|
Solution |
findOptimalSolution(Objective objective,
Var objectiveVar)
This method is equivalent to
findOptimalSolution(Objective.MINIMIZE,objectiveVar,OptimizationStrategy.NATIVE)
It is usually overridden by an implementation
|
Solution |
findOptimalSolution(Objective objective,
Var objectiveVar,
OptimizationStrategy optStrategy)
This method attempts to find the solution that minimizes/maximizes the objective variable.
|
Solution |
findOptimalSolution(Objective objective,
VarReal objectiveVar)
This method is equivalent to
findOptimalSolution(Objective.MINIMIZE,objectiveVar,OptimizationStrategy.NATIVE)
It is usually overridden by an implementation
|
Solution |
findOptimalSolution(Objective objective,
VarReal objectiveVar,
OptimizationStrategy optStrategy) |
Solution |
findOptimalSolution(Var objectiveVar)
This method is equivalent to findOptimalSolution(Objective.MINIMIZE,objectiveVar)
|
Solution |
findOptimalSolution(VarReal objectiveVar)
This method is equivalent to findOptimalSolution(Objective.MINIMIZE,objectiveVar)
|
Solution |
findSolution()
This method is equivalent to findSolution(DO_NOT_RESTORE);
It means that the problem state will always be restored even when a solution is found.
|
Solution |
findSolution(ProblemState restoreOrNot)
This method attempts to find a solution of the problem, for which the solver was defined.
|
int |
getMaxNumberOfSolutions()
Returns the maximal number of solutions any search can look for.
|
int |
getNumberOfSolutions()
Returns the number of the last solution found, or 0 if no solutions
have been found yet (or the search for a solution was not yet launched).
|
int |
getOptimizationTolerance()
Returns the current tolerance for the method findOptimalSolution()
|
Problem |
getProblem()
Returns the Problem for which this solver was created
|
SearchStrategy |
getSearchStrategy()
Returns a SearchStrategy that is currently used by the solver
|
Solution |
getSolution(int i)
Returns the i-th Solution found by the latest search
|
SearchStrategy |
getStrategyLogVariables()
Returns a search strategy that logs all variables
|
int |
getTimeLimit()
Returns the duration, in milliseconds, of the imposed time limit on search of one solution.
|
int |
getTimeLimitGlobal()
Returns the duration, in milliseconds, of the imposed time limit
on global search of all solutions or an optimal solution.
|
long |
getTimeLimitStart()
Returns the time, in milliseconds, at which the time limit began counting.
|
void |
logStats()
This method logs execution statistics such as a number of choice points,
number of failures, used memory, etc.
|
SearchStrategy |
newSearchStrategy()
This methods returns a new default search strategy
|
void |
restoreProblem()
Restores a previously saved problem
|
void |
saveProblem()
Creates a copy of the problem in its current state
|
void |
setMaxNumberOfSolutions(int maxNumberOfSolutions)
Sets the limit on the maximal number of solutions any search can look for.
|
void |
setOptimizationTolerance(int tolerance)
Specifies a tolerance for the method findOptimalSolution().
|
void |
setProblem(Problem problem)
Set the Problem with which this solver should work
|
void |
setSearchStrategy(SearchStrategy strategy)
Define a search strategy that will be used by the solver to solve the problem.
|
void |
setSearchStrategy(Var[] vars)
Define a searchStrategy that will be used by find solutions methods.
|
void |
setSearchStrategy(Var[] vars,
ValueSelector valueSelector)
Define a searchStrategy that will be used by find solutions methods.
|
void |
setSearchStrategy(Var[] vars,
VarSelector varSelector)
Define a searchStrategy that will be used by find solutions methods.
|
void |
setSearchStrategy(Var[] vars,
VarSelector varSelector,
ValueSelector valueSelector)
Define a searchStrategy that will be used by find solutions methods.
|
void |
setTimeLimit(int mills)
Sets the duration, in milliseconds, of the time limit on search of one solution.
|
void |
setTimeLimitGlobal(int mills)
Sets the duration, in milliseconds, of the time limit
on global search of all solutions or an optimal solution.
|
void |
setTimeLimitStart()
Sets the start time as the system current time, for counting milliseconds to the time limit.
|
SolutionIterator |
solutionIterator()
Creates a solution iterator that allows a user to find and navigate
through solutions using the default search strategy.
|
void |
trace(Var var)
This method forces to trace (to log) all modification events for
the variable "var".
|
void |
trace(Var[] vars)
This method forces to trace (to log) all modification events for
all variables "vars"
|
void |
trace(VarSet setVar)
This method forces to trace (to log) all modification events for
the variable "setVar".
|
void |
traceExecution(boolean trueOrFalse)
This method forces the execution to
log important execution points
|
void |
traceFailures(boolean flag)
If flag is true, all failures will be traced (logged)
|
void |
traceSolutions(boolean trueOrFalse)
This method forces the execution to
log intermediate solutions during optimization search
|
void addSearchStrategy(SearchStrategy strategy)
strategy
- void addSearchStrategy(Var[] vars)
vars
- void addSearchStrategy(Var[] vars, ValueSelector valueSelector)
vars
- valueSelector
- void addSearchStrategy(Var[] vars, ValueSelectorType valueSelectorType)
vars
- valueSelectorType
- void addSearchStrategy(Var[] vars, VarSelector varSelector)
vars
- varSelector
- void addSearchStrategy(Var[] vars, VarSelectorType varSelectorType)
vars
- varSelectorType
- void addSearchStrategy(Var[] vars, VarSelectorType varSelectorType, ValueSelectorType valueSelectorType)
vars
- varSelectorType
- valueSelectorType
- void addSearchStrategy(Var[] vars, VarSelector varSelector, ValueSelector valueSelector)
vars
- varSelector
- valueSelector
- void addStrategyLogVariables()
Solution[] findAllSolutions()
Solution findOptimalSolution(Objective objective, Var objectiveVar)
objectiveVar
- Solution findOptimalSolution(Objective objective, Var objectiveVar, OptimizationStrategy optStrategy)
objective
- Objective.MINIMIZE or Objective.MAXIMIZEobjectiveVar
- the variable that is being minimized/maximizedoptStrategy
- OptimizationStrategy (BASIC, DICHOTOMIZE, or NATIVE)Solution findOptimalSolution(Objective objective, VarReal objectiveVar)
objectiveVar
- Solution findOptimalSolution(Objective objective, VarReal objectiveVar, OptimizationStrategy optStrategy)
Solution findOptimalSolution(Var objectiveVar)
objectiveVar
- Solution findOptimalSolution(VarReal objectiveVar)
objectiveVar
- Solution findSolution()
Solution findSolution(ProblemState restoreOrNot)
restoreOrNot
- defines if the problem state should be restored after a solution is foundint getMaxNumberOfSolutions()
int getNumberOfSolutions()
int getOptimizationTolerance()
Problem getProblem()
SearchStrategy getSearchStrategy()
Solution getSolution(int i)
findAllSolutions()
SearchStrategy getStrategyLogVariables()
int getTimeLimit()
int getTimeLimitGlobal()
long getTimeLimitStart()
void logStats()
SearchStrategy newSearchStrategy()
void restoreProblem()
void saveProblem()
void setMaxNumberOfSolutions(int maxNumberOfSolutions)
maxNumberOfSolutions
- the new limit for the maximal number of solutions any search can
look for.void setOptimizationTolerance(int tolerance)
tolerance
- void setProblem(Problem problem)
void setSearchStrategy(SearchStrategy strategy)
strategy
- void setSearchStrategy(Var[] vars)
vars
- void setSearchStrategy(Var[] vars, ValueSelector valueSelector)
vars
- valueSelector
- void setSearchStrategy(Var[] vars, VarSelector varSelector)
vars
- varSelector
- void setSearchStrategy(Var[] vars, VarSelector varSelector, ValueSelector valueSelector)
vars
- varSelector
- valueSelector
- void setTimeLimit(int mills)
mills
- the new time limit in millisecondsvoid setTimeLimitGlobal(int mills)
mills
- the new global time limit in millisecondsvoid setTimeLimitStart()
SolutionIterator solutionIterator()
void trace(Var var)
var
- void trace(Var[] vars)
vars
- void trace(VarSet setVar)
setVar
- void traceExecution(boolean trueOrFalse)
trueOrFalse
- booleanvoid traceFailures(boolean flag)
flag
- void traceSolutions(boolean trueOrFalse)
trueOrFalse
- boolean