Class ExplanationEngine
- java.lang.Object
-
- org.chocosolver.solver.explanations.ExplanationEngine
-
- All Implemented Interfaces:
IExplanationEngine
public class ExplanationEngine extends Object implements IExplanationEngine
An Asynchronous, Reverse, Low-Intrusive and Lazy explanation engine Based on "A Lazy explanation engine for Choco3", C.Prud'homme.Created by cprudhom on 09/12/14. Project: choco.
-
-
Constructor Summary
Constructors Constructor Description ExplanationEngine(Model model, boolean partialExplanationsOn, boolean recordCauses)Create an explanation engine based on a rule store
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivePropagator(BoolVar var, Propagator propagator)Explain the activation of a propagator involved in a reified constraintExplanationexplain(ContradictionException cex)Compute the explanation of the last event from the event store (naturally, the one that leads to a conflict), and return the explanation of the failure, that is, the (sub-)set of decisions and propagators explaining the conflict.voidfreeDecisionExplanation(Decision decision)Free the explanation related to the decision (for efficiency purpose only)ExplanationgetDecisionRefutationExplanation(Decision decision)Get the explanation of a decision refutationArrayEventStoregetEventStore()RuleStoregetRuleStore()voidinstantiateTo(IntVar var, int val, ICause cause, int oldLB, int oldUB)Explain the assignment tovalofvardue tocause.booleanisSaveCauses()Indicate whether or not the clauses are saved in ExplanationExplanationmakeExplanation(boolean saveCauses)voidmoveDecisionRefutation(Decision decision, int to)Move a decision explanation from the old index to the new one.voidremoveValue(IntVar var, int val, ICause cause)Explain the removal of thevalfromvar, due tocause.voidstoreDecisionExplanation(Decision decision, Explanation explanation)Store a decision refutation, for future reasoning.voidundo()Undo the last operation donevoidupdateLowerBound(IntVar var, int value, int old, ICause cause)Explain the removal of [old,value[ fromvar, due tocause.voidupdateUpperBound(IntVar var, int value, int old, ICause cause)Explain the removal of ]value,old] fromvar, due tocause.
-
-
-
Constructor Detail
-
ExplanationEngine
public ExplanationEngine(Model model, boolean partialExplanationsOn, boolean recordCauses)
Create an explanation engine based on a rule store- Parameters:
model- a modelpartialExplanationsOn- set to true to enable partial explanations, false otherwiserecordCauses- set to true to record causes in explanations, false otherwise
-
-
Method Detail
-
isSaveCauses
public boolean isSaveCauses()
Indicate whether or not the clauses are saved in Explanation- Specified by:
isSaveCausesin interfaceIExplanationEngine- Returns:
- if clauses are saved
-
explain
public Explanation explain(ContradictionException cex)
Compute the explanation of the last event from the event store (naturally, the one that leads to a conflict), and return the explanation of the failure, that is, the (sub-)set of decisions and propagators explaining the conflict.- Specified by:
explainin interfaceIExplanationEngine- Parameters:
cex- contradiction to explain- Returns:
- an explanation (set of decisions and propagators).
-
makeExplanation
public Explanation makeExplanation(boolean saveCauses)
- Specified by:
makeExplanationin interfaceIExplanationEngine- Parameters:
saveCauses- set to true if causes need to be stored- Returns:
- an empty explanation, ready to be filled up
-
getRuleStore
public RuleStore getRuleStore()
- Specified by:
getRuleStorein interfaceIExplanationEngine- Returns:
- the current rule store
-
getEventStore
public ArrayEventStore getEventStore()
- Specified by:
getEventStorein interfaceIExplanationEngine- Returns:
- the current store of events
-
getDecisionRefutationExplanation
public Explanation getDecisionRefutationExplanation(Decision decision)
Get the explanation of a decision refutation- Specified by:
getDecisionRefutationExplanationin interfaceIExplanationEngine- Parameters:
decision- a refuted decision- Returns:
- the explanation
-
storeDecisionExplanation
public void storeDecisionExplanation(Decision decision, Explanation explanation)
Store a decision refutation, for future reasoning.- Specified by:
storeDecisionExplanationin interfaceIExplanationEngine- Parameters:
decision- refuted decisionexplanation- the explanation of the refutation
-
moveDecisionRefutation
public void moveDecisionRefutation(Decision decision, int to)
Move a decision explanation from the old index to the new one. Required for DBT only and should be called with care!- Specified by:
moveDecisionRefutationin interfaceIExplanationEngine- Parameters:
decision- a decisionto- the new index
-
freeDecisionExplanation
public void freeDecisionExplanation(Decision decision)
Free the explanation related to the decision (for efficiency purpose only)- Specified by:
freeDecisionExplanationin interfaceIExplanationEngine- Parameters:
decision- the decision which is going to be forgotten
-
removeValue
public void removeValue(IntVar var, int val, ICause cause)
Explain the removal of thevalfromvar, due tocause. This is the main explanation why we create this class. Record operations to execute for explicit call to explanation.- Specified by:
removeValuein interfaceIExplanationEngine- Parameters:
var- an integer variableval- a valuecause- a cause
-
updateLowerBound
public void updateLowerBound(IntVar var, int value, int old, ICause cause)
Explain the removal of [old,value[ fromvar, due tocause. Prerequisite:valueshould belong tovarThis is the main reason why we create this class. Record operations to execute for explicit call to explanation.- Specified by:
updateLowerBoundin interfaceIExplanationEngine- Parameters:
var- an integer variablevalue- a valuecause- a cause
-
updateUpperBound
public void updateUpperBound(IntVar var, int value, int old, ICause cause)
Explain the removal of ]value,old] fromvar, due tocause. Prerequisite:valueshould belong tovarThis is the main reason why we create this class. Record operations to execute for explicit call to explanation.- Specified by:
updateUpperBoundin interfaceIExplanationEngine- Parameters:
var- an integer variablevalue- a valuecause- a cause
-
instantiateTo
public void instantiateTo(IntVar var, int val, ICause cause, int oldLB, int oldUB)
Explain the assignment tovalofvardue tocause. This is the main reason why we create this class. Record operations to execute for explicit call to explanation.- Specified by:
instantiateToin interfaceIExplanationEngine- Parameters:
var- an integer variableval- a valuecause- a causeoldLB- previous lboldUB- previous ub
-
activePropagator
public void activePropagator(BoolVar var, Propagator propagator)
Explain the activation of a propagator involved in a reified constraint- Specified by:
activePropagatorin interfaceIExplanationEngine- Parameters:
var- the reified variablepropagator- the propagator to awake.
-
undo
public void undo()
Undo the last operation done- Specified by:
undoin interfaceIExplanationEngine
-
-