org.chocosolver.solver.ICause Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of choco-solver Show documentation
Show all versions of choco-solver Show documentation
Open-source constraint solver.
/*
* This file is part of choco-solver, http://choco-solver.org/
*
* Copyright (c) 2019, IMT Atlantique. All rights reserved.
*
* Licensed under the BSD 4-clause license.
*
* See LICENSE file in the project root for full license information.
*/
package org.chocosolver.solver;
import org.chocosolver.solver.exception.SolverException;
import org.chocosolver.solver.learn.ExplanationForSignedClause;
import org.chocosolver.solver.learn.Implications;
import org.chocosolver.solver.variables.IntVar;
import org.chocosolver.util.objects.ValueSortedMap;
import java.util.function.Consumer;
/**
* This interface describes services of smallest element which can act on variables.
* As an example, propagator is a cause because it filters values from variable domain.
* So do decision, objective manager, etc.
* It has an impact on domain variables and so it can fails.
*
* @author Charles Prud'homme
* @since 26 oct. 2010
*/
public interface ICause {
/**
* Clausal explanation for this cause.
*
* This method must filled explanations with inferred literals.
* These literals are inferred from the analysis of
* (a subset of) conflicting nodes stored in front,
* the implication graph ig and the current node in conflict,
* not yet contained in front.
*
*
* Optionally, this method can update front by looking for a predecessor of any node
* that seems more relevant than the declared one.
*
* @param explanation explanation to compute
* @param front ordered map of (variable,node> in the conflict frontier of the implication graph.
* @param implicationGraph an implication graph
* @param pivot the pivot node out of front
*/
default void explain(ExplanationForSignedClause explanation,
ValueSortedMap front,
Implications implicationGraph,
int pivot){
throw new SolverException("Undefined explain(...) method for " + this.getClass().getSimpleName());
}
/**
* Apply an action on each variable declared on the scope of this cause, if any.
* @param action action to perform on each variable declared in this cause.
*/
default void forEachIntVar(Consumer action){
throw new SolverException("Undefined forEachIntVar(...) method for " + this.getClass().getSimpleName());
}
}