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, tracequeueIndex| 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, watchedVariableGroundedauxiliaryVariables, checkInput, checkInput, checkInputForDuplication, checkInputForDuplicationSkipSingletons, checkInputForNullness, checkInputForNullness, checkInputForNullness, derivative, getDubletonsSkipSingletons, imposeDecompositionclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisStatefulpublic 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 Constraintstore - constraint store within which the constraint consistency is being checked.public void onConflict(MapClause clause, int level)
onConflict in interface ConflictListenerclause - the conflict (unsatisfiable) clauselevel - the level at which the conflict occurredpublic void onExplain(MapClause explanation)
onExplain in interface ExplanationListenerexplanation - the explanation clausepublic void onSolution(boolean satisfiable)
SolutionListeneronSolution in interface SolutionListenersatisfiable - true when the solution is Satisfiable, false if
it is Unsatisfiable.public void removeLevel(int cpLevel)
removeLevel in interface StatefulcpLevel - the level which is being removed.public void queueVariable(int level,
Var var)
ConstraintqueueVariable in class Constraintlevel - the level of the store at which the change has occurred.var - variable which has changed.public int getConsistencyPruningEvent(Var var)
ConstraintgetConsistencyPruningEvent in class Constraintvar - variable for which pruning event is retrievedpublic int getDefaultConsistencyPruningEvent()
getDefaultConsistencyPruningEvent in class Constraintpublic int getMostActiveLiteral()
public String showLiteralMeaning(int literal)
literal - literal for showing its meaningpublic String id()
Constraintid in class Constraintpublic void removeConstraint()
ConstraintremoveConstraint in class Constraintpublic boolean satisfied()
SatisfiedPresentImplementations 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 SatisfiedPresentpublic String toString()
ConstrainttoString in class Constraintpublic void increaseWeight()
ConstraintincreaseWeight in class Constraintpublic Set<Var> arguments()
Constraintarguments in class Constraintpublic 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)
Constraintimpose in class Constraintstore - 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()
StartStopListeneronStart in interface StartStopListenerpublic void onStop()
StartStopListeneronStop in interface StartStopListenerpublic void initialize(Core core)
SolverComponentinitialize in interface SolverComponentcore - core component to initializepublic void toCNF(BufferedWriter output) throws IOException
IOExceptionCopyright © 2022. All rights reserved.