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 booleanCHECK_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 voidclear()Clear internal structuresvoiddelayedPropagation(Propagator propagator, PropagatorEventType type)Exeucte a delayed propagatorvoiddesactivatePropagator(Propagator propagator)Set the propagator as inactivated within the propagation enginevoiddynamicAddition(boolean permanent, Propagator... ps)Add a constraint to the propagation enginevoiddynamicDeletion(Propagator... ps)Delete the list of propagators in input from the enginevoidexecute(Propagator propagator)Execute 'coarse' propagation on a newly added propagator or one that should be propagated on backtrackvoidflush()Flushthis, ie. remove every pending eventsvoidignoreModifications()voidinitialize()Build up internal structure, if not yet done, in order to allow propagation.booleanisInitialized()Is the engine initialized?voidonPropagatorExecution(Propagator propagator)Action to do when a propagator is executedvoidonVariableUpdate(Variable variable, IEventType type, ICause cause)Take into account the modification of a variablevoidpropagate()Launch the proapagation, ie, active propagators if necessary, then reach a fix pointvoidpropagateOnBacktrack(Propagator propagator)Update the scope of variable of a propagator (addition or deletion are allowed -- p.vars are scanned)voidreset()Reset the propagation engine.voidupdateInvolvedVariables(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 SolverExceptionBuild 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 ContradictionExceptionLaunch 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
-
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 SolverExceptionAdd 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
-
-