public class DecisionPath extends DecisionMaker implements Serializable
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.
Modifier and Type | Field and Description |
---|---|
protected int[] |
levels
Indices of level in
decisions |
protected IStateInt |
mLevel
Store the sizes of
decisions during search, to evaluate which decisions are part of the same level. |
Constructor and Description |
---|
DecisionPath(IEnvironment environment)
Create a decision path
|
Modifier and Type | Method and Description |
---|---|
void |
apply()
Apply decisions pushed since the last call to this method.
|
Decision |
getDecision(int i)
Return the decision in position i in this decision path, or null if no decision exists at that position.
|
Decision |
getLastDecision()
Retrieves, but not removes, the last decision of the decision path.
|
int |
indexPreviousLevelLastLevel()
Return the position of the first decision of the last level.
|
String |
lastDecisionToString() |
void |
pushDecision(Decision decision)
Add a decision at the decision path.
|
int |
size()
Return the number of decision in this decision path.
|
void |
synchronize()
Synchronizes the decision path after a backtrack.
|
String |
toString() |
void |
transferInto(Collection<Decision> aList,
boolean includeRootDecision)
Add all decisions of this decision path into a list of decision
|
makeIntDecision, makeRealDecision, makeSetDecision
protected IStateInt mLevel
decisions
during search, to evaluate which decisions are part of the same level.protected int[] levels
decisions
public DecisionPath(IEnvironment environment)
environment
- backtracking environmentpublic void apply() throws ContradictionException
ContradictionException
- if one decision application failspublic void pushDecision(Decision decision)
decision
- the decision to addpublic void synchronize()
RootDecision.ROOT
, can not be removed from this.public Decision getLastDecision()
RootDecision.ROOT
.public int indexPreviousLevelLastLevel()
public int size()
RootDecision.ROOT
.public Decision getDecision(int i)
i
- index of the decision to returnIndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())public void transferInto(Collection<Decision> aList, boolean includeRootDecision)
aList
- list to populateincludeRootDecision
- set to true to include the very first fake decision, ROOT, in the list.public String lastDecisionToString()
Copyright © 2018. All rights reserved.