Class Decision<E extends Variable>
- java.lang.Object
-
- org.chocosolver.solver.search.strategy.decision.Decision<E>
-
- Type Parameters:
E- type of variable handle by this decision
- All Implemented Interfaces:
Serializable,ICause
- Direct Known Subclasses:
IbexDecision,IntDecision,RealDecision,RootDecision,SetDecision
public abstract class Decision<E extends Variable> extends Object implements ICause, Serializable
An abstract which defines a Decision- Since:
- 2 juil. 2010
- Author:
- Charles Prud'homme
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intbranchIndication of the decision state. 0: not yet applied 1: applied once 2: refuter once, ...protected intmax_branchingNumber of time a decision can be applied.protected EvarVariable of this decision
-
Constructor Summary
Constructors Constructor Description Decision(int arity)Create a arity-decision.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidapply()Apply the current decisionvoidbuildNext()Build the refutation, hasNext() must be called beforeDecision<E>duplicate()abstract voidfree()Free the decision, ie, it can be reusedintgetArity()abstract ObjectgetDecisionValue()Return the value object involves in the decisionEgetDecisionVariable()Return the variable object involves in the decisionintgetPosition()Get the position of this decision in the decision path Note that the position a decision is unique, but some decisions taken together have the same rank.booleanhasNext()Return true if the decision can be refutedbooleanisEquivalentTo(Decision dec)voidreverse()Reverse the decision operatorvoidrewind()Force the decision to be in its creation state.protected voidset(E var)Reuse the decisionvoidsetPosition(int p)Set the position of this decision in the decision path.Decision<E>setRefutable(boolean isRefutable)Indicate whether or not this decision can be refuted if set to false, if the decision(e.g. x=3) fails instead of backtracking once and applying its negation (e.g. x!inttriesLeft()Return the number of branches left to try
-
-
-
Method Detail
-
setPosition
public final void setPosition(int p)
Set the position of this decision in the decision path. Note that the position a decision is unique, but some decisions taken together have the same rank.- Parameters:
p- position of this decision in the decision path
-
getPosition
public final int getPosition()
Get the position of this decision in the decision path Note that the position a decision is unique, but some decisions taken together have the same rank.- Returns:
- position of this decision in the decision path
-
hasNext
public final boolean hasNext()
Return true if the decision can be refuted- Returns:
- true if the decision can be refuted, false otherwise
-
buildNext
public final void buildNext()
Build the refutation, hasNext() must be called before
-
triesLeft
public final int triesLeft()
Return the number of branches left to try- Returns:
- number of tries left
-
setRefutable
public final Decision<E> setRefutable(boolean isRefutable)
Indicate whether or not this decision can be refuted if set to false, if the decision(e.g. x=3) fails instead of backtracking once and applying its negation (e.g. x!=3) the resolver will backtrack twice and negates the previous decision.- Parameters:
isRefutable- set to false to disable refutation- Returns:
- this object
-
getArity
public final int getArity()
- Returns:
- number of time a decision can be applied. For unary decision set to 1 , for binary decision, set to 2, ...
-
apply
public abstract void apply() throws ContradictionExceptionApply the current decision- Throws:
ContradictionException- if the application of this decision fails
-
rewind
public final void rewind()
Force the decision to be in its creation state.
-
set
protected void set(E var)
Reuse the decision- Parameters:
var- the decision object (commonly a variable)
-
getDecisionVariable
public final E getDecisionVariable()
Return the variable object involves in the decision- Returns:
- a variable V
-
getDecisionValue
public abstract Object getDecisionValue()
Return the value object involves in the decision- Returns:
- a value object
-
free
public abstract void free()
Free the decision, ie, it can be reused
-
reverse
public void reverse()
Reverse the decision operator
-
isEquivalentTo
public boolean isEquivalentTo(Decision dec)
- Parameters:
dec- a decision- Returns:
- true if the two decisions are equivalent (same variable, same operator, same value)
-
-