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 apply(), and removed in a call to synchronize().
    Note that, if more than one decision is added before calling apply(), these decisions belong to the same level. They will be applied at the same time in a call to apply(), and remove at the same time in a call to synchronize(). Otherwise, 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
    • Field Detail

      • mLevel

        protected IStateInt mLevel
        Store the sizes of decisions during search, to evaluate which decisions are part of the same level.
      • levels

        protected int[] levels
        Indices of level in decisions
    • Constructor Detail

      • DecisionPath

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

      • apply

        public void apply()
                   throws ContradictionException
        Apply decisions pushed since the last call to this method. If more than one decision are applied in this call, they are automatically force to not be refuted, and are considered to belong to the same level.
        Throws:
        ContradictionException - if one decision application fails
      • 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 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.
      • 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.
      • indexPreviousLevelLastLevel

        public int indexPreviousLevelLastLevel()
        Return the position of the first decision of the last level. Except for LNS first meta-decision, this should return the position of the last decision
        Returns:
        the position of the first decision of the last level.
      • 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)