choco
Interface Var

All Superinterfaces:
Entity
All Known Subinterfaces:
ExplainedIntVar, ExplainedVar, IntDomainVar, IntVar, PalmRealVar, PalmVar, RealVar, SetVar
All Known Implementing Classes:
AbstractVar, IntDomainVarImpl, JumpIntVar, PalmIntVar, PalmRealVarImpl, RealVarImpl, SetVarImpl

public interface Var
extends Entity

Interface for all implementations of domain variables.


Method Summary
 int addConstraint(Constraint c, int varIdx, boolean dynamicAddition)
          Adds a new listener for the variable, that is a constraint which should be informed as soon as the variable domain is modified.
 void fail()
          a constraint may fail during propagation, raising a contradiction
 Constraint getConstraint(int i)
          Returns the ith constraint.
 java.util.Iterator getConstraintsIterator()
          This methods should be used if one want to access the different constraints currently posted on this variable.
 PartiallyStoredVector getConstraintVector()
          access the data structure storing constraints involving a given variable
 VarEvent getEvent()
          returns the object used by the propagation engine to model a propagation event associated to the variable (an update to its domain)
 PartiallyStoredIntVector getIndexVector()
          access the data structure storing indices associated to constraints involving a given variable
 int getNbConstraints()
          Returns the number of listeners involving the variable.
 int getVarIndex(int constraintIndex)
          returns the index of the variable in it i-th constraint
 boolean isInstantiated()
          Public user API: Domains : testing whether a variable is instantiated or not.
 
Methods inherited from interface choco.Entity
getProblem, pretty
 

Method Detail

getNbConstraints

int getNbConstraints()
Returns the number of listeners involving the variable.


fail

void fail()
          throws ContradictionException
a constraint may fail during propagation, raising a contradiction

Throws:
ContradictionException

getConstraint

Constraint getConstraint(int i)
Returns the ith constraint. i should be more than or equal to 0, and less or equal to the number of constraint minus 1.


getVarIndex

int getVarIndex(int constraintIndex)
returns the index of the variable in it i-th constraint

Parameters:
constraintIndex - the index of the constraint (among all constraints linked to the variable)
Returns:
the index of the variable (0 if this is the first variable of that constraint)

getConstraintVector

PartiallyStoredVector getConstraintVector()
access the data structure storing constraints involving a given variable

Returns:

getIndexVector

PartiallyStoredIntVector getIndexVector()
access the data structure storing indices associated to constraints involving a given variable

Returns:

isInstantiated

boolean isInstantiated()
Public user API: Domains : testing whether a variable is instantiated or not.


addConstraint

int addConstraint(Constraint c,
                  int varIdx,
                  boolean dynamicAddition)
Adds a new listener for the variable, that is a constraint which should be informed as soon as the variable domain is modified. The addition can be dynamic (undone upon backtracking) or not


getEvent

VarEvent getEvent()
returns the object used by the propagation engine to model a propagation event associated to the variable (an update to its domain)

Returns:
the propagation event

getConstraintsIterator

java.util.Iterator getConstraintsIterator()
This methods should be used if one want to access the different constraints currently posted on this variable. Indeed, since indices are not always consecutive, it is the only simple way to achieve this.

Returns:
an iterator over all constraints involving this variable