Class PropagationEngine


  • public class PropagationEngine
    extends Object
    This engine is priority-driven constraint-oriented seven queues engine.
    On a call to onVariableUpdate, 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 Detail

      • CHECK_SCOPE

        public static boolean CHECK_SCOPE
    • 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
      • 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()
        Flush this, 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 variable
        type - type of modification event
        cause - 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 execute
        type - 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 added
        ps - 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