Module org.chocosolver
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 int
branch
Indication of the decision state. 0: not yet applied 1: applied once 2: refuter once, ...protected int
max_branching
Number of time a decision can be applied.protected E
var
Variable 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 void
apply()
Apply the current decisionvoid
buildNext()
Build the refutation, hasNext() must be called beforeDecision<E>
duplicate()
abstract void
free()
Free the decision, ie, it can be reusedint
getArity()
abstract Object
getDecisionValue()
Return the value object involves in the decisionE
getDecisionVariable()
Return the variable object involves in the decisionint
getPosition()
Get the position of this decision in the decision path Note that the position a decision is unique.boolean
hasNext()
Return true if the decision can be refutedboolean
isEquivalentTo(Decision dec)
void
reverse()
Reverse the decision operatorvoid
rewind()
Force the decision to be in its creation state.protected void
set(E var)
Reuse the decisionvoid
setPosition(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!int
triesLeft()
Return the number of branches left to try-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.chocosolver.solver.ICause
explain, forEachIntVar
-
-
-
-
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.- 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.- 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 ContradictionException
Apply 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)
-
-