choco.prop
Class ChocEngine

java.lang.Object
  extended by choco.AbstractEntity
      extended by choco.prop.AbstractPropagationEngine
          extended by choco.prop.ChocEngine
All Implemented Interfaces:
Entity, PropagationEngine
Direct Known Subclasses:
PalmEngine

public class ChocEngine
extends AbstractPropagationEngine

Implementation of an AbstractPropagationEngine for Choco.


Field Summary
protected static int NB_CONST_QUEUES
          the number of queues for storing constraint events
protected  int nbPendingInitConstAwakeEvent
          Number of pending init constraint awake events.
protected  VarEventQueue varEventQueue
          The queue with all the variable events.
 
Fields inherited from class choco.prop.AbstractPropagationEngine
contradictionCause
 
Fields inherited from class choco.AbstractEntity
hook, problem
 
Constructor Summary
ChocEngine(AbstractProblem pb)
          Constructs a new engine by initializing the var queues.
 
Method Summary
protected  void _postEvent(Var v, int idx, int basicEvt)
          Private method for completing the bound var posting.
 boolean checkCleanState()
          checking that the propagation engine remains in a proper state
 void decPendingInitConstAwakeEvent()
          Decrements the number of init constraint awake events.
 void flushEvents()
          Removes all pending events (used when interrupting a propagation because a contradiction has been raised)
 int getNbPendingEvents()
           
 EventQueue getNextActiveConstraintEventQueue()
          Returns the next constraint var queue from which an event should be propagated.
 EventQueue getNextActiveEventQueue()
          Returns the next queue from which an event should be propagated.
 PropagationEvent getPendingEvent(int idx)
          getter without side effect: returns the i-ht pending event (without popping any event from the queues)
 ConstraintEventQueue getQueue(ConstraintEvent event)
          Gets the queue for a given priority of var.
 VarEventQueue getVarEventQueue()
          Returns the variable var queue.
 void incPendingInitConstAwakeEvent()
          Increments the number of init constraint awake events.
 void postAddKer(SetVar v, int idx)
          Posts a kernel addition event on a set variable
 boolean postConstAwake(Propagator constraint, boolean init)
          Posts a constraint awake var.
 void postInstInt(IntDomainVar v, int idx)
          Posts an Inst var.
 void postInstSet(SetVar v, int idx)
          Posts an Inst event on a set var.
 void postRemEnv(SetVar v, int idx)
          Posts a removal event on a set variable
 void postRemoveVal(IntDomainVar v, int x, int idx)
          Posts an Remove var.
 void postUpdateInf(IntDomainVar v, int idx)
          Posts an IncInf event
 void postUpdateInf(RealVar v, int idx)
          Posts an lower bound event for a real variable.
 void postUpdateSup(IntDomainVar v, int idx)
          Posts a DecSup event
 void postUpdateSup(RealVar v, int idx)
          Posts an upper bound event for a real variable
 void raiseContradiction()
          Throws a contradiction without cause.
 void raiseContradiction(Entity cause)
          Throws a contradiction with the specified cause.
 void registerEvent(ConstraintEvent event)
          Registers an event in the queue.
 
Methods inherited from class choco.prop.AbstractPropagationEngine
getContradictionCause, setContradictionCause, setNoContradictionCause
 
Methods inherited from class choco.AbstractEntity
getProblem, pretty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface choco.Entity
getProblem, pretty
 

Field Detail

NB_CONST_QUEUES

protected static int NB_CONST_QUEUES
the number of queues for storing constraint events


nbPendingInitConstAwakeEvent

protected int nbPendingInitConstAwakeEvent
Number of pending init constraint awake events.


varEventQueue

protected VarEventQueue varEventQueue
The queue with all the variable events.

Constructor Detail

ChocEngine

public ChocEngine(AbstractProblem pb)
Constructs a new engine by initializing the var queues.

Method Detail

postUpdateInf

public void postUpdateInf(IntDomainVar v,
                          int idx)
Posts an IncInf event

Parameters:
v - The variable the bound is modified.
idx - The index of the constraint which is responsible of the var.

postUpdateSup

public void postUpdateSup(IntDomainVar v,
                          int idx)
Posts a DecSup event

Parameters:
v - The variable the bound is modified.
idx - The index of the constraint which is responsible of the var.

_postEvent

protected void _postEvent(Var v,
                          int idx,
                          int basicEvt)
Private method for completing the bound var posting.

Parameters:
basicEvt - The basic event posted.
idx - The index of the constraint which is responsible of the var.

postInstInt

public void postInstInt(IntDomainVar v,
                        int idx)
Posts an Inst var.

Parameters:
v - The variable that is instantiated.
idx - The index of the constraint which is responsible of the var.

postRemoveVal

public void postRemoveVal(IntDomainVar v,
                          int x,
                          int idx)
Posts an Remove var.

Parameters:
v - The variable the value is removed from.
idx - The index of the constraint which is responsible of the var.

postUpdateInf

public void postUpdateInf(RealVar v,
                          int idx)
Posts an lower bound event for a real variable.

Parameters:
v -
idx -

postUpdateSup

public void postUpdateSup(RealVar v,
                          int idx)
Posts an upper bound event for a real variable

Parameters:
v -
idx -

postRemEnv

public void postRemEnv(SetVar v,
                       int idx)
Posts a removal event on a set variable

Parameters:
v - the variable the enveloppe is modified
idx - the index of the constraint that causes the event

postAddKer

public void postAddKer(SetVar v,
                       int idx)
Posts a kernel addition event on a set variable

Parameters:
v - the variable the kernel is modified
idx - the index of the constraint that causes the event

postInstSet

public void postInstSet(SetVar v,
                        int idx)
Posts an Inst event on a set var.

Parameters:
v - The variable that is instantiated.
idx - The index of the constraint which is responsible of the var.

postConstAwake

public boolean postConstAwake(Propagator constraint,
                              boolean init)
Posts a constraint awake var.

Parameters:
constraint - The constraint that must be awaken.
init - Specifies if the constraint must be initialized (awake instead of propagate).

getQueue

public ConstraintEventQueue getQueue(ConstraintEvent event)
Gets the queue for a given priority of var.

Parameters:
event - The var for which the queue is searched.

registerEvent

public void registerEvent(ConstraintEvent event)
Registers an event in the queue. It should be called before using the queue to add the var in the available events of the queue.

Parameters:
event -

getVarEventQueue

public VarEventQueue getVarEventQueue()
Returns the variable var queue.


raiseContradiction

public void raiseContradiction()
                        throws ContradictionException
Throws a contradiction without cause.

Throws:
ContradictionException

raiseContradiction

public void raiseContradiction(Entity cause)
                        throws ContradictionException
Throws a contradiction with the specified cause.

Throws:
ContradictionException

decPendingInitConstAwakeEvent

public void decPendingInitConstAwakeEvent()
Decrements the number of init constraint awake events.


incPendingInitConstAwakeEvent

public void incPendingInitConstAwakeEvent()
Increments the number of init constraint awake events.


getNextActiveConstraintEventQueue

public EventQueue getNextActiveConstraintEventQueue()
Returns the next constraint var queue from which an event should be propagated.


getNextActiveEventQueue

public EventQueue getNextActiveEventQueue()
Returns the next queue from which an event should be propagated.

Specified by:
getNextActiveEventQueue in interface PropagationEngine
Overrides:
getNextActiveEventQueue in class AbstractPropagationEngine

getNbPendingEvents

public int getNbPendingEvents()

getPendingEvent

public PropagationEvent getPendingEvent(int idx)
getter without side effect: returns the i-ht pending event (without popping any event from the queues)


flushEvents

public void flushEvents()
Removes all pending events (used when interrupting a propagation because a contradiction has been raised)


checkCleanState

public boolean checkCleanState()
Description copied from interface: PropagationEngine
checking that the propagation engine remains in a proper state