choco.real.constraint
Class AbstractLargeRealConstraint

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.AbstractConstraint
          extended by choco.real.constraint.AbstractLargeRealConstraint
All Implemented Interfaces:
Constraint, Entity, VarEventListener, Propagator, RealConstraint, RealListener, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
Equation

public abstract class AbstractLargeRealConstraint
extends AbstractConstraint
implements RealConstraint

A real constraint with an undetermined number of variables.


Field Summary
protected  int[] cIndices
          Indices associated with this contraint in each variable.
protected  RealVar[] vars
          The variables involved in the constraint.
 
Fields inherited from class choco.AbstractConstraint
active, constAwakeEvent, hook, priority
 
Fields inherited from class choco.AbstractEntity
problem
 
Constructor Summary
AbstractLargeRealConstraint(RealVar[] vars)
          Builds such a constraint with the specified variables.
 
Method Summary
 int assignIndices(AbstractCompositeConstraint root, int i, boolean dynamicAddition)
          Assigns indices according to a variable for boolean meta-constraints.
 java.lang.Object clone()
          Makes a copy of this constraint.
 int getConstraintIdx(int i)
          Returns this constraint index according to the variable i.
 int getNbVars()
          Returns the number of variables.
 RealVar getRealVar(int i)
          Returns the variable with the index i.
 int getRealVarNb()
          Returns the number of real variables.
 int getSelfIndex()
          Returns the index associated with this constraint by the problem.
 Var getVar(int i)
          Returns the variable with the index i.
 boolean isCompletelyInstantiated()
          Checks if the constrait is completely instantiated.
 void setConstraintIndex(int i, int idx)
          Sets this constraint index according to the variable i.
 void setVar(int i, Var v)
          Sets a variable involved by the constraint.
 
Methods inherited from class choco.AbstractConstraint
addListener, awake, awakeOnVar, connectVar, constAwake, delete, fail, getEvent, getPlugIn, getPriority, getProblem, getVarIdxInOpposite, isActive, isEntailed, isEquivalentTo, 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.Propagator
awake, awakeOnVar, constAwake, delete, getEvent, getPlugIn, getPriority, isConsistent, isEntailed, propagate
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.real.constraint.RealListener
awakeOnInf, awakeOnSup
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 

Field Detail

vars

protected RealVar[] vars
The variables involved in the constraint.


cIndices

protected int[] cIndices
Indices associated with this contraint in each variable.

Constructor Detail

AbstractLargeRealConstraint

public AbstractLargeRealConstraint(RealVar[] vars)
Builds such a constraint with the specified variables.

Parameters:
vars - the variables involved by this constraint
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Makes a copy of this constraint.

Specified by:
clone in interface Constraint
Overrides:
clone in class AbstractConstraint
Returns:
a copy of this constraint
Throws:
java.lang.CloneNotSupportedException - thrown if this constraint cannot be cloned.

setConstraintIndex

public void setConstraintIndex(int i,
                               int idx)
Sets this constraint index according to the variable i.

Specified by:
setConstraintIndex in interface Constraint
Specified by:
setConstraintIndex in interface RealListener
Parameters:
i - the variable index
idx - this constraint index according to the variable i

getConstraintIdx

public int getConstraintIdx(int i)
Returns this constraint index according to the variable i.

Specified by:
getConstraintIdx in interface Constraint
Specified by:
getConstraintIdx in interface RealListener
Parameters:
i - the variable index
Returns:
this constraint index

getNbVars

public int getNbVars()
Returns the number of variables.

Specified by:
getNbVars in interface Constraint
Returns:
the number of variables involved by this constraint

getVar

public Var getVar(int i)
Returns the variable with the index i.

Specified by:
getVar in interface Constraint
Parameters:
i - the requested index
Returns:
the required variable

setVar

public void setVar(int i,
                   Var v)
Sets a variable involved by the constraint.

Specified by:
setVar in interface Constraint
Parameters:
i - the index to set
v - the variable

getRealVar

public RealVar getRealVar(int i)
Returns the variable with the index i.

Specified by:
getRealVar in interface RealConstraint
Parameters:
i - the requested index
Returns:
the required variable

getRealVarNb

public int getRealVarNb()
Returns the number of real variables. In this case it equals the number of variables since there are only real variables.

Specified by:
getRealVarNb in interface RealConstraint
Returns:
the number of real variables

assignIndices

public int assignIndices(AbstractCompositeConstraint root,
                         int i,
                         boolean dynamicAddition)
Assigns indices according to a variable for boolean meta-constraints.

Specified by:
assignIndices in interface Propagator
Parameters:
root - the over all constraint containing this one
i - the beginning index for the global boolean constraint
dynamicAddition - states if the addition is definitive or not
Returns:
the index usable for following constraints in the global constraint (that i plus the number of added variables)

isCompletelyInstantiated

public boolean isCompletelyInstantiated()
Checks if the constrait is completely instantiated.

Specified by:
isCompletelyInstantiated in interface Propagator
Returns:
true if all variables are instantiated

getSelfIndex

public int getSelfIndex()
Returns the index associated with this constraint by the problem.

Returns:
this constraint index according to the problem