V
- VariableT
- ValueC
- Assignment Contextpublic abstract class ConstraintWithContext<V extends Variable<V,T>,T extends Value<V,T>,C extends AssignmentConstraintContext<V,T>> extends Constraint<V,T> implements HasAssignmentContext<V,T,C>, CanHoldContext
AssignmentConstraintContext
interface). This context is created by calling
HasAssignmentContext.createAssignmentContext(Assignment)
and accessed by
getContext(Assignment)
.AssignmentContext
iConstraintListeners, iId
sMaxSize
Constructor and Description |
---|
ConstraintWithContext() |
Modifier and Type | Method and Description |
---|---|
void |
assigned(Assignment<V,T> assignment,
long iteration,
T value)
Given value is to be assigned to its variable.
|
AssignmentContextReference<V,T,C> |
getAssignmentContextReference()
Returns an assignment context reference
|
AssignmentContext[] |
getContext()
An array of
CanHoldContext.sMaxSize assignment contexts |
C |
getContext(Assignment<V,T> assignment)
Returns an assignment context associated with this constraint.
|
void |
setAssignmentContextReference(AssignmentContextReference<V,T,C> reference)
Store an assignment context reference that was given for the class by the
Model.createReference(HasAssignmentContext) . |
void |
setModel(Model<V,T> model)
Sets the model which the constraint belongs to
|
void |
unassigned(Assignment<V,T> assignment,
long iteration,
T value)
Given value is unassigned from its variable.
|
addConstraintListener, addVariable, assignedVariables, compareTo, computeConflicts, computeConflictsNoForwardCheck, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, getName, hashCode, inConflict, isConsistent, isHard, removeConstraintListener, removeVariable, variables
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
createAssignmentContext
public ConstraintWithContext()
public void setModel(Model<V,T> model)
Constraint
public C getContext(Assignment<V,T> assignment)
HasAssignmentContext.createAssignmentContext(Assignment)
method. From that time on,
this context is kept with the assignment and automatically updated by calling the
AssignmentConstraintContext.assigned(Assignment, Value)
and AssignmentConstraintContext.unassigned(Assignment, Value)
whenever a variable of this constraint is changed.getContext
in interface HasAssignmentContext<V extends Variable<V,T>,T extends Value<V,T>,C extends AssignmentConstraintContext<V,T>>
assignment
- given assignmentpublic AssignmentContextReference<V,T,C> getAssignmentContextReference()
HasAssignmentContext
getAssignmentContextReference
in interface HasAssignmentContext<V extends Variable<V,T>,T extends Value<V,T>,C extends AssignmentConstraintContext<V,T>>
Model.createReference(HasAssignmentContext)
during initializationpublic void setAssignmentContextReference(AssignmentContextReference<V,T,C> reference)
HasAssignmentContext
Model.createReference(HasAssignmentContext)
.setAssignmentContextReference
in interface HasAssignmentContext<V extends Variable<V,T>,T extends Value<V,T>,C extends AssignmentConstraintContext<V,T>>
reference
- reference provided by the model by calling Model.createReference(HasAssignmentContext)
during initializationpublic AssignmentContext[] getContext()
CanHoldContext
CanHoldContext.sMaxSize
assignment contextsgetContext
in interface CanHoldContext
public void assigned(Assignment<V,T> assignment, long iteration, T value)
Constraint
public void unassigned(Assignment<V,T> assignment, long iteration, T value)
Constraint
unassigned
in class Constraint<V extends Variable<V,T>,T extends Value<V,T>>
assignment
- current assignmentiteration
- current iterationvalue
- unassigned value