choco.bool
Class ConstantConstraint

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.AbstractConstraint
          extended by choco.bool.ConstantConstraint
All Implemented Interfaces:
Constraint, Entity, VarEventListener, Propagator, java.lang.Cloneable, java.util.EventListener

public class ConstantConstraint
extends AbstractConstraint


Field Summary
 
Fields inherited from class choco.AbstractConstraint
active, constAwakeEvent, hook, priority
 
Fields inherited from class choco.AbstractEntity
problem
 
Constructor Summary
ConstantConstraint(boolean value)
           
 
Method Summary
 int assignIndices(AbstractCompositeConstraint root, int i, boolean dynamicAddition)
          performs the global numbering (wrt root) of the variables contained in the subtree this, starting from i
 java.lang.Object clone()
          returns a copy of the constraint.
 int getConstraintIdx(int idx)
          Network management: Among all listeners linked to the idx-th variable of c, find the index of constraint c.
 int getNbVars()
          Network management: Get the number of variables involved in the constraint.
 Var getVar(int i)
          Network management: Accessing the ith variable of a constraint.
 boolean isCompletelyInstantiated()
          Utility: Testing if all variables involved in the constraint are instantiated.
 boolean isConsistent()
          tests if the constraint is consistent with respect to the current state of domains
 boolean isEquivalentTo(Constraint compareTo)
          tests the equivalence (logical equality of the conditions) between two constraints.
 boolean isSatisfied()
          Semantic: Testing if the constraint is satisfied.
 void propagate()
          Propagation: Propagating the constraint until local consistency is reached.
 void setConstraintIndex(int i, int idx)
          Network management: Storing that among all listeners linked to the i-th variable of c, this (the current constraint) is found at index idx.
 void setVar(int i, Var v)
          Network management: Setting (or overwriting) the ith variable of a constraint.
 
Methods inherited from class choco.AbstractConstraint
addListener, awake, awakeOnVar, connectVar, constAwake, delete, fail, getEvent, getPlugIn, getPriority, getProblem, getVarIdxInOpposite, isActive, isEntailed, opposite, setActive, setEntailed, setPassive, setPlugIn, substituteVar
 
Methods inherited from class choco.AbstractEntity
pretty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface choco.Entity
pretty
 

Constructor Detail

ConstantConstraint

public ConstantConstraint(boolean value)
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Description copied from interface: Constraint
returns a copy of the constraint. This copy is a new object, may be a recursive copy in case of composite constraints. The original and the copy share the same variables & plugins

Specified by:
clone in interface Constraint
Overrides:
clone in class AbstractConstraint
Returns:
Throws:
java.lang.CloneNotSupportedException

getNbVars

public int getNbVars()
Description copied from interface: Constraint
Network management: Get the number of variables involved in the constraint.


getVar

public Var getVar(int i)
Description copied from interface: Constraint
Network management: Accessing the ith variable of a constraint.

Parameters:
i - index of the variable in the constraint

setVar

public void setVar(int i,
                   Var v)
Description copied from interface: Constraint
Network management: Setting (or overwriting) the ith variable of a constraint.

Parameters:
i - index of the variable in the constraint
v - the variable (may be an IntDomainVar, SetVar, RealVar, ...

isCompletelyInstantiated

public boolean isCompletelyInstantiated()
Description copied from interface: Propagator
Utility: Testing if all variables involved in the constraint are instantiated.


isSatisfied

public boolean isSatisfied()
Description copied from interface: Constraint
Semantic: Testing if the constraint is satisfied. Note that all variables involved in the constraint must be instantiated when this method is called.


propagate

public void propagate()
               throws ContradictionException
Description copied from interface: Propagator
Propagation: Propagating the constraint until local consistency is reached.

Throws:
ContradictionException

isConsistent

public boolean isConsistent()
Description copied from interface: Propagator
tests if the constraint is consistent with respect to the current state of domains


assignIndices

public int assignIndices(AbstractCompositeConstraint root,
                         int i,
                         boolean dynamicAddition)
Description copied from interface: Propagator
performs the global numbering (wrt root) of the variables contained in the subtree this, starting from i

Parameters:
root - the overall root constraint, for which the variables are numbered
i - the index that will assigned to the first variable in the subtree this (originally 0)
dynamicAddition - whether the addition is undone automatically on backtracking
Returns:
the index of the last variable in the subtree

setConstraintIndex

public void setConstraintIndex(int i,
                               int idx)
Description copied from interface: Constraint
Network management: Storing that among all listeners linked to the i-th variable of c, this (the current constraint) is found at index idx.

Parameters:
i - index of the variable in the constraint
idx - index of the constraint in the among all listeners linked to that variable

getConstraintIdx

public int getConstraintIdx(int idx)
Description copied from interface: Constraint
Network management: Among all listeners linked to the idx-th variable of c, find the index of constraint c.

Parameters:
idx - index of the variable in the constraint

isEquivalentTo

public final boolean isEquivalentTo(Constraint compareTo)
Description copied from interface: Constraint
tests the equivalence (logical equality of the conditions) between two constraints. In particular whenever c1.equals(c2), then c1.isEquivalent(c2).

Specified by:
isEquivalentTo in interface Constraint
Overrides:
isEquivalentTo in class AbstractConstraint
Parameters:
compareTo - the constraint to be compared to
Returns:
true if and only if the constraints model the same logical condition.