Class LazyImplications


  • public class LazyImplications
    extends Implications
    This implication graph is lazily built. It maintains the list of events invoked during propagation on each variable, and maintains a copy of each domain.

    Data is stored in a stack, where each entry is a tuple:

    < v, D, c, m, p, n>
    where :
    • v is the variable modified,
    • D is its current domain,
    • c is the cause (most of the time, a propagator),
    • m is the mask of event that triggers the modification,
    • p is a pointer to the previous entry on v in the stack
    • n is a pointer to the next entry on v in the stack (if any)

    Note that, under some conditions, two entries can be merged into a single one. Project: choco-solver.

    Since:
    25/01/2017.
    Author:
    Charles Prud'homme
    • Method Detail

      • init

        public void init​(Model model)
        Description copied from class: Implications
        Initialize this class
        Specified by:
        init in class Implications
        Parameters:
        model - if needed, a reference to the model that uses this class
      • undoLastEvent

        public void undoLastEvent()
        Description copied from class: Implications
        Undo the last event stored, use only when dealing with views.
        Specified by:
        undoLastEvent in class Implications
      • pushEvent

        public void pushEvent​(IntVar var,
                              ICause cause,
                              IntEventType evt,
                              int one,
                              int two,
                              int three)
        Description copied from class: Implications
        Push an event
        Specified by:
        pushEvent in class Implications
        Parameters:
        var - modified variable
        cause - cause of the modification
        evt - modification mask
        one - an int
        two - an int
        three - an int
      • size

        public int size()
        Specified by:
        size in class Implications
        Returns:
        the number of nodes in the implication graph.
      • predecessorsOf

        public void predecessorsOf​(int p,
                                   ValueSortedMap<IntVar> front)
        Description copied from class: Implications
        Retrieve the nodes that are predecessors of node p in this and put them into set.
        Specified by:
        predecessorsOf in class Implications
        Parameters:
        p - index of the node whom predecessors have to be found
        front - map of (node, variable) in conflict
      • findPredecessor

        public void findPredecessor​(ValueSortedMap<IntVar> front,
                                    IntVar vi,
                                    int p)
        Find the direct predecessor of a node, declared on variable vi, starting from node at position p. If a variable-based node already exists in front, then this node is used to look for the predecessor, assuming that it is below p (otherwise, this node the predecessor we are looking for). Otherwise, there is no node based on vi in front and the rightmost node above p, starting from the predecessor of its root node, is added.
        Specified by:
        findPredecessor in class Implications
        Parameters:
        front - the set to update
        vi - the variable to look the predecessor for
        p - the rightmost position of the node (below means outdated node).
      • getCauseAt

        public ICause getCauseAt​(int idx)
        Description copied from class: Implications
        Get the ICause declared in node idx
        Specified by:
        getCauseAt in class Implications
        Parameters:
        idx - position of the node to query
        Returns:
        the cause declared in node idx
      • getEventMaskAt

        public int getEventMaskAt​(int idx)
        Description copied from class: Implications
        Get the mask of event declared in node idx. The mask can be a bitwise operation over mask of IntEventType.
        Specified by:
        getEventMaskAt in class Implications
        Parameters:
        idx - position of the node to query
        Returns:
        the event declared in node idx
      • getIntVarAt

        public IntVar getIntVarAt​(int idx)
        Description copied from class: Implications
        Get the IntVar declared in node idx
        Specified by:
        getIntVarAt in class Implications
        Parameters:
        idx - position of the node to query
        Returns:
        the intvar declared in node idx
      • getValueAt

        public int getValueAt​(int idx)
        Description copied from class: Implications
        Get the value declared in node idx
        Specified by:
        getValueAt in class Implications
        Parameters:
        idx - position of the node to query
        Returns:
        the value declared in node idx
      • getDecisionLevelAt

        public int getDecisionLevelAt​(int idx)
        Description copied from class: Implications
        Get the decision level declared in node idx
        Specified by:
        getDecisionLevelAt in class Implications
        Parameters:
        idx - position of the node to query
        Returns:
        the decision level declared in node idx
      • getPredecessorOf

        public int getPredecessorOf​(int idx)
        Description copied from class: Implications
        Get the position of precedent entry of the one declared in node idx
        Specified by:
        getPredecessorOf in class Implications
        Parameters:
        idx - position of the node to query
        Returns:
        its ancestor