|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.constraints.impl.search.AbstractSolver
public abstract class AbstractSolver
This class defines different solving methods for a given Problem including different flavors of such methods as: solve, solveAll, findSolution, minimize, maximize
| Constructor Summary | |
|---|---|
AbstractSolver()
|
|
AbstractSolver(Problem problem)
|
|
| Method Summary | |
|---|---|
void |
addReversibleAction(ReversibleAction action)
Adds an application-specific action that will be executed during backtracking. |
void |
addSearchStrategy(SearchStrategy strategy)
This method adds this strategy to the end of the strategy execution list. |
void |
addSearchStrategy(ValueSelector valueSelector)
This method creates a new instance of the default search strategy, resets its valueSelector, and adds this strategy to the end of the strategy execution lists. |
void |
addSearchStrategy(Var[] vars)
This method creates a new instance of 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 method creates a new instance of 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 method creates a new instance of 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 method creates a new instance of 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 method creates a new instance of 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 method creates a new instance of the default search strategy, resets its vars, varSelector, and valueSelector, and then adds this strategy to the end of the strategy execution list. |
void |
addSearchStrategy(Var[] vars,
VarSelector varSelector,
ValueSelector valueSelector)
This method creates a new instance of the default search strategy, resets its vars, varSelector, and valueSelector, and then adds this strategy to the end of the strategy execution list. |
void |
addSolution(Solution solution)
Adds a solution to the current array of solutions |
void |
addStrategyLogVariables()
This methods adds the strategy getStrategyLogVariables() to the end of the strategy execution lists. |
boolean |
applySolution(int solutionNumber)
This method tries to resolve the problem by applying the existing Solution at the "solutionNumber"-th index of the array of solutions (Accessible by getSolutions();). |
abstract boolean |
applySolution(Solution solution)
This method tries to resolve the problem by applying the Solution "solution" to the problem, and returns true if "solution" satisfies all of the posted constraints, false otherwise. |
boolean |
checkTimeLimit()
Validates in the difference between the current time and the getTimeLimitStart() time is more than getTimeLimit() |
void |
clearSolutions()
|
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(Var objectiveVar)
This method is equivalent to findOptimalSolution(Objective.MINIMIZE,objectiveVar) |
Solution |
findOptimalSolutionBasic(Objective objective,
Var objectiveVar)
This method is similar to findOptimalSolution(Objective objective, Var objectiveVar) but uses the common (no solver-specific) implementation |
Solution |
findOptimalSolutionDichotomize(Objective objective,
Var objectiveVar)
The actual minimization algorithm executes a dichotomized search. |
Solution |
findOptimalSolutionDichotomize(Var objectiveVar)
This method is equivalent to findOptimalSolutionCommon(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. |
abstract 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 |
java.util.Vector<SearchStrategy> |
getSearchStrategies()
|
SearchStrategy |
getSearchStrategy()
Returns a SearchStrategy that is currently used by the solver |
Solution |
getSolution()
Returns the first (or only) solution |
Solution |
getSolution(int i)
Returns the i-th Solution |
Solution[] |
getSolutions()
Returns an array of Solutions, containing all found solutions. |
long |
getSolverStartTime()
|
SearchStrategy |
getStrategyLogVariables()
Returns a search strategy that logs all variables |
int |
getTimeLimit()
Returns the duration, in milliseconds, of the imposed time limit on searches. |
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. |
boolean |
isTimeLimitExceeded()
Returns true if the time limit expired during a search, or false if not. |
boolean |
isTraceExecution()
|
boolean |
isTraceSolutions()
|
void |
log(java.lang.String text)
|
void |
logStats()
This method logs execution statistics such as a number of choice points, number of failures, used memory, etc. |
abstract SearchStrategy |
newSearchStrategy()
This method 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 searchStrategy that will be used by find solutions methods |
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 |
setSolverStartTime(long solverStartTime)
|
void |
setTimeLimit(int mills)
Sets the duration, in milliseconds, of the time limit on searches. |
void |
setTimeLimitExceeded(boolean exceeded)
Sets whether or not the time limit has expired. |
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 search and navigate through multiple solutions. |
void |
traceExecution(boolean flag)
This method forces each search strategy to log itself each time when solver calls its method execute |
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 |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.constraints.Solver |
|---|
trace, trace, trace |
| Constructor Detail |
|---|
public AbstractSolver()
public AbstractSolver(Problem problem)
| Method Detail |
|---|
public void addReversibleAction(ReversibleAction action)
action - the action to be executed during backtracking.public void addSearchStrategy(SearchStrategy strategy)
addSearchStrategy in interface Solverstrategy - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}public void addSearchStrategy(ValueSelector valueSelector)
valueSelector - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}public void addSearchStrategy(Var[] vars)
addSearchStrategy in interface Solvervars - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}
public void addSearchStrategy(Var[] vars,
ValueSelector valueSelector)
addSearchStrategy in interface Solvervars - valueSelector - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}
public void addSearchStrategy(Var[] vars,
ValueSelectorType valueSelectorType)
addSearchStrategy in interface Solvervars - valueSelectorType - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}
public void addSearchStrategy(Var[] vars,
VarSelector varSelector)
addSearchStrategy in interface Solvervars - varSelector - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}
public void addSearchStrategy(Var[] vars,
VarSelectorType varSelectorType)
addSearchStrategy in interface Solvervars - varSelectorType - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}
public void addSearchStrategy(Var[] vars,
VarSelectorType varSelectorType,
ValueSelectorType valueSelectorType)
addSearchStrategy in interface Solvervars - varSelectorType - valueSelectorType - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}
public void addSearchStrategy(Var[] vars,
VarSelector varSelector,
ValueSelector valueSelector)
addSearchStrategy in interface Solvervars - varSelector - valueSelector - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}public void addSolution(Solution solution)
public void addStrategyLogVariables()
addStrategyLogVariables in interface Solverpublic boolean applySolution(int solutionNumber)
solutionNumber - the Solution object being tested on the problem.
Solver#getSolution(),
Solver.getSolution(int),
Solver#applySolution(Solution)public abstract boolean applySolution(Solution solution)
solution - the Solution object being tested on the problem.
public boolean checkTimeLimit()
public void clearSolutions()
public Solution[] findAllSolutions()
findAllSolutions in interface Solver
public Solution findOptimalSolution(Objective objective,
Var objectiveVar)
findOptimalSolution in interface SolverobjectiveVar -
public Solution findOptimalSolution(Objective objective,
Var objectiveVar,
OptimizationStrategy optStrategy)
findOptimalSolution in interface Solverobjective - Objective.MINIMIZE or Objective.MAXIMIZEobjectiveVar - the variable that is being minimized/maximizedoptStrategy - OptimizationStrategy
public Solution findOptimalSolution(Var objectiveVar)
findOptimalSolution in interface SolverobjectiveVar -
public Solution findOptimalSolutionBasic(Objective objective,
Var objectiveVar)
objective - Objective.MINIMIZE or Objective.MAXIMIZEobjectiveVar - the variable that is being minimized/maximized
public Solution findOptimalSolutionDichotomize(Objective objective,
Var objectiveVar)
public Solution findOptimalSolutionDichotomize(Var objectiveVar)
objectiveVar -
public Solution findSolution()
findSolution in interface Solverpublic abstract Solution findSolution(ProblemState restoreOrNot)
findSolution in interface SolverrestoreOrNot - defines if the problem state should be restored after a solution is found
public int getMaxNumberOfSolutions()
getMaxNumberOfSolutions in interface Solverpublic int getNumberOfSolutions()
getNumberOfSolutions in interface Solverpublic int getOptimizationTolerance()
Solver
getOptimizationTolerance in interface Solverpublic Problem getProblem()
Solver
getProblem in interface Solverpublic java.util.Vector<SearchStrategy> getSearchStrategies()
public SearchStrategy getSearchStrategy()
Solver
getSearchStrategy in interface Solverpublic Solution getSolution()
public Solution getSolution(int i)
getSolution in interface SolverfindAllSolutions()public Solution[] getSolutions()
public long getSolverStartTime()
public SearchStrategy getStrategyLogVariables()
Solver
getStrategyLogVariables in interface Solverpublic int getTimeLimit()
getTimeLimit in interface Solverpublic int getTimeLimitGlobal()
getTimeLimitGlobal in interface Solverpublic long getTimeLimitStart()
getTimeLimitStart in interface Solverpublic boolean isTimeLimitExceeded()
public boolean isTraceExecution()
public boolean isTraceSolutions()
public void log(java.lang.String text)
public void logStats()
logStats in interface Solverpublic abstract SearchStrategy newSearchStrategy()
newSearchStrategy in interface Solverpublic void restoreProblem()
restoreProblem in interface Solverpublic void saveProblem()
saveProblem in interface Solverpublic void setMaxNumberOfSolutions(int maxNumberOfSolutions)
setMaxNumberOfSolutions in interface SolvermaxNumberOfSolutions - the new limit for the maximal number of solutions any search
can look for.public void setOptimizationTolerance(int tolerance)
Solver
setOptimizationTolerance in interface Solverpublic void setProblem(Problem problem)
Solver
setProblem in interface Solverpublic void setSearchStrategy(SearchStrategy strategy)
setSearchStrategy in interface Solverstrategy - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}public void setSearchStrategy(Var[] vars)
setSearchStrategy in interface Solvervars - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}
public void setSearchStrategy(Var[] vars,
ValueSelector valueSelector)
setSearchStrategy in interface Solvervars - valueSelector - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}
public void setSearchStrategy(Var[] vars,
VarSelector varSelector)
setSearchStrategy in interface Solvervars - varSelector - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}
public void setSearchStrategy(Var[] vars,
VarSelector varSelector,
ValueSelector valueSelector)
setSearchStrategy in interface Solvervars - varSelector - valueSelector - AbstractSolver#findSolution()} {@link AbstractSolver#findOptimalSolution(Var)}public void setSolverStartTime(long solverStartTime)
public void setTimeLimit(int mills)
setTimeLimit in interface Solvermills - the new time limit in millisecondspublic void setTimeLimitExceeded(boolean exceeded)
exceeded - true if the time limit exceeded, false otherwise.public void setTimeLimitGlobal(int mills)
setTimeLimitGlobal in interface Solvermills - the new global time limit in millisecondspublic void setTimeLimitStart()
setTimeLimitStart in interface Solverpublic SolutionIterator solutionIterator()
solutionIterator in interface Solverpublic void traceExecution(boolean flag)
traceExecution in interface Solverflag - booleanpublic void traceFailures(boolean flag)
traceFailures in interface Solverflag - public void traceSolutions(boolean trueOrFalse)
traceSolutions in interface SolvertrueOrFalse - boolean
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||