|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjopt.csp.CspSolver
Class that is used to construct and solve CSP problems. The solver can be based on various different CSP algorithms and searching techniques, but it also has default algorithms if the user does not wish to override these options.
Constructor Summary | |
CspSolver()
|
Method Summary | |
abstract void |
addConstraint(CspBooleanExpr bool)
Adds a boolean expression as a constraint to the CspSolver . |
abstract void |
addConstraint(CspConstraint constraint)
Adds a constraint to the constraint reduction algorithm of this CspSolver . |
abstract void |
addConstraint(CspConstraint constraint,
boolean keepAfterReset)
Adds a constraint to the constraint reduction algorithm of this CspSolver . |
abstract void |
addVariable(CspVariable var)
Adds a variable to be managed by the solver. |
abstract void |
clear()
Resets all variables and removes all constraints and variables added to solver |
static CspSolver |
createSolver()
Creates a new solver based upon a default generalized AC5 bounds algorithm with a default search manager |
static CspSolver |
createSolver(CspAlgorithm alg)
Creates a new solver based upon a specific algorithm with the default search manager |
static CspSolver |
createSolver(CspAlgorithm alg,
SearchManager mgr)
Creates a new solver based upon a given CSP algorithm and search manager |
static CspSolver |
createSolver(SearchManager mgr)
Creates a new solver based upon a default generalized AC5 algorithm with a specific search manager |
abstract boolean |
getAutoPropagate()
Retrieves the auto propagation status |
LocalSearch |
getLocalSearch()
Returns a LocalSearch object that is used to create common objects for use during local neighborhood search operations |
SearchActions |
getSearchActions()
Returns a SearchActions object that is used to create common search operations |
SearchGoals |
getSearchGoals()
Returns a SearchGoals object that is will create common goals for guiding searches |
SearchLimits |
getSearchLimits()
Returns a SearchLimits object that is used to create common limits for use to control search operations |
SearchTechniques |
getSearchTechniques()
Returns a SearchTechniques object that is used to create common techniques for guiding searches such as Breadth First Searching and Depth First Searching |
CspVariableFactory |
getVarFactory()
Returns the variable factory for the algorithm the solver is based upon |
abstract boolean |
nextSolution()
Searches for another solution to a previous search initiated by a call to a solve method. |
abstract boolean |
propagate()
Propagates the constraints currently defined using the constraint reduction algorithm of this CspSolver . |
abstract void |
reset()
Resets all variables by undoing all changes stored in the CspSolver
for the wrapped algorithm and leaving any constraints that have been added. |
abstract void |
restoreNeighboringSolution(SolverSolution initial,
SolverSolution neighbor)
Restores a neighboring solution to another solution that was previously stored. |
abstract void |
restoreSolution(SolverSolution solution)
Restores domain state information for variables defined within a solution. |
void |
restoreSolution(SolverSolution solution,
boolean reset)
Calls reset() before calling restoreSolution(SolverSolution)
depending on boolean flag passed |
abstract void |
setAutoPropagate(boolean autoPropagate)
Sets the auto propagation status of this CspSolver . |
boolean |
solve(CspDoubleVariable[] vars,
double precision)
Resets the solver and locates a solution for an array of variables within the problem contained by the solver Since real numbers can be divided an infinite number of times, a precision value must be specified to indicate when the range of the variable is small enough to consider the variable completely instantiated. |
boolean |
solve(CspFloatVariable[] vars,
float precision)
Resets the solver and locates a solution for an array of variables within the problem contained by the solver Since real numbers can be divided an infinite number of times, a precision value must be specified to indicate when the range of the variable is small enough to consider the variable completely instantiated. |
boolean |
solve(CspIntVariable[] vars)
Resets the solver and locates a solution for an array of variables within the problem contained by the solver |
boolean |
solve(CspIntVariable[] vars,
boolean reset)
Locates a solution for an array of variables within the problem contained by the solver |
boolean |
solve(CspLongVariable[] vars)
Resets the solver and locates a solution for an array of variables within the problem contained by the solver |
boolean |
solve(CspSetVariable[] vars)
Resets the solver and locates a solution for an array of variables within the problem contained by the solver |
boolean |
solve(Search search)
Resets the solver and locates a solution for the current problem given a Search object. |
boolean |
solve(SearchAction action)
Resets the solver and locates a solution for the current problem given a search action that defines a set of operations that should be performed in order to locate a solution. |
boolean |
solve(SearchAction action,
boolean reset)
Locates a solution for the current problem given a search action that defines a set of operations that should be searched in order to locate a solution. |
boolean |
solve(SearchAction action,
SearchGoal goal)
Resets the solver and locates a solution for the current problem given a search action that defines a set of operations that should be performed in order to locate a solution. |
boolean |
solve(SearchAction action,
SearchGoal goal,
boolean continuallyImprove)
Resets the solver and locates a solution for the current problem given a search action that defines a set of operations that should be performed in order to locate a solution. |
boolean |
solve(SearchAction action,
SearchGoal goal,
SearchTechnique technique)
Resets the solver and locates a solution. |
boolean |
solve(SearchAction action,
SearchGoal goal,
SearchTechnique technique,
boolean continuallyImprove)
Resets the solver and locates a solution for the current problem. |
abstract boolean |
solve(SearchAction action,
SearchGoal goal,
SearchTechnique technique,
boolean continuallyImprove,
boolean reset)
Locates a solution for the current problem. |
boolean |
solve(SearchAction action,
SearchTechnique technique)
Resets the solver and locates a solution. |
boolean |
solve(SearchAction action,
SearchTechnique technique,
boolean reset)
Locates a solution for the current problem. |
abstract boolean |
solve(Search search,
boolean reset)
Locates a solution for the current problem given a Search object. |
SolverSolution |
storeSolution(SolutionScope scope)
Returns a solution that has recorded the variable domain information for the variables within the scope specified. |
abstract void |
storeSolution(SolverSolution solution)
Records domain values for variables that are defined in the scope of the specified solution. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CspSolver()
Method Detail |
public static CspSolver createSolver()
public static CspSolver createSolver(CspAlgorithm alg, SearchManager mgr)
alg
- Algorithm the new solver should be based upon. If null, the
implementing class should use a default of its choice.mgr
- Search manager that will be used to locate solutions by solver.
If null, the implementing class should use a default solver of its
choice.public static CspSolver createSolver(SearchManager mgr)
mgr
- Search manager that will be used to locate solutions by solverpublic static CspSolver createSolver(CspAlgorithm alg)
alg
- Algorithm solver is based uponpublic CspVariableFactory getVarFactory()
public SearchActions getSearchActions()
public SearchGoals getSearchGoals()
public SearchTechniques getSearchTechniques()
public LocalSearch getLocalSearch()
public SearchLimits getSearchLimits()
public abstract boolean getAutoPropagate()
CspSolver
public abstract void setAutoPropagate(boolean autoPropagate)
CspSolver
.
autoPropagate
- The new value of the autoUpdate flag.public abstract boolean propagate()
CspSolver
. Note that calls to this method are
unnecessary when the auto propagate flag is set.
public abstract void addVariable(CspVariable var)
public abstract void addConstraint(CspConstraint constraint) throws PropagationFailureException
CspSolver
.
Constraint will be kept after store is reset.
constraint
- The constraint to be added to the reduction algorithm.
If
- auto propagate is set, this forces the wrapped algorithm to propagate the constraint.
If the propagation fails, an appropriate exception is thrown. If, however, the auto propagate
flag is not set, this method will not throw an exception.
PropagationFailureException
public abstract void addConstraint(CspConstraint constraint, boolean keepAfterReset) throws PropagationFailureException
CspSolver
.
Allows you to specify whether the constraint will be kept after store is reset.
constraint
- The constraint to be added to the reduction algorithm.keepAfterReset
- True if constraint should be kept after reset if performed
If
- autoPropagate is set, this forces the wrapped algorithm to propagate the constraint.
If the propagation fails, an appropriate exception is thrown. If, however, the autoPropagate
is not set, this method will not throw an exception.
PropagationFailureException
public abstract void addConstraint(CspBooleanExpr bool) throws PropagationFailureException
CspSolver
.
bool
- Boolean expression representing a constraint
PropagationFailureException
public abstract void clear()
public abstract void reset()
CspSolver
for the wrapped algorithm and leaving any constraints that have been added.
public abstract boolean solve(Search search, boolean reset)
search
- Search object used to locate solutionsreset
- True if state of problem should be reset before starting search
public boolean solve(Search search)
search
- Search object used to locate solutions
public abstract boolean solve(SearchAction action, SearchGoal goal, SearchTechnique technique, boolean continuallyImprove, boolean reset)
action
- Search action used to locate a solutiongoal
- Goal to guide search towards a solutiontechnique
- Search technique used to locate a solutioncontinuallyImprove
- True if each successive solution found will be an improvement over previous, false
if the best solution (according to the goal) is found during the original searchreset
- True if state of problem should be reset before starting search
public boolean solve(SearchAction action, SearchGoal goal, SearchTechnique technique, boolean continuallyImprove)
action
- Search action used to locate a solutiongoal
- Goal to guide search towards a solution.technique
- Search technique used to locate a solutioncontinuallyImprove
- True if successive solutions found will be an improvement over previous, false
if the best solution (according to the goal) is found during the original search
public boolean solve(SearchAction action, SearchGoal goal, SearchTechnique technique)
action
- Search action used to locate a solutiongoal
- Goal to guide search towards a solution.technique
- Search technique used to locate a solution
public boolean solve(SearchAction action, SearchTechnique technique)
action
- Search action used to locate a solutiontechnique
- Search technique used to locate a solution
public boolean solve(SearchAction action, SearchTechnique technique, boolean reset)
action
- Search action used to locate a solutiontechnique
- Search technique used to locate a solutionreset
- True if state of problem should be reset before starting search
public boolean solve(SearchAction action, SearchGoal goal, boolean continuallyImprove)
action
- Search action used to locate a solutiongoal
- Goal to guide search towards a solution.continuallyImprove
- True if each successive solution found will be an improvement over previous, false
if the best solution (according to the goal) is found during the original search
public boolean solve(SearchAction action, SearchGoal goal)
action
- Search action used to locate a solutiongoal
- Goal to guide search towards a solution.
public boolean solve(SearchAction action)
action
- Search action used to locate a solution
public boolean solve(SearchAction action, boolean reset)
action
- Search action used to locate a solutionreset
- True if solver should be reset before solving
public boolean solve(CspIntVariable[] vars)
vars
- Array of variables to instantiate
public boolean solve(CspIntVariable[] vars, boolean reset)
vars
- Array of variables to instantiatereset
- True if solver should be reset before solving
public boolean solve(CspLongVariable[] vars)
vars
- Array of variables to instantiate
public boolean solve(CspFloatVariable[] vars, float precision)
vars
- Array of variables to instantiateprecision
- Minimum precision to which variable domain will be reduced
public boolean solve(CspDoubleVariable[] vars, double precision)
vars
- Array of variables to instantiateprecision
- Minimum precision to which variable domain will be reduced
public boolean solve(CspSetVariable[] vars)
vars
- Array of variables to instantiate
public abstract boolean nextSolution()
solve
method.
public SolverSolution storeSolution(SolutionScope scope)
scope
- Scope of variables to include in solutionpublic abstract void storeSolution(SolverSolution solution)
solution
- Solution object to record data that specifies
which variables should be captured in solutionpublic void restoreSolution(SolverSolution solution, boolean reset) throws PropagationFailureException
reset()
before calling restoreSolution(SolverSolution)
depending on boolean flag passed
solution
- Solution object with recorded variable data that
should be restoredreset
- True if solver should be reset before restoration
PropagationFailureException
public abstract void restoreSolution(SolverSolution solution) throws PropagationFailureException
reset
call must be made before restoring if the solution
should not be applied to the current state of the solver but
instead should be applied to the original state of the solver.
solution
- Solution object with recorded variable data that
should be restored to problem
PropagationFailureException
public abstract void restoreNeighboringSolution(SolverSolution initial, SolverSolution neighbor) throws PropagationFailureException
initial
- Initial solution that was previously storedneighbor
- Neighboring solution to restore
PropagationFailureException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |