Class LearnExplained
- java.lang.Object
-
- org.chocosolver.solver.search.loop.learn.LearnExplained
-
- All Implemented Interfaces:
Learn
- Direct Known Subclasses:
LearnCBJ,MoveLearnBinaryTDR
public class LearnExplained extends Object implements Learn
An abstract class to deal with explanation-based learning. Created by cprudhom on 05/11/2015. Project: choco.
-
-
Field Summary
Fields Modifier and Type Field Description protected ExplanationlastExplanationThe last explanation computed.protected IExplanationEnginemExplainerThe explanation engine, which computes and returns explanation of a state.protected ModelmModelThe solver to explain.
-
Constructor Summary
Constructors Constructor Description LearnExplained(Model mModel, boolean partialExplanationsOn, boolean recordCauses)Equips the solver with an explanation engine, which is able to explain failures and solutions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidforget(Solver solver)Forget some pieces of knowledge.ExplanationgetLastExplanation()Return the explanation of the last conflictvoidonFailure(Solver solver)Actions to do when a failure is met.voidonSolution(Solver solver)Actions to do when a solution is found.voidrecord(Solver solver)Validate and record a new piece of knowledge, that is, the current position is a dead-end.
-
-
-
Field Detail
-
mModel
protected final Model mModel
The solver to explain.
-
mExplainer
protected final IExplanationEngine mExplainer
The explanation engine, which computes and returns explanation of a state.
-
lastExplanation
protected Explanation lastExplanation
The last explanation computed.
-
-
Constructor Detail
-
LearnExplained
public LearnExplained(Model mModel, boolean partialExplanationsOn, boolean recordCauses)
Equips the solver with an explanation engine, which is able to explain failures and solutions.- Parameters:
mModel- the solver to equippartialExplanationsOn- set to true to enable partial explanations, false otherwiserecordCauses- set to true to record causes in explanations, false otherwise- Throws:
SolverException- if views are enabled. Views provide incomplete explanation.
-
-
Method Detail
-
record
public void record(Solver solver)
Description copied from interface:LearnValidate and record a new piece of knowledge, that is, the current position is a dead-end.
-
forget
public void forget(Solver solver)
Description copied from interface:LearnForget some pieces of knowledge.
-
onSolution
public void onSolution(Solver solver)
Actions to do when a solution is found. By default, it records the basic explanation related to the refutation of the last decision.
-
onFailure
public void onFailure(Solver solver)
Actions to do when a failure is met.
-
getLastExplanation
public final Explanation getLastExplanation()
Return the explanation of the last conflict- Returns:
- an explanation
-
-