Class DecisionPath
- java.lang.Object
-
- org.chocosolver.solver.search.strategy.decision.DecisionMaker
-
- org.chocosolver.solver.search.strategy.decision.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 toapply(), and removed in a call tosynchronize(). Note that, if more than one decision is added before callingapply(), these decisions belong to the same level. They will be applied at the same time in a call toapply(), and remove at the same time in a call tosynchronize(). Otherwise, only one decision is applied/removed at a time. First decision is alwaysRootDecision.ROOT, so,size()returns at least 1.Project: choco-solver.
- Since:
- 11/03/2016.
- Author:
- Charles Prud'homme
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DecisionPath(IEnvironment environment)Create a decision path
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapply()Apply decisions pushed since the last call to this method.DecisiongetDecision(int i)Return the decision in position i in this decision path, or null if no decision exists at that position.DecisiongetLastDecision()Retrieves, but not removes, the last decision of the decision path.intindexPreviousLevelLastLevel()Return the position of the first decision of the last level.StringlastDecisionToString()voidpushDecision(Decision decision)Add a decision at the decision path.intsize()Return the number of decision in this decision path.voidsynchronize()Synchronizes the decision path after a backtrack.StringtoString()voidtransferInto(Collection<Decision> aList, boolean includeRootDecision)Add all decisions of this decision path into a list of decision-
Methods inherited from class org.chocosolver.solver.search.strategy.decision.DecisionMaker
makeIntDecision, makeRealDecision, makeSetDecision
-
-
-
-
Constructor Detail
-
DecisionPath
public DecisionPath(IEnvironment environment)
Create a decision path- Parameters:
environment- backtracking environment
-
-
Method Detail
-
apply
public void apply() throws ContradictionExceptionApply 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 isRootDecision.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 populateincludeRootDecision- 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)
-
-