public final class SatWrapper extends Constraint implements ConflictListener, ExplanationListener, StartStopListener, SolutionListener, Stateful, SatisfiedPresent
Modifier and Type | Field and Description |
---|---|
ActivityModule |
activity |
HeuristicAssertionModule |
assertionModule |
SatCPBridge[] |
boolVarToDomains |
Core |
core |
Integer[] |
cpToSatLevels |
DomainClausesDatabase |
domainDatabase |
DomainTranslator |
domainTranslator |
int |
levelToBackjumpTo |
MemoryPool |
pool |
Set<IntVar> |
registeredVars |
SatChangesListener |
satChangesListener |
Integer[] |
satToCpLevels |
Store |
store |
int |
verbosity |
atomicExecution, consistencyPruningEvents, constraintScope, earlyTerminationOK, increaseWeight, numberId, scope, trace
queueIndex
Constructor and Description |
---|
SatWrapper()
creates everything in the right order
|
Modifier and Type | Method and Description |
---|---|
void |
addModelClause(Collection<Integer> clause)
add model (globally valid) clause to solver, in a delayed fashion
|
void |
addModelClause(int[] clause) |
void |
addSolverComponent(SolverComponent module)
to add some module to the solver
|
void |
addWrapperComponent(WrapperComponent module)
add a component
|
Set<Var> |
arguments()
It returns the variables in a scope of the constraint.
|
int |
boolVarToCpValue(int literal)
transform a literal 'x=v' into a value 'v' for some CP variable
|
IntVar |
boolVarToCpVar(int literal)
get the IntVar back from a literal
|
SatCPBridge |
boolVarToDomain(int literal)
returns the CpVarDomain associated with this literal
|
void |
consistency(Store store)
The point where all operations are effectively done in the SAT solver,
until no operation remains or a conflict occurs
|
int |
cpVarToBoolVar(IntVar variable,
int value,
boolean isEquality)
given a CP variable and a value, retrieve the associated boolean literal
for either 'variable = value' or either 'variable <= value'
|
void |
forget()
asks the solver to forget useless clauses, to free memory
|
int |
getConsistencyPruningEvent(Var var)
It retrieves the pruning event which causes reevaluation of the
constraint.
|
int |
getDefaultConsistencyPruningEvent() |
int |
getMostActiveLiteral()
asks the solver for which literal is the most active.
|
String |
id()
It gives the id string of a constraint.
|
void |
impose(Constraint constraint)
add the constraint to the wrapper (ie, constraint.imposeToSat(this))
|
void |
impose(Store store)
It imposes the constraint in a given store.
|
void |
increaseWeight()
It increases the weight of the variables in the constraint scope.
|
void |
initialize(Core core)
initializes the component with the given solver.
|
boolean |
isEqualityBoolVar(int literal)
checks if the boolean variable represents an assertion 'x=v' or 'x<=v'
|
boolean |
isVarLiteral(int literal)
checks if this literal corresponds to some CP variable
|
boolean |
log(Object o,
String format,
Object... args)
log method, similar to printf.
|
void |
onConflict(MapClause clause,
int level)
wrapper listens for conflicts.
|
void |
onExplain(MapClause explanation)
wrapper listens for explanations, to know how deep to backtrack
|
void |
onSolution(boolean satisfiable)
a handler called when a solution is found.
|
void |
onStart()
called when the solver starts search.
|
void |
onStop()
called when the solver stop search, for any reason
|
void |
queueVariable(int level,
Var var)
This is a function called to indicate which variable in a scope of
constraint has changed.
|
void |
register(IntVar result) |
void |
register(IntVar variable,
boolean translate)
registers the variable so that we can use it in SAT solver
|
void |
removeConstraint()
It removes the constraint by removing this constraint from all variables.
|
void |
removeLevel(int cpLevel)
when the CP solver decides to remove a level, the wrapper must force
the SAT solver to backtrack accordingly, to keep mappings between the
two search trees consistent.
|
boolean |
satisfied()
It checks if the constraint is satisfied.
|
String |
showClauseMeaning(Iterable<Integer> literals) |
String |
showLiteralMeaning(int literal)
(for debug) show what a literal means
|
void |
toCNF(BufferedWriter output) |
String |
toString()
It produces a string representation of a constraint state.
|
afc, cleanAfterFailure, decompose, getGuideConstraint, getGuideValue, getGuideVariable, grounded, grounded, impose, imposeDecomposition, intArrayToString, long2int, numberArgs, requiresMonotonicity, setConsistencyPruningEvent, setConstraintScope, setScope, setScope, setScope, setScope, setScope, setWatchedVariableGrounded, supplyGuideFeedback, updateAFC, watchedVariableGrounded
auxiliaryVariables, checkInput, checkInput, checkInputForDuplication, checkInputForDuplicationSkipSingletons, checkInputForNullness, checkInputForNullness, checkInputForNullness, derivative, getDubletonsSkipSingletons, imposeDecomposition
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isStateful
public Core core
public ActivityModule activity
public HeuristicAssertionModule assertionModule
public SatCPBridge[] boolVarToDomains
public SatChangesListener satChangesListener
public Store store
public MemoryPool pool
public DomainClausesDatabase domainDatabase
public DomainTranslator domainTranslator
public int levelToBackjumpTo
public Integer[] satToCpLevels
public Integer[] cpToSatLevels
public int verbosity
public void register(IntVar result)
public void register(IntVar variable, boolean translate)
variable
- the CP IntVar variabletranslate
- indicate whether to use == or <=public void consistency(Store store)
consistency
in class Constraint
store
- constraint store within which the constraint consistency is being checked.public void onConflict(MapClause clause, int level)
onConflict
in interface ConflictListener
clause
- the conflict (unsatisfiable) clauselevel
- the level at which the conflict occurredpublic void onExplain(MapClause explanation)
onExplain
in interface ExplanationListener
explanation
- the explanation clausepublic void onSolution(boolean satisfiable)
SolutionListener
onSolution
in interface SolutionListener
satisfiable
- true when the solution is Satisfiable, false if
it is Unsatisfiable.public void removeLevel(int cpLevel)
removeLevel
in interface Stateful
cpLevel
- the level which is being removed.public void queueVariable(int level, Var var)
Constraint
queueVariable
in class Constraint
level
- the level of the store at which the change has occurred.var
- variable which has changed.public int getConsistencyPruningEvent(Var var)
Constraint
getConsistencyPruningEvent
in class Constraint
var
- variable for which pruning event is retrievedpublic int getDefaultConsistencyPruningEvent()
getDefaultConsistencyPruningEvent
in class Constraint
public int getMostActiveLiteral()
public String showLiteralMeaning(int literal)
literal
- literal for showing its meaningpublic String id()
Constraint
id
in class Constraint
public void removeConstraint()
Constraint
removeConstraint
in class Constraint
public boolean satisfied()
SatisfiedPresent
Implementations of this interface for constraints that are not PrimitiveConstraint may require constraint imposition and consistency check as a requirement to work correctly.
satisfied
in interface SatisfiedPresent
public String toString()
Constraint
toString
in class Constraint
public void increaseWeight()
Constraint
increaseWeight
in class Constraint
public Set<Var> arguments()
Constraint
arguments
in class Constraint
public final void addSolverComponent(SolverComponent module)
module
- the module to addpublic final void addWrapperComponent(WrapperComponent module)
module
- the componentpublic final void forget()
public final void addModelClause(Collection<Integer> clause)
clause
- the clause to addpublic final void addModelClause(int[] clause)
public final void impose(Constraint constraint)
constraint
- the constraint to addpublic final void impose(Store store)
Constraint
impose
in class Constraint
store
- the constraint store to which the constraint is imposed to.public final int cpVarToBoolVar(IntVar variable, int value, boolean isEquality)
variable
- the CP variablevalue
- a value in the range of this variableisEquality
- a boolean, true if we want the literal that stands for
'x=d', false for 'x<=d'public final SatCPBridge boolVarToDomain(int literal)
literal
- the boolean literalpublic final IntVar boolVarToCpVar(int literal)
literal
- the literalpublic final int boolVarToCpValue(int literal)
literal
- literal to be transformed to value it representspublic final boolean isEqualityBoolVar(int literal)
literal
- the boolean literalpublic final boolean isVarLiteral(int literal)
literal
- the literalpublic boolean log(Object o, String format, Object... args)
o
- the object that logs something (use this
)format
- the format string (the message, if no formatting)args
- the arguments to fill in the formatpublic void onStart()
StartStopListener
onStart
in interface StartStopListener
public void onStop()
StartStopListener
onStop
in interface StartStopListener
public void initialize(Core core)
SolverComponent
initialize
in interface SolverComponent
core
- core component to initializepublic void toCNF(BufferedWriter output) throws IOException
IOException
Copyright © 2022. All rights reserved.