Class DecisionPath

  • All Implemented Interfaces:
    Serializable

    public class DecisionPath
    extends DecisionMaker
    implements Serializable
    To handle set of decisions.

    Decisions are added to this set of decisions with a call to pushDecision(Decision), Decisions are then applied in a call to buildNext() and apply(), and removed in a call to synchronize().
    Only one decision can be added at the same level. The last declared will erased the previous ones. Only one decision is applied/removed at a time.
    First decision is always RootDecision.ROOT, so, size() returns at least 1.

    Project: choco-solver.

    Since:
    11/03/2016.
    Author:
    Charles Prud'homme
    See Also:
    Serialized Form
    • Constructor Detail

      • DecisionPath

        public DecisionPath​(IEnvironment environment)
        Create a decision path
        Parameters:
        environment - backtracking environment
    • Method Detail

      • buildNext

        public void buildNext()
        Prepare the last decision pushed since the last call to this method to be applied.
      • pushDecision

        public void pushDecision​(Decision decision)
        Add a decision at the decision path.
        Parameters:
        decision - the decision to add
      • synchronize

        public void synchronize()
        Synchronizes the decision path after a backtrack. Removes and frees all decisions with level greater or equal to the current level. Recall that the very first decision, RootDecision.ROOT, can not be removed from this.
      • synchronize

        public void synchronize​(boolean free)
        Synchronizes the decision path after a backtrack. Removes all decisions with level greater or equal to the current level. Recall that the very first decision, RootDecision.ROOT, can not be removed from this.
        Parameters:
        free - set to true to synchronize and free out-dated decisions
      • getLastDecision

        public Decision getLastDecision()
        Retrieves, but not removes, the last decision of the decision path. Recall that the very first decision of this decision path is RootDecision.ROOT.
        Returns:
        the last decision of the decision path.
      • size

        public int size()
        Return the number of decision in this decision path. Recall that this decisions path contains at least one decision: RootDecision.ROOT.
        Returns:
        the size of the decision path
      • getDecision

        public Decision getDecision​(int i)
        Return the decision in position i in this decision path, or null if no decision exists at that position.
        Parameters:
        i - index of the decision to return
        Returns:
        the decision in position i in this decision path
        Throws:
        IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())
      • transferInto

        public void transferInto​(Collection<Decision> aList,
                                 boolean includeRootDecision)
        Add all decisions of this decision path into a list of decision
        Parameters:
        aList - list to populate
        includeRootDecision - set to true to include the very first fake decision, ROOT, in the list.
      • lastDecisionToString

        public String lastDecisionToString()
        Returns:
        a pretty print of the downmost decision(s)