choco.bool
Class AbstractLargeCompositeConstraint

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.AbstractConstraint
          extended by choco.bool.AbstractCompositeConstraint
              extended by choco.bool.AbstractLargeCompositeConstraint
All Implemented Interfaces:
CompositeConstraint, Constraint, Entity, IntVarEventListener, VarEventListener, Propagator, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
AbstractLargeBoolConstraint

public abstract class AbstractLargeCompositeConstraint
extends AbstractCompositeConstraint


Field Summary
protected  int[] additionalIndices
          constraint indices (for the constraint network management) corresponding to the additional variables
protected  IntDomainVarImpl[] additionalVars
          variables in the composition that are not in the subconstraints
protected  AbstractConstraint[] constraints
          all subconstraints from the composition
protected  int nbConstraints
          the number of sub-constraints
protected  int[] offsets
          offsets[i] is the total number of variables in all previous terms constraints[0]...constraints[i-1] Therefore it is the offset in the variable indexing of constraints[i]
 
Fields inherited from class choco.AbstractConstraint
active, constAwakeEvent, hook, priority
 
Fields inherited from class choco.AbstractEntity
problem
 
Constructor Summary
AbstractLargeCompositeConstraint(Constraint[] subConstraints)
           
AbstractLargeCompositeConstraint(Constraint[] subConstraints, IntDomainVar[] moreVars)
           
 
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 i)
          Network management: Among all listeners linked to the idx-th variable of c, find the index of constraint c.
 IntDomainVar getIntVar(int varIdx)
           
protected  int getLocalVarIndex(int varIdx, int constIdx)
           
 int getNbSubConstraints()
          returns the number of sub-constraints that the composite constraint is made of
 int getNbVars()
          Network management: Get the number of variables involved in the constraint.
 int getNbVarsFromSubConst()
           
 Constraint getSubConstraint(int constIdx)
          accessor to the sub-constraints from which the composite constraint is made of
 int getSubConstraintIdx(int varIdx)
          return the index of the subconstraint where the i-th variable is referenced
 Var getVar(int i)
          Network management: Accessing the ith variable of a constraint.
 int getVarIdxInOpposite(int i)
          computes the index of the i-th variable in the counter-opposite of the constraint
 boolean isCompletelyInstantiated()
          Utility: Testing if all variables involved in the constraint are instantiated.
 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.bool.AbstractCompositeConstraint
addListener, awakeOnBounds, awakeOnRemovals, getGlobalVarIndex
 
Methods inherited from class choco.AbstractConstraint
awake, awakeOnVar, connectVar, constAwake, delete, fail, getEvent, getPlugIn, getPriority, getProblem, 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.Constraint
isEquivalentTo, isSatisfied, opposite
 
Methods inherited from interface choco.Entity
getProblem, pretty
 
Methods inherited from interface choco.integer.var.IntVarEventListener
awakeOnInf, awakeOnInst, awakeOnRem, awakeOnSup
 
Methods inherited from interface choco.prop.VarEventListener
awakeOnVar, isActive, setActive, setPassive
 
Methods inherited from interface choco.Propagator
isConsistent, propagate
 

Field Detail

constraints

protected AbstractConstraint[] constraints
all subconstraints from the composition


offsets

protected int[] offsets
offsets[i] is the total number of variables in all previous terms constraints[0]...constraints[i-1] Therefore it is the offset in the variable indexing of constraints[i]


nbConstraints

protected int nbConstraints
the number of sub-constraints


additionalVars

protected IntDomainVarImpl[] additionalVars
variables in the composition that are not in the subconstraints


additionalIndices

protected int[] additionalIndices
constraint indices (for the constraint network management) corresponding to the additional variables

Constructor Detail

AbstractLargeCompositeConstraint

public AbstractLargeCompositeConstraint(Constraint[] subConstraints)

AbstractLargeCompositeConstraint

public AbstractLargeCompositeConstraint(Constraint[] subConstraints,
                                        IntDomainVar[] moreVars)
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

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

getNbVarsFromSubConst

public int getNbVarsFromSubConst()

getSubConstraintIdx

public int getSubConstraintIdx(int varIdx)
Description copied from interface: CompositeConstraint
return the index of the subconstraint where the i-th variable is referenced

Parameters:
varIdx - the overall index of the variable (among all variables of the combination
Returns:
the index of the subconstraint involving the variable or -1 if none can be found (which would be a definite bug !)

getLocalVarIndex

protected int getLocalVarIndex(int varIdx,
                               int constIdx)

getVarIdxInOpposite

public int getVarIdxInOpposite(int i)
Description copied from interface: Constraint
computes the index of the i-th variable in the counter-opposite of the constraint

Specified by:
getVarIdxInOpposite in interface Constraint
Overrides:
getVarIdxInOpposite in class AbstractConstraint
Parameters:
i - the index of the variable in the current constraint (this)
Returns:
the index of the variable in the opposite constraint (this.opposite())

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 i)
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:
i - index of the variable in the constraint

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, ...

getIntVar

public IntDomainVar getIntVar(int varIdx)

isCompletelyInstantiated

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


getSubConstraint

public Constraint getSubConstraint(int constIdx)
Description copied from interface: CompositeConstraint
accessor to the sub-constraints from which the composite constraint is made of

Parameters:
constIdx - the index of the constraint
Returns:
the appropriate subConstraint

getNbSubConstraints

public int getNbSubConstraints()
Description copied from interface: CompositeConstraint
returns the number of sub-constraints that the composite constraint is made of