public abstract class MetaConstraintSolver extends MultiConstraintSolver
ConstraintNetworks - i.e., variables and
constraints which should be posted to the ground-CSP(s) in order to satisfy the meta-constraints.
In resource scheduling for instance, a value of a meta-variable is a temporal constraint that
eliminates the temporal overlap of the concurrent over-consuming activities.
This class provides the fundamental mechanisms to define and solve a meta-CSP. It implements
a backtracking search over the search space defined by meta-variables, meta-values and
meta-constraints. Examples of concrete MetaConstraintSolvers that implement this
class are given in this framework (e.g., the TCSPSolver, which implements
a Temporal Constraint Satisfaction Problem solver as a meta-CSP, and the Scheduler, which
implements the ESTA algorithm for solving resource scheduling problems).
This class also provides limited support for constraint optimization through branch-and-bound.| Modifier and Type | Class and Description |
|---|---|
protected class |
MetaConstraintSolver.TerminalNode |
MultiConstraintSolver.OPTIONS| Modifier and Type | Field and Description |
|---|---|
protected long |
animationTime |
protected boolean |
breakSearch |
protected int |
counterMoves |
protected FocusConstraint |
currentFocus |
protected MetaVariable |
currentVertex |
protected edu.uci.ics.jung.graph.DelegateForest<MetaVariable,ConstraintNetwork> |
g |
protected java.util.Vector<MetaConstraint> |
metaConstraints |
protected java.util.HashMap<ConstraintNetwork,MetaConstraint> |
metaVarsToMetaCons |
protected java.util.HashMap<ConstraintNetwork,ConstraintNetwork> |
resolvers |
protected java.util.HashMap<ConstraintNetwork,ConstraintNetwork> |
resolversInverseMapping |
constraintSolvers, ingredientsautoprop, components, constraintTypes, IDs, logger, name, nesting, noPropOnVarCreation, numcalls, skipPropagation, spacing, theNetwork, variableType| Modifier | Constructor and Description |
|---|---|
protected |
MetaConstraintSolver(java.lang.Class<?>[] constraintTypes,
long animationTime,
ConstraintSolver... internalSolvers) |
| Modifier and Type | Method and Description |
|---|---|
void |
addMetaConstraint(MetaConstraint metaConstraint)
Method to add a
MetaConstraint to this meta-CSP solver. |
protected boolean |
addResolver(ConstraintNetwork metaVarConstraintNetwork,
ConstraintNetwork resolverNetwork) |
protected abstract boolean |
addResolverSub(ConstraintNetwork metaVariable,
ConstraintNetwork metaValue)
Implement this method to define any additional operations that should happen before
adding a meta-value in the meta-CSP search (e.g., when branching).
|
boolean |
backtrack()
Initiates CSP-style backtracking search on the meta-CSP.
|
boolean |
branchAndBound()
Perform branch-and-bound search for an optimal solution to this meta-CSP.
|
void |
breakSearch()
Interrupt the current meta-CSP search.
|
void |
clearResolvers()
Clear memory of all resolvers added to the ground-CSP(s) in order to obtain the
current solution to the meta-CSP.
|
void |
draw()
Draws the search space of the meta-CSP.
|
void |
failurePruning(int failure_time) |
void |
focus(Variable... vars) |
ConstraintNetwork[] |
getAddedResolvers()
Get the final list of resolvers (meta-values) added to the ground-CSP(s)
for obtaining a solution to the meta-CSP.
|
protected MetaVariable |
getConflict() |
ConstraintSolver[] |
getConstraintSolvers()
Get all the ground constraint solvers of this meta-CSP.
|
int |
getCounterMoves() |
FocusConstraint |
getCurrentFocusConstraint() |
java.lang.String |
getDescription()
Gets a description of this
ConstraintSolver stating which variable and constraint types it supports. |
Variable[] |
getFocused() |
java.util.HashMap<ConstraintSolver,Variable[]> |
getGroundVariables()
Get all the
Variables of all ground solvers used by this MetaConstraintSolver. |
protected abstract double |
getLowerBound() |
MetaConstraint |
getMetaConstraint(ConstraintNetwork metaVariable) |
MetaConstraint[] |
getMetaConstraints() |
java.util.HashMap<ConstraintNetwork,ConstraintNetwork> |
getResolvers() |
java.util.HashMap<ConstraintNetwork,ConstraintNetwork> |
getResolversInverseMapping() |
boolean |
getTimeOut() |
protected abstract double |
getUpperBound() |
protected abstract boolean |
hasConflictClause(ConstraintNetwork metaValue) |
boolean |
isFocused(Variable var) |
abstract void |
postBacktrack(MetaVariable metaVariable)
Implement this method to define any extra operations that should be performed
after branching over a
MetaVariable. |
abstract void |
preBacktrack()
Implement this method to define any extra operations that should be performed
before backtracking over a
MetaVariable (and before it is even chosen). |
boolean |
propagate()
Propagate the constraint network.
|
void |
registerValueChoiceFunctions() |
void |
removeFromCurrentFocus(Variable... vars) |
protected abstract void |
resetFalseClause() |
protected void |
retractResolver(ConstraintNetwork metaVar,
ConstraintNetwork res) |
void |
retractResolvers()
Retract all resolvers added to the ground-CSP(s) in order to obtain the
current solution to the meta-CSP.
|
protected abstract void |
retractResolverSub(ConstraintNetwork metaVariable,
ConstraintNetwork metaValue)
Implement this method to define any extra operations that should happen
after retracting a meta-value in the meta-CSP search (e.g., when backtracking).
|
void |
setCounterMoves(int counterMoves) |
void |
setCurrentFocusConstraint(FocusConstraint focus) |
void |
setFocus(Variable... vars) |
protected abstract void |
setLowerBound() |
void |
setResolvers(java.util.HashMap<ConstraintNetwork,ConstraintNetwork> resolvers) |
protected abstract void |
setUpperBound() |
addConstraintsSub, createVariablesSub, createVariablesSub, createVariablesSub, drawConstraintNetworkHierarchy, drawConstraintSolverHierarchy, getConstraintNetworkHierarchy, getConstraintNetworksFromSolverHierarchy, getConstraintSolver, getConstraintSolverHierarchy, getConstraintSolversFromConstraintSolverHierarchy, getOption, removeConstraintsSub, removeVariablesSub, setConstraintSolver, setIngredients, setOptionsaddConstraint, addConstraintNoPropagation, addConstraints, addConstraintsDebug, addConstraintsNoPropagation, containsVariable, createVariable, createVariable, createVariables, createVariables, deplenish, getComponent, getComponents, getConstraintNetwork, getConstraints, getConstraints, getID, getOption, getVariable, getVariables, getVariables, getVariables, isCompatible, maskConstraints, removeConstraint, removeConstraints, removeVariable, removeVariables, setComponent, setComponents, setConstraintNetwork, setName, setOptions, toString, unmaskConstraintsprotected java.util.Vector<MetaConstraint> metaConstraints
protected edu.uci.ics.jung.graph.DelegateForest<MetaVariable,ConstraintNetwork> g
protected MetaVariable currentVertex
protected boolean breakSearch
protected java.util.HashMap<ConstraintNetwork,MetaConstraint> metaVarsToMetaCons
protected java.util.HashMap<ConstraintNetwork,ConstraintNetwork> resolvers
protected java.util.HashMap<ConstraintNetwork,ConstraintNetwork> resolversInverseMapping
protected long animationTime
protected int counterMoves
protected FocusConstraint currentFocus
protected MetaConstraintSolver(java.lang.Class<?>[] constraintTypes,
long animationTime,
ConstraintSolver... internalSolvers)
public MetaConstraint[] getMetaConstraints()
public ConstraintNetwork[] getAddedResolvers()
public void retractResolvers()
public void clearResolvers()
retractResolvers().public void addMetaConstraint(MetaConstraint metaConstraint)
MetaConstraint to this meta-CSP solver.metaConstraint - The MetaConstraint to add.protected MetaVariable getConflict()
public abstract void preBacktrack()
MetaVariable (and before it is even chosen).public abstract void postBacktrack(MetaVariable metaVariable)
MetaVariable.metaVariable - The MetaVariable that has been branched upon.public boolean backtrack()
true iff a set of assignments to all MetaVariables which
satisfies the MetaConstraints was found.public boolean getTimeOut()
protected final boolean addResolver(ConstraintNetwork metaVarConstraintNetwork, ConstraintNetwork resolverNetwork)
protected final void retractResolver(ConstraintNetwork metaVar, ConstraintNetwork res)
public boolean propagate()
ConstraintSolverpropagate in class MultiConstraintSolverprotected abstract void retractResolverSub(ConstraintNetwork metaVariable, ConstraintNetwork metaValue)
metaVariable - The MetaVariable over which backtracking occurs.metaValue - The meta-value that has been retracted.protected abstract boolean addResolverSub(ConstraintNetwork metaVariable, ConstraintNetwork metaValue)
metaVariable - The MetaVariable over which the search is branching.metaValue - The meta-value that has been selected (the branch).true iff the metavalue is consistent with the ground-CSP (Note: if false is returned, the ground-CSP has not been changed, i.e., it is left in a consistent state.)public java.util.HashMap<ConstraintSolver,Variable[]> getGroundVariables()
Variables of all ground solvers used by this MetaConstraintSolver.public void draw()
public ConstraintSolver[] getConstraintSolvers()
getConstraintSolvers in class MultiConstraintSolverpublic void breakSearch()
public boolean branchAndBound()
true iff IRAN: complete this please!protected abstract double getUpperBound()
protected abstract void setUpperBound()
protected abstract double getLowerBound()
protected abstract void setLowerBound()
protected abstract boolean hasConflictClause(ConstraintNetwork metaValue)
protected abstract void resetFalseClause()
public java.lang.String getDescription()
ConstraintSolverConstraintSolver stating which variable and constraint types it supports.getDescription in class MultiConstraintSolverConstraintSolver stating which variable and constraint types it supports.public void failurePruning(int failure_time)
failurePruning in class MultiConstraintSolverpublic int getCounterMoves()
public FocusConstraint getCurrentFocusConstraint()
public void setCurrentFocusConstraint(FocusConstraint focus)
public Variable[] getFocused()
public void setFocus(Variable... vars)
public boolean isFocused(Variable var)
public void focus(Variable... vars)
public void removeFromCurrentFocus(Variable... vars)
public void setCounterMoves(int counterMoves)
public java.util.HashMap<ConstraintNetwork,ConstraintNetwork> getResolvers()
public java.util.HashMap<ConstraintNetwork,ConstraintNetwork> getResolversInverseMapping()
public void setResolvers(java.util.HashMap<ConstraintNetwork,ConstraintNetwork> resolvers)
public MetaConstraint getMetaConstraint(ConstraintNetwork metaVariable)
public void registerValueChoiceFunctions()
registerValueChoiceFunctions in class MultiConstraintSolver