choco.palm.search
Class AbstractDecision

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.palm.search.AbstractDecision
All Implemented Interfaces:
Constraint, Entity, DecisionConstraint, PalmConstraint, PalmVarListener, SymbolicDecision, VarEventListener, Propagator, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
Assignment

public abstract class AbstractDecision
extends AbstractEntity
implements DecisionConstraint

A class representing a decision as a constraint (An adapter of decision constraint). It is useful to represent decision in a uniform way when the search algorithm performs assignments instead of posting constraints (As done by the AssignVar branching).


Field Summary
 
Fields inherited from class choco.AbstractEntity
hook, problem
 
Constructor Summary
AbstractDecision(AbstractProblem problem)
           
 
Method Summary
 void activateListener()
           
 void addListener(boolean dynamicAddition)
          This function connects a constraint with its variables in several ways.
 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
 void awake()
          Propagation: Propagating the constraint for the very first time until local consistency is reached.
 void awakeOnVar(int idx)
          propagation on domain revision.
 java.lang.Object clone()
          returns a copy of the constraint.
 void deactivateListener()
           
 void deactivateListener(int varIndex)
           
 int getConstraintIdx(int idx)
          Network management: Among all listeners linked to the idx-th variable of c, find the index of constraint c.
 PropagationEvent getEvent()
          Returns the constraint awake var associated with this constraint.
 ConstraintPlugin getPlugIn()
          Returns the constraint plugin.
 int getPriority()
          Propagation: Accessing the priority level of the queue handling the propagation of the constraint.
 int getVarIdxInOpposite(int i)
          computes the index of the i-th variable in the counter-opposite of the constraint
 boolean isActive()
          Propagation: A constraint is active if it is connected to the network and if it does propagate.
 boolean isConsistent()
          tests if the constraint is consistent with respect to the current state of domains
 java.lang.Boolean isEntailed()
          Checks whether the constraint is definitely satisfied, no matter what further restrictions occur to the domain of its variables.
 boolean isEquivalentTo(Constraint compareTo)
          tests the equivalence (logical equality of the conditions) between two constraints.
 Constraint negate()
          Returns the negation of this enumeration constraint.
 AbstractConstraint opposite()
          computes the constraint modelling the counter-opposite condition of this
 void propagate()
          Propagation: Propagating the constraint until local consistency is reached.
 void setActive()
          Propagation: un-freezes a constraint [a constraint is active if it is connected to the network and if it does propagate]
 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 setPassive()
          Propagation: freezes a constraint [a constraint is active if it is connected to the network and if it does propagate]
 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.
 
Methods inherited from class choco.AbstractEntity
getProblem, pretty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface choco.palm.dbt.search.DecisionConstraint
getBranch
 

Constructor Detail

AbstractDecision

public AbstractDecision(AbstractProblem problem)
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 java.lang.Object
Returns:
Throws:
java.lang.CloneNotSupportedException

getPlugIn

public ConstraintPlugin getPlugIn()
Description copied from interface: Propagator
Returns the constraint plugin. Useful for extending the solver.

Specified by:
getPlugIn in interface Propagator

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

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

negate

public Constraint negate()
Description copied from interface: DecisionConstraint
Returns the negation of this enumeration constraint.

Specified by:
negate in interface DecisionConstraint

addListener

public void addListener(boolean dynamicAddition)
Description copied from interface: VarEventListener
This function connects a constraint with its variables in several ways. Note that it may only be called once the constraint has been fully created and is being posted to a problem. Note that it should be called only once per constraint. This can be a dynamic addition (undone upon backtracking) or not

Specified by:
addListener in interface VarEventListener

deactivateListener

public void deactivateListener(int varIndex)

deactivateListener

public void deactivateListener()

activateListener

public void activateListener()

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.

Specified by:
setConstraintIndex in interface Constraint
Specified by:
setConstraintIndex in interface PalmVarListener
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 idx)
Description copied from interface: Constraint
Network management: Among all listeners linked to the idx-th variable of c, find the index of constraint c.

Specified by:
getConstraintIdx in interface Constraint
Specified by:
getConstraintIdx in interface PalmVarListener
Parameters:
idx - index of the variable in the constraint

awake

public void awake()
           throws ContradictionException
Description copied from interface: Propagator
Propagation: Propagating the constraint for the very first time until local consistency is reached.

Specified by:
awake in interface Propagator
Throws:
ContradictionException

awakeOnVar

public void awakeOnVar(int idx)
                throws ContradictionException
Description copied from interface: VarEventListener
propagation on domain revision.

Specified by:
awakeOnVar in interface VarEventListener
Specified by:
awakeOnVar in interface Propagator
Throws:
ContradictionException

propagate

public void propagate()
               throws ContradictionException
Description copied from interface: Propagator
Propagation: Propagating the constraint until local consistency is reached.

Specified by:
propagate in interface Propagator
Throws:
ContradictionException

getPriority

public int getPriority()
Description copied from interface: Propagator
Propagation: Accessing the priority level of the queue handling the propagation of the constraint. Results range from 1 (most reactive, for listeners with fast propagation algorithms) to 4 (most delayed, for listeners with lengthy propagation algorithms).

Specified by:
getPriority in interface Propagator

isActive

public boolean isActive()
Description copied from interface: VarEventListener
Propagation: A constraint is active if it is connected to the network and if it does propagate.

Specified by:
isActive in interface VarEventListener

setActive

public void setActive()
Description copied from interface: VarEventListener
Propagation: un-freezes a constraint [a constraint is active if it is connected to the network and if it does propagate]

Specified by:
setActive in interface VarEventListener

setPassive

public void setPassive()
Description copied from interface: VarEventListener
Propagation: freezes a constraint [a constraint is active if it is connected to the network and if it does propagate]

Specified by:
setPassive in interface VarEventListener

getEvent

public PropagationEvent getEvent()
Description copied from interface: Propagator
Returns the constraint awake var associated with this constraint.

Specified by:
getEvent in interface Propagator

isEntailed

public java.lang.Boolean isEntailed()
Description copied from interface: Propagator
Checks whether the constraint is definitely satisfied, no matter what further restrictions occur to the domain of its variables.

Specified by:
isEntailed in interface Propagator

isConsistent

public boolean isConsistent()
Description copied from interface: Propagator
tests if the constraint is consistent with respect to the current state of domains

Specified by:
isConsistent in interface Propagator

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
Parameters:
i - the index of the variable in the current constraint (this)
Returns:
the index of the variable in the opposite constraint (this.opposite())

opposite

public AbstractConstraint opposite()
Description copied from interface: Constraint
computes the constraint modelling the counter-opposite condition of this

Specified by:
opposite in interface Constraint
Returns:
a new constraint (modelling the opposite condition)

isEquivalentTo

public boolean isEquivalentTo(Constraint compareTo)
Description copied from interface: Constraint
tests the equivalence (logical equality of the conditions) between two constraints. In particular whenever c1.equals(c2), then c1.isEquivalent(c2).

Specified by:
isEquivalentTo in interface Constraint
Parameters:
compareTo - the constraint to be compared to
Returns:
true if and only if the constraints model the same logical condition.

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

Specified by:
assignIndices in interface Propagator
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