choco.palm.integer.constraints
Class PalmIntLinComb

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.AbstractConstraint
          extended by choco.integer.constraints.AbstractIntConstraint
              extended by choco.integer.constraints.AbstractLargeIntConstraint
                  extended by choco.integer.constraints.IntLinComb
                      extended by choco.palm.integer.constraints.PalmIntLinComb
All Implemented Interfaces:
Constraint, Entity, IntConstraint, IntVarEventListener, PalmIntVarListener, PalmConstraint, PalmVarListener, VarEventListener, Propagator, java.lang.Cloneable, java.util.EventListener

public class PalmIntLinComb
extends IntLinComb
implements PalmIntVarListener, PalmConstraint

Created by IntelliJ IDEA. User: rochart Date: Jan 13, 2004 Time: 7:58:45 AM To change this template use Options | File Templates.


Field Summary
 
Fields inherited from class choco.integer.constraints.IntLinComb
coeffs, cste, EQ, GEQ, nbPosVars, NEQ, op
 
Fields inherited from class choco.integer.constraints.AbstractLargeIntConstraint
cIndices, vars
 
Fields inherited from class choco.integer.constraints.AbstractIntConstraint
logger
 
Fields inherited from class choco.AbstractConstraint
active, constAwakeEvent, hook, priority
 
Fields inherited from class choco.AbstractEntity
problem
 
Constructor Summary
PalmIntLinComb(IntDomainVar[] vars, int[] coeffs, int nbPositive, int c, int linOperator)
           
 
Method Summary
 void awakeOnRem(int idx, int x)
          Propagation whenever a value is removed from the variable domain.
 void awakeOnRemovals(int idx, IntIterator it)
          The default implementation of propagation when a variable has been modified consists in iterating all values that have been removed (the delta domain) and propagate them one after another, incrementally.
 void awakeOnRestoreInf(int idx)
          Handles an inf bound restoration on the constraint idx
 void awakeOnRestoreSup(int idx)
          Handles a sup bound restoration on the constraint idx
 void awakeOnRestoreVal(int idx, int val)
          Handles a val restoration on the constraint idx
 void awakeOnRestoreVal(int idx, IntIterator it)
          Handles a val restoration on the constraint idx
 void awakeOnVar(int idx)
          Generic propagation when a variable is modified.
protected  boolean propagateNewLowerBound(int mylb)
          Propagates the constraint sigma(ai Xi) + c <= 0 where mylb = sigma(ai inf(Xi)) + c.
protected  boolean propagateNewUpperBound(int myub)
          Propagates the constraint sigma(ai Xi) + c <= 0 where myub = sigma(ai sup(Xi)) + c.
 void takeIntoAccountStatusChange(int index)
          Informs constraints that one of their children has a modified status (due to value restoration).
 void updateDataStructuresOnConstraint(int idx, int select, int newValue, int oldValue)
          Method called when one of the variables is modified.
 void updateDataStructuresOnRestoreConstraint(int idx, int select, int newValue, int oldValue)
          Method called when one of the variables has a restored value.
 java.util.Set whyIsFalse()
          When all variables are instantiated, explains why the wonstraint is false.
 java.util.Set whyIsTrue()
          When all variables are instantiated, explains why the wonstraint is true.
 
Methods inherited from class choco.integer.constraints.IntLinComb
awakeOnInf, awakeOnInst, awakeOnSup, clone, computeLowerBound, computeUpperBound, filter, filterOnImprovedLowerBound, filterOnImprovedUpperBound, hasConsistentLowerBound, hasConsistentUpperBound, init, isConsistent, isEntailed, isEquivalentTo, isSatisfied, opposite, pretty, propagate
 
Methods inherited from class choco.integer.constraints.AbstractLargeIntConstraint
assignIndices, getConstraintIdx, getIntVar, getNbVars, getVar, isCompletelyInstantiated, setConstraintIndex, setVar
 
Methods inherited from class choco.integer.constraints.AbstractIntConstraint
awakeOnBounds, getSelfIndex
 
Methods inherited from class choco.AbstractConstraint
addListener, awake, connectVar, constAwake, delete, fail, getEvent, getPlugIn, getPriority, getProblem, getVarIdxInOpposite, isActive, setActive, setEntailed, setPassive, setPlugIn, substituteVar
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface choco.palm.PalmVarListener
getConstraintIdx, setConstraintIndex
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.integer.var.IntVarEventListener
awakeOnInf, awakeOnInst, awakeOnSup, getConstraintIdx, setConstraintIndex
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.Propagator
assignIndices, awake, constAwake, delete, getEvent, getPlugIn, getPriority, isCompletelyInstantiated, isConsistent, isEntailed, propagate
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.Constraint
clone, getConstraintIdx, getNbVars, getVar, getVarIdxInOpposite, isEquivalentTo, isSatisfied, opposite, setConstraintIndex, setVar
 
Methods inherited from interface choco.Entity
getProblem, pretty
 
Methods inherited from interface choco.palm.PalmVarListener
getConstraintIdx, setConstraintIndex
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 

Constructor Detail

PalmIntLinComb

public PalmIntLinComb(IntDomainVar[] vars,
                      int[] coeffs,
                      int nbPositive,
                      int c,
                      int linOperator)
Method Detail

awakeOnRem

public void awakeOnRem(int idx,
                       int x)
                throws ContradictionException
Description copied from class: IntLinComb
Propagation whenever a value is removed from the variable domain.

Specified by:
awakeOnRem in interface IntVarEventListener
Overrides:
awakeOnRem in class IntLinComb
Parameters:
idx - the index of the modified variable
x - the removed value
Throws:
ContradictionException - if a domain empties or a contradiction is infered

awakeOnVar

public void awakeOnVar(int idx)
                throws ContradictionException
Description copied from class: IntLinComb
Generic propagation when a variable is modified. Here no propagation.

Specified by:
awakeOnVar in interface VarEventListener
Specified by:
awakeOnVar in interface Propagator
Overrides:
awakeOnVar in class IntLinComb
Parameters:
idx - the index of the modified variable
Throws:
ContradictionException - if a domain empties or a contradiction is infered

awakeOnRemovals

public void awakeOnRemovals(int idx,
                            IntIterator it)
                     throws ContradictionException
Description copied from class: AbstractIntConstraint
The default implementation of propagation when a variable has been modified consists in iterating all values that have been removed (the delta domain) and propagate them one after another, incrementally.

Specified by:
awakeOnRemovals in interface IntConstraint
Overrides:
awakeOnRemovals in class AbstractIntConstraint
Throws:
ContradictionException

awakeOnRestoreInf

public void awakeOnRestoreInf(int idx)
                       throws ContradictionException
Description copied from interface: PalmIntVarListener
Handles an inf bound restoration on the constraint idx

Specified by:
awakeOnRestoreInf in interface PalmIntVarListener
Parameters:
idx - Variable involved.
Throws:
ContradictionException

awakeOnRestoreSup

public void awakeOnRestoreSup(int idx)
                       throws ContradictionException
Description copied from interface: PalmIntVarListener
Handles a sup bound restoration on the constraint idx

Specified by:
awakeOnRestoreSup in interface PalmIntVarListener
Parameters:
idx - Variable involved.
Throws:
ContradictionException

awakeOnRestoreVal

public void awakeOnRestoreVal(int idx,
                              int val)
                       throws ContradictionException
Description copied from interface: PalmIntVarListener
Handles a val restoration on the constraint idx

Specified by:
awakeOnRestoreVal in interface PalmIntVarListener
Parameters:
idx - Variable involved.
Throws:
ContradictionException

awakeOnRestoreVal

public void awakeOnRestoreVal(int idx,
                              IntIterator it)
                       throws ContradictionException
Description copied from interface: PalmIntVarListener
Handles a val restoration on the constraint idx

Specified by:
awakeOnRestoreVal in interface PalmIntVarListener
Parameters:
idx - Variable involved.
Throws:
ContradictionException

whyIsTrue

public java.util.Set whyIsTrue()
Description copied from interface: PalmIntVarListener
When all variables are instantiated, explains why the wonstraint is true.

Specified by:
whyIsTrue in interface PalmIntVarListener
Returns:
A set of constraint justifying that the constraint is satisfied.

whyIsFalse

public java.util.Set whyIsFalse()
Description copied from interface: PalmIntVarListener
When all variables are instantiated, explains why the wonstraint is false.

Specified by:
whyIsFalse in interface PalmIntVarListener
Returns:
A set of constraint justifying that the constraint is not satisfied.

updateDataStructuresOnConstraint

public void updateDataStructuresOnConstraint(int idx,
                                             int select,
                                             int newValue,
                                             int oldValue)
Description copied from interface: PalmVarListener
Method called when one of the variables is modified.

Specified by:
updateDataStructuresOnConstraint in interface PalmVarListener
Parameters:
idx - Index of the variable.
select - Type of modification (PalmIntVar.INF, PalmIntVar.SUP, PalmIntVar.VAL).
newValue - New value (or modified value).
oldValue - Old value (or 0 if this a value removal).

updateDataStructuresOnRestoreConstraint

public void updateDataStructuresOnRestoreConstraint(int idx,
                                                    int select,
                                                    int newValue,
                                                    int oldValue)
Description copied from interface: PalmVarListener
Method called when one of the variables has a restored value.

Specified by:
updateDataStructuresOnRestoreConstraint in interface PalmVarListener
Parameters:
idx - Index of the variable.
select - Type of modification.
newValue - New value (or modified value).
oldValue - Old value (or 0 if this a value removal).

takeIntoAccountStatusChange

public void takeIntoAccountStatusChange(int index)
Description copied from interface: PalmConstraint
Informs constraints that one of their children has a modified status (due to value restoration).

Specified by:
takeIntoAccountStatusChange in interface PalmConstraint

propagateNewLowerBound

protected boolean propagateNewLowerBound(int mylb)
                                  throws ContradictionException
Description copied from class: IntLinComb
Propagates the constraint sigma(ai Xi) + c <= 0 where mylb = sigma(ai inf(Xi)) + c. Note: this does not reach saturation (fix point), but returns a boolean indicating whether it infered new information or not.

Overrides:
propagateNewLowerBound in class IntLinComb
Parameters:
mylb - the computed lower bound
Returns:
true if filtering has been infered
Throws:
ContradictionException - if a domain empties or a contradiction is infered

propagateNewUpperBound

protected boolean propagateNewUpperBound(int myub)
                                  throws ContradictionException
Description copied from class: IntLinComb
Propagates the constraint sigma(ai Xi) + c <= 0 where myub = sigma(ai sup(Xi)) + c. Note: this does not reach saturation (fix point), but returns a boolean indicating whether it infered new information or not.

Overrides:
propagateNewUpperBound in class IntLinComb
Parameters:
myub - the computed upper bound
Returns:
true if filtering has been infered
Throws:
ContradictionException - if a domain empties or a contradiction is infered