Class PropagationEngine
- java.lang.Object
-
- org.chocosolver.solver.propagation.PropagationEngine
-
public class PropagationEngine extends Object
This engine is priority-driven constraint-oriented seven queues engine.
On a call toonVariableUpdate
, it stores the event generated and schedules the propagator in one of the 7 queues wrt to its priority for future revision.- Since:
- 05/07/12
- Author:
- Charles Prud'homme
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
CHECK_SCOPE
-
Constructor Summary
Constructors Constructor Description PropagationEngine(Model model)
A seven-queue propagation engine.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear internal structuresvoid
delayedPropagation(Propagator propagator, PropagatorEventType type)
Exeucte a delayed propagatorvoid
desactivatePropagator(Propagator propagator)
Set the propagator as inactivated within the propagation enginevoid
dynamicAddition(boolean permanent, Propagator... ps)
Add a constraint to the propagation enginevoid
dynamicDeletion(Propagator... ps)
Delete the list of propagators in input from the enginevoid
execute(Propagator propagator)
Execute 'coarse' propagation on a newly added propagator or one that should be propagated on backtrackvoid
flush()
Flushthis
, ie. remove every pending eventsvoid
ignoreModifications()
void
initialize()
Build up internal structure, if not yet done, in order to allow propagation.boolean
isInitialized()
Is the engine initialized?void
onPropagatorExecution(Propagator propagator)
Action to do when a propagator is executedvoid
onVariableUpdate(Variable variable, IEventType type, ICause cause)
Take into account the modification of a variablevoid
propagate()
Launch the proapagation, ie, active propagators if necessary, then reach a fix pointvoid
propagateOnBacktrack(Propagator propagator)
Update the scope of variable of a propagator (addition or deletion are allowed -- p.vars are scanned)void
reset()
Reset the propagation engine.void
schedule(Propagator prop, int pindice, int mask)
void
updateInvolvedVariables(Propagator p)
Update the scope of variable of a propagator (addition or deletion are allowed -- p.vars are scanned)
-
-
-
Constructor Detail
-
PropagationEngine
public PropagationEngine(Model model)
A seven-queue propagation engine. Each of the seven queues deals with on priority. When a propagator needs to be executed, it is scheduled in the queue corresponding to its priority. The lowest priority queue is emptied before one element of the second lowest queue is popped, etc.- Parameters:
model
- the declaring model
-
-
Method Detail
-
initialize
public void initialize() throws SolverException
Build up internal structure, if not yet done, in order to allow propagation. If new constraints are added after having initializing the engine, dynamic addition is used. A call to clear erase the internal structure, and allow new initialisation.- Throws:
SolverException
- if a constraint is declared more than once in this propagation engine
-
isInitialized
public boolean isInitialized()
Is the engine initialized? Important for dynamic addition of constraints- Returns:
- true if the engine has been initialized
-
propagate
public void propagate() throws ContradictionException
Launch the proapagation, ie, active propagators if necessary, then reach a fix point- Throws:
ContradictionException
- if a contradiction occurrs
-
execute
public void execute(Propagator propagator) throws ContradictionException
Execute 'coarse' propagation on a newly added propagator or one that should be propagated on backtrack- Parameters:
propagator
- a propagator to propagate- Throws:
ContradictionException
- if propagation fails
-
flush
public void flush()
Flushthis
, ie. remove every pending events
-
onVariableUpdate
public void onVariableUpdate(Variable variable, IEventType type, ICause cause)
Take into account the modification of a variable- Parameters:
variable
- modified variabletype
- type of modification eventcause
- origin of the modification
-
schedule
public void schedule(Propagator prop, int pindice, int mask)
-
delayedPropagation
public void delayedPropagation(Propagator propagator, PropagatorEventType type)
Exeucte a delayed propagator- Parameters:
propagator
- propagator to executetype
- type of event to execute
-
onPropagatorExecution
public void onPropagatorExecution(Propagator propagator)
Action to do when a propagator is executed- Parameters:
propagator
- propagator to execute
-
desactivatePropagator
public void desactivatePropagator(Propagator propagator)
Set the propagator as inactivated within the propagation engine- Parameters:
propagator
- propagator to desactivate
-
reset
public void reset()
Reset the propagation engine.
-
clear
public void clear()
Clear internal structures
-
ignoreModifications
public void ignoreModifications()
-
dynamicAddition
public void dynamicAddition(boolean permanent, Propagator... ps) throws SolverException
Add a constraint to the propagation engine- Parameters:
permanent
- does the constraint is permanently addedps
- propagators to add * @throws SolverException if a constraint is declared more than once in this propagation engine- Throws:
SolverException
-
updateInvolvedVariables
public void updateInvolvedVariables(Propagator p)
Update the scope of variable of a propagator (addition or deletion are allowed -- p.vars are scanned)- Parameters:
p
- a propagator
-
propagateOnBacktrack
public void propagateOnBacktrack(Propagator propagator)
Update the scope of variable of a propagator (addition or deletion are allowed -- p.vars are scanned)- Parameters:
propagator
- a propagator
-
dynamicDeletion
public void dynamicDeletion(Propagator... ps)
Delete the list of propagators in input from the engine- Parameters:
ps
- a list of propagators
-
-