choco.cp.solver.propagation
Class ChocoEngine

java.lang.Object
  extended by choco.cp.solver.propagation.AbstractPropagationEngine
      extended by choco.cp.solver.propagation.ChocoEngine
All Implemented Interfaces:
PropagationEngine

public class ChocoEngine
extends AbstractPropagationEngine

Implementation of an AbstractPropagationEngine for Choco.


Field Summary
protected  ConstraintEventQueue[] constEventQueues
          The different queues for the constraint awake events.
protected  int nbPendingInitConstAwakeEvent
          Number of pending init constraint awake events.
protected  VariableEventQueue[] varEventQueue
          The queue with all the variable events.
 
Fields inherited from class choco.cp.solver.propagation.AbstractPropagationEngine
failMeasure, pelIdx, propagationEngineListeners, reuseException, solver
 
Fields inherited from interface choco.kernel.solver.propagation.PropagationEngine
LOGGER
 
Constructor Summary
ChocoEngine(Solver solver)
          Constructs a new engine by initializing the var queues.
 
Method Summary
 boolean checkCleanState()
          checking that the propagation engine remains in a proper state
 void clear()
          Clear datastructures for safe reuses
 void decPendingInitConstAwakeEvent()
          Decrements the number of init constraint awake events.
 void desactivatePropagator(Propagator propagator)
          Desactivate a constraint.
 void flushEvents()
          Removes all pending events (used when interrupting a propagation because a contradiction has been raised)
 void freeze()
          Freeze the current events contained in this.
 int getNbPendingEvents()
          Return the number of pending events.
 PropagationEvent getPendingEvent(int idx)
          getter without side effect: returns the i-ht pending event (without popping any event from the queues)
 void incPendingInitConstAwakeEvent()
          Increments the number of init constraint awake events.
 void loadSettings(Configuration configuration)
           
 boolean postConstAwake(Propagator constraint, boolean init)
          Post a constraint event.
 void postEvent(Var v, int basicEvt, SConstraint constraint, boolean forceAwake)
          Generic method to post events.
 void propagateEvents()
          Propagate one by one events registered
 void registerPropagator(Propagator c)
          Register a constraint.
 void unfreeze()
          Unfreeze the previously frozen events contained in this.
 
Methods inherited from class choco.cp.solver.propagation.AbstractPropagationEngine
addPropagationEngineListener, containsPropagationListener, getFailMeasure, getSolver, postAddKer, postInstInt, postInstSet, postRemEnv, postRemoveVal, postUpdateInf, postUpdateInf, postUpdateSup, postUpdateSup, raiseContradiction, raiseContradiction, raiseContradiction, removePropagationEngineListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constEventQueues

protected ConstraintEventQueue[] constEventQueues
The different queues for the constraint awake events.


nbPendingInitConstAwakeEvent

protected int nbPendingInitConstAwakeEvent
Number of pending init constraint awake events.


varEventQueue

protected VariableEventQueue[] varEventQueue
The queue with all the variable events.

Constructor Detail

ChocoEngine

public ChocoEngine(Solver solver)
Constructs a new engine by initializing the var queues.

Parameters:
solver - Solver master
Method Detail

loadSettings

public void loadSettings(Configuration configuration)

clear

public void clear()
Clear datastructures for safe reuses

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

postEvent

public void postEvent(Var v,
                      int basicEvt,
                      SConstraint constraint,
                      boolean forceAwake)
Generic method to post events. The caller is reponsible of basic event type field: it should be meaningful for the the associate kind of event.

Parameters:
v - The modified variable.
basicEvt - integer specifying mdofication kind for the attached
constraint - constraint at the origin of the modification
forceAwake - should the constraint be informed of the current event

postConstAwake

public boolean postConstAwake(Propagator constraint,
                              boolean init)
Post a constraint event.

Parameters:
constraint - constraint to call
init - indicates wether this call should be a call to Propagator.awake() (true) or to Propagator.Propagator() (false).
Returns:
true if the event has been added, false if it was already present

registerPropagator

public void registerPropagator(Propagator c)
Register a constraint. Any constraint declared in the Solver should be present in this. It should be called before call to Propagator.propagate().

Parameters:
c - element to declare to this

propagateEvents

public void propagateEvents()
                     throws ContradictionException
Propagate one by one events registered. First, it propagates every variable events (respecting priority hierarchy). Then, it propagates one constraint event and checks for variable events to propagate. Loops until no event found.

Throws:
ContradictionException - if an event propagation creates a contradiction

desactivatePropagator

public void desactivatePropagator(Propagator propagator)
Desactivate a constraint. This constraint won't be informed of any new events occuring on its variable.

Parameters:
propagator - element to desactivate

decPendingInitConstAwakeEvent

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


incPendingInitConstAwakeEvent

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


getNbPendingEvents

public int getNbPendingEvents()
Return the number of pending events.

Returns:
number of pending events.

getPendingEvent

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

Parameters:
idx - indice of the event
Returns:
a propagation event

flushEvents

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


checkCleanState

public boolean checkCleanState()
checking that the propagation engine remains in a proper state

Returns:
return true if the state is proper, false otherwise

freeze

public void freeze()
Freeze the current events contained in this. The behaviour of the engine is still the same, but those events won't be treated in next calls to PropagationEngine.propagateEvents()


unfreeze

public void unfreeze()
Unfreeze the previously frozen events contained in this. See PropagationEngine.freeze().



Copyright © 2012. All Rights Reserved.