public class Constraint extends Object
Propagator
.
It can either be posted or reifiedVariable
,
Propagator
,
PropagationEngine
Modifier and Type | Class and Description |
---|---|
static class |
Constraint.Status
Status of this constraint wrt the model
|
Modifier and Type | Field and Description |
---|---|
protected BoolVar |
boolReif
BoolVar that reifies this constraint, unique.
|
protected Propagator[] |
propagators
Propagators of the constraint (they will filter domains and eventually check solutions)
|
Constructor and Description |
---|
Constraint(String name,
Propagator... propagators)
Make a new constraint defined as a set of given propagators
|
Modifier and Type | Method and Description |
---|---|
void |
checkNewStatus(Constraint.Status aStatus)
Check if the new status is not in conflict with the current one
|
PropagatorPriority |
computeMaxPriority() |
void |
declareAs(Constraint.Status aStatus,
int idx)
For internal usage only, declare the status of this constraint in the model
and, if need be, its position in the constraint list.
|
int |
getCidxInModel() |
String |
getName() |
Constraint |
getOpposite()
Get the opposite constraint of this constraint.
|
Propagator |
getPropagator(int i) |
Propagator[] |
getPropagators()
Return an array which contains the propagators declared in
this . |
Constraint.Status |
getStatus() |
boolean |
isReified() |
ESat |
isSatisfied()
Test if this
Constraint object is satisfied,
regarding its Propagators and its Variable current domains. |
protected Constraint |
makeOpposite()
Make the opposite constraint of this.
|
static Constraint |
merge(String name,
Constraint... toMerge)
Creates a new constraint with all propagators of toMerge
|
void |
post()
Posts the constraint to its model so that the constraint must be satisfied.
|
BoolVar |
reify()
Get/make the boolean variable indicating whether the constraint is satisfied or not
This should not be posted.
|
void |
reifyWith(BoolVar bool)
Reifies the constraint with a boolean variable
If the reified boolean variable already exists, an additional (equality) constraint is automatically posted.
|
void |
setName(String newName)
Changes the name of
this constraint |
protected void |
setOpposite(Constraint opp) |
String |
toString() |
protected final Propagator[] propagators
protected BoolVar boolReif
public Constraint(String name, Propagator... propagators)
name
- name of the constraintpropagators
- set of propagators defining the constraintpublic Propagator[] getPropagators()
this
.Propagator
.public Propagator getPropagator(int i)
public ESat isSatisfied()
Constraint
object is satisfied,
regarding its Propagators
and its Variable
current domains.
This method is called on each solution as a checker when assertions are enabled (-ea in VM parameters)
It is also called for constraint reification (to state whether or not a constraint is satisfied)
The method calls entailment checks of this
propagatorsESat.FALSE
if the constraint cannot be satisfied (from domain consideration),
ESat.TRUE
if whatever future decisions are, the constraint will be satisfied for sure (without propagating domain modifications)
ESat.UNDIFINED
otherwise (more decisions/filtering must be made before concluding about constraint satisfaction)public final boolean isReified()
public void reifyWith(BoolVar bool)
bool
- the variable to reify withpublic final BoolVar reify()
public final void post()
public final void declareAs(Constraint.Status aStatus, int idx) throws SolverException
aStatus
- status of this constraint in the modelidx
- position of this constraint in the constraint list.SolverException
- if the constraint a incoherent status is declaredpublic final void checkNewStatus(Constraint.Status aStatus) throws SolverException
aStatus
- new status of the constraintSolverException
- if the constraint a incoherent status is declaredpublic final Constraint.Status getStatus()
Constraint.Status
of this constraintpublic int getCidxInModel()
public Constraint getOpposite()
protected void setOpposite(Constraint opp)
protected Constraint makeOpposite()
public void setName(String newName)
this
constraintnewName
- the name of the constraintpublic String getName()
this
constraintpublic PropagatorPriority computeMaxPriority()
public static Constraint merge(String name, Constraint... toMerge)
name
- name of the new constrainttoMerge
- a set of constraints to merge in thisCopyright © 2018. All rights reserved.