choco.palm.search
Class NogoodConstraint

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.palm.integer.AbstractPalmLargeIntConstraint
                      extended by choco.palm.search.NogoodConstraint
All Implemented Interfaces:
Constraint, Entity, IntConstraint, IntVarEventListener, PalmIntVarListener, PalmConstraint, PalmVarListener, VarEventListener, Propagator, java.lang.Cloneable, java.util.EventListener

public class NogoodConstraint
extends AbstractPalmLargeIntConstraint


Field Summary
protected  java.util.LinkedList nogoods
          The list of nogood.
protected  java.util.LinkedList permanentMemory
           
 
Fields inherited from class choco.integer.constraints.AbstractLargeIntConstraint
cIndices, cste, 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
NogoodConstraint(IntDomainVar[] vs)
           
 
Method Summary
 void addFirst(PalmExplanation exp, java.util.LinkedList mem)
           
 void addNogoodFirst(ConstraintCollection exp)
           
 void addPermanentNogood(ConstraintCollection exp)
           
 void addPermanentNogood(SymbolicDecision[] exp)
           
 void awakeOnBounds(int varIndex)
           
 void awakeOnRemovals(int idx, IntIterator deltaDomain)
          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 index)
          Handles an inf bound restoration on the constraint idx
 void awakeOnRestoreSup(int index)
          Handles a sup bound restoration on the constraint idx
 void awakeOnRestoreVal(int idx, int i)
          Handles a val restoration on the constraint idx
 boolean checkAddition(SymbolicDecision[] cut1, java.util.LinkedList memo)
           
 int checkCut(SymbolicDecision[] cut1, SymbolicDecision[] cut2)
          check whether cut1 contains cut2 or cut2 contains cut1
 void filter()
           
 void filterLastDecision(SymbolicDecision[] nogood, int numDec)
           
 void filterMem(java.util.LinkedList memoryToFilter)
           
 java.util.LinkedList getMemory()
           
 int getPermanentMemorySize()
           
 boolean isSatisfied()
          Semantic: Testing if the constraint is satisfied.
 void propagate()
          Propagates the constraint awake events.
 void removeLastNogood()
           
 void removeNogood(ConstraintCollection exp)
           
 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.palm.integer.AbstractPalmLargeIntConstraint
awakeOnInst, awakeOnRestoreVal, clone, getIntVar, takeIntoAccountStatusChange, updateDataStructuresOnConstraint, updateDataStructuresOnRestoreConstraint
 
Methods inherited from class choco.integer.constraints.AbstractLargeIntConstraint
assignIndices, getConstraintIdx, getNbVars, getVar, isCompletelyInstantiated, setConstraintIndex, setVar
 
Methods inherited from class choco.integer.constraints.AbstractIntConstraint
awakeOnInf, awakeOnRem, awakeOnSup, getSelfIndex, isConsistent
 
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.palm.PalmVarListener
getConstraintIdx, setConstraintIndex
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.integer.var.IntVarEventListener
awakeOnInf, awakeOnRem, awakeOnSup, getConstraintIdx, setConstraintIndex
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.Propagator
assignIndices, awake, awakeOnVar, constAwake, delete, getEvent, getPlugIn, getPriority, isCompletelyInstantiated, isConsistent, isEntailed
 
Methods inherited from interface choco.prop.VarEventListener
addListener, isActive, setActive, setPassive
 
Methods inherited from interface choco.Constraint
getConstraintIdx, getNbVars, getVar, getVarIdxInOpposite, isEquivalentTo, 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
 

Field Detail

nogoods

protected java.util.LinkedList nogoods
The list of nogood. A nogood is stored as a set of decision constraints.


permanentMemory

protected java.util.LinkedList permanentMemory
Constructor Detail

NogoodConstraint

public NogoodConstraint(IntDomainVar[] vs)
Method Detail

getMemory

public java.util.LinkedList getMemory()

getPermanentMemorySize

public int getPermanentMemorySize()

addPermanentNogood

public void addPermanentNogood(ConstraintCollection exp)

addPermanentNogood

public void addPermanentNogood(SymbolicDecision[] exp)

addNogoodFirst

public void addNogoodFirst(ConstraintCollection exp)

addFirst

public void addFirst(PalmExplanation exp,
                     java.util.LinkedList mem)

removeNogood

public void removeNogood(ConstraintCollection exp)

removeLastNogood

public void removeLastNogood()

propagate

public void propagate()
               throws ContradictionException
Description copied from class: AbstractLargeIntConstraint
Propagates the constraint awake events.

Specified by:
propagate in interface Propagator
Overrides:
propagate in class AbstractLargeIntConstraint
Throws:
ContradictionException

filter

public void filter()
            throws ContradictionException
Throws:
ContradictionException

filterMem

public void filterMem(java.util.LinkedList memoryToFilter)
               throws ContradictionException
Throws:
ContradictionException

filterLastDecision

public void filterLastDecision(SymbolicDecision[] nogood,
                               int numDec)
                        throws ContradictionException
Throws:
ContradictionException

awakeOnRestoreVal

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

Parameters:
idx - Variable involved.
Throws:
ContradictionException

awakeOnRestoreSup

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

Specified by:
awakeOnRestoreSup in interface PalmIntVarListener
Overrides:
awakeOnRestoreSup in class AbstractPalmLargeIntConstraint
Parameters:
index - Variable involved.
Throws:
ContradictionException

awakeOnRestoreInf

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

Specified by:
awakeOnRestoreInf in interface PalmIntVarListener
Overrides:
awakeOnRestoreInf in class AbstractPalmLargeIntConstraint
Parameters:
index - Variable involved.
Throws:
ContradictionException

awakeOnRemovals

public void awakeOnRemovals(int idx,
                            IntIterator deltaDomain)
                     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

awakeOnBounds

public void awakeOnBounds(int varIndex)
                   throws ContradictionException
Specified by:
awakeOnBounds in interface IntConstraint
Overrides:
awakeOnBounds in class AbstractIntConstraint
Throws:
ContradictionException

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.


whyIsTrue

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

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.

Returns:
A set of constraint justifying that the constraint is not satisfied.

checkAddition

public boolean checkAddition(SymbolicDecision[] cut1,
                             java.util.LinkedList memo)

checkCut

public int checkCut(SymbolicDecision[] cut1,
                    SymbolicDecision[] cut2)
check whether cut1 contains cut2 or cut2 contains cut1

Returns:
1 if cut1 contains cut2 2 if cut2 contains cut1 0 if cut1 is equal to cut2 -1 otherwise