Class 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 Detail

      • ExplanationEngine

        public ExplanationEngine​(Model model,
                                 boolean partialExplanationsOn,
                                 boolean recordCauses)
        Create an explanation engine based on a rule store
        Parameters:
        model - a model
        partialExplanationsOn - set to true to enable partial explanations, false otherwise
        recordCauses - 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:
        isSaveCauses in interface IExplanationEngine
        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:
        explain in interface IExplanationEngine
        Parameters:
        cex - contradiction to explain
        Returns:
        an explanation (set of decisions and propagators).
      • makeExplanation

        public Explanation makeExplanation​(boolean saveCauses)
        Specified by:
        makeExplanation in interface IExplanationEngine
        Parameters:
        saveCauses - set to true if causes need to be stored
        Returns:
        an empty explanation, ready to be filled up
      • storeDecisionExplanation

        public void storeDecisionExplanation​(Decision decision,
                                             Explanation explanation)
        Store a decision refutation, for future reasoning.
        Specified by:
        storeDecisionExplanation in interface IExplanationEngine
        Parameters:
        decision - refuted decision
        explanation - 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:
        moveDecisionRefutation in interface IExplanationEngine
        Parameters:
        decision - a decision
        to - the new index
      • freeDecisionExplanation

        public void freeDecisionExplanation​(Decision decision)
        Free the explanation related to the decision (for efficiency purpose only)
        Specified by:
        freeDecisionExplanation in interface IExplanationEngine
        Parameters:
        decision - the decision which is going to be forgotten
      • removeValue

        public void removeValue​(IntVar var,
                                int val,
                                ICause cause)
        Explain the removal of the val from var, due to cause. This is the main explanation why we create this class. Record operations to execute for explicit call to explanation.
        Specified by:
        removeValue in interface IExplanationEngine
        Parameters:
        var - an integer variable
        val - a value
        cause - a cause
      • updateLowerBound

        public void updateLowerBound​(IntVar var,
                                     int value,
                                     int old,
                                     ICause cause)
        Explain the removal of [old,value[ from var, due to cause.

        Prerequisite: value should belong to var This is the main reason why we create this class. Record operations to execute for explicit call to explanation.

        Specified by:
        updateLowerBound in interface IExplanationEngine
        Parameters:
        var - an integer variable
        value - a value
        cause - a cause
      • updateUpperBound

        public void updateUpperBound​(IntVar var,
                                     int value,
                                     int old,
                                     ICause cause)
        Explain the removal of ]value,old] from var, due to cause.

        Prerequisite: value should belong to var This is the main reason why we create this class. Record operations to execute for explicit call to explanation.

        Specified by:
        updateUpperBound in interface IExplanationEngine
        Parameters:
        var - an integer variable
        value - a value
        cause - a cause
      • instantiateTo

        public void instantiateTo​(IntVar var,
                                  int val,
                                  ICause cause,
                                  int oldLB,
                                  int oldUB)
        Explain the assignment to val of var due to cause. This is the main reason why we create this class. Record operations to execute for explicit call to explanation.
        Specified by:
        instantiateTo in interface IExplanationEngine
        Parameters:
        var - an integer variable
        val - a value
        cause - a cause
        oldLB - previous lb
        oldUB - previous ub
      • activePropagator

        public void activePropagator​(BoolVar var,
                                     Propagator propagator)
        Explain the activation of a propagator involved in a reified constraint
        Specified by:
        activePropagator in interface IExplanationEngine
        Parameters:
        var - the reified variable
        propagator - the propagator to awake.