public final class Core extends Object implements SolverComponent
This implements interfaces for being manipulated from the outside, and from its components
Modifier and Type | Field and Description |
---|---|
AssertionListener[] |
assertionModules |
long |
assignmentNum |
BackjumpListener[] |
backjumpModules |
ClauseListener[] |
clauseModules |
Config |
config |
ConflictLearning |
conflictLearning |
ConflictListener[] |
conflictModules |
int |
currentLevel |
int |
currentState |
DatabasesStore |
dbStore |
MapClause |
explanationClause |
ExplanationListener[] |
explanationModules |
ForgetListener[] |
forgetModules |
boolean |
isStopped |
PrintStream |
logStream |
int |
numAssertionModules |
int |
numBackjumpModules |
int |
numClauseModules |
int |
numConflictModules |
int |
numExplanationModules |
int |
numForgetModules |
int |
numPropagateModules |
int |
numRestartModules |
int |
numSolutionModules |
int |
numStartStopModules |
MemoryPool |
pool |
PropagateListener[] |
propagateModules |
BackjumpListener[] |
restartModules |
SearchModule |
search |
SolutionListener[] |
solutionModules |
StartStopListener[] |
startStopModules |
Timer |
timer |
IntQueue |
toPropagate |
Trail |
trail |
int |
verbosity |
Constructor and Description |
---|
Core()
initializes the solver with a default configuration.
|
Core(Config config)
creates the solver, which in turn creates all inner components and
connect them together.
|
Modifier and Type | Method and Description |
---|---|
void |
addComponent(SolverComponent module)
give the module access to the whole class, even if the solver is only
known as a ISatSolver
|
int |
addModelClause(int[] clause)
same as previous, add the clause as a model clause
|
int |
addModelClause(IntVec clause)
adds a clause to the solver
|
void |
assertLiteral(int literal,
int newLevel)
decides a single step of search by setting the value of a variable
|
void |
backjumpToLevel(int level)
tells the SAT-solver to backtrack to the given level.
|
boolean |
canRemove(int clauseId)
predicate : can we remove the clause without breaking the correctness
of the solver ?
|
void |
forget()
removes the less useful learnt clauses to free memory
|
int |
getFreshVariable()
gets a fresh variable that one can use for example
for lazy clause generation.
|
int |
getLevelToBackjump()
Computes at which level we should backjump to solve the conflict.
|
int |
getLevelToBackjump(MapClause explanationClause) |
int |
getManyFreshVariables(int number)
get several new variables at once, more efficiently than
running getFreshVariable() @param number times.
|
int |
getMaxVariable() |
int |
getReturnCode()
before exiting, we must know which return code we must give
|
long |
getTime(String s)
get the time associated with given mark, or 0 if none
|
long |
getTimeDiff(String s)
gets the time difference (in ms) between now and the mark
|
boolean |
hasSolution() |
void |
initialize(Core core)
initializes the component with the given solver.
|
void |
logc(int level,
String s,
Object... args)
logs less important messages, in comments
|
void |
logc(String s,
Object... args)
logs important messages in comments
|
void |
markTime(String s)
remembers that @param s is associated with the current time (in ms)
|
void |
printSolution()
prints the current solution on standard output
|
boolean |
removeClause(int clauseId)
removes the clause with unique Id, if possible
|
void |
restart()
make a restart, that is, restart search from level 0.
|
void |
setMaxVariable(int maxVariable)
Tells the solver what is the greatest variable in the problem
|
void |
start()
notify all modules that we start
|
void |
stop()
notify all modules that we stop
|
String |
toString() |
void |
triggerBackjumpEvent(int level)
triggers an event to backjump
|
void |
triggerConflictEvent(MapClause clause)
triggers a conflict.
|
void |
triggerIdleEvent()
tells the SAT-solver to return to a normal state after a conflict has
been solved (backjump or restart)
|
void |
triggerLearnEvent(MapClause clauseToLearn)
triggers an event of learning
|
void |
triggerPropagateEvent(int literal,
int unitClauseId)
triggers a unit propagation event.
|
void |
triggerRestartEvent()
triggers an event of restart
|
void |
triggerSatEvent()
to trigger if the problem is found to be satisfiable
|
void |
triggerUnsatEvent()
to trigger if the problem is found to be not satisfiable
|
void |
unitPropagate()
performs propagation on all unit clauses until either :
- no unit clause remains
- a conflict occurs
|
public IntQueue toPropagate
public MapClause explanationClause
public long assignmentNum
public boolean isStopped
public Timer timer
public MemoryPool pool
public DatabasesStore dbStore
public Trail trail
public SearchModule search
public Config config
public int verbosity
public PrintStream logStream
public int currentLevel
public int currentState
public ConflictLearning conflictLearning
public AssertionListener[] assertionModules
public BackjumpListener[] backjumpModules
public ConflictListener[] conflictModules
public PropagateListener[] propagateModules
public SolutionListener[] solutionModules
public ForgetListener[] forgetModules
public ClauseListener[] clauseModules
public ExplanationListener[] explanationModules
public StartStopListener[] startStopModules
public BackjumpListener[] restartModules
public int numAssertionModules
public int numBackjumpModules
public int numConflictModules
public int numPropagateModules
public int numSolutionModules
public int numForgetModules
public int numClauseModules
public int numExplanationModules
public int numStartStopModules
public int numRestartModules
public Core(Config config)
config
- configuration for the solverpublic Core()
public int addModelClause(IntVec clause)
clause
- the clause to addpublic int addModelClause(int[] clause)
clause
- the clause to addpublic boolean canRemove(int clauseId)
clauseId
- the unique Id of the clausepublic boolean removeClause(int clauseId)
clauseId
- the unique Id of the clause to removepublic void assertLiteral(int literal, int newLevel)
literal
- the literal to set truenewLevel
- the current search levelpublic void backjumpToLevel(int level)
level
- the level to return topublic void restart()
public void start()
public void stop()
public void forget()
public int getLevelToBackjump()
public int getLevelToBackjump(MapClause explanationClause)
public int getFreshVariable()
public int getManyFreshVariables(int number)
number
- the number of fresh variables we wantpublic void setMaxVariable(int maxVariable)
maxVariable
- the new maximum variable. Must not be lower than
solver.getMaxVariable().public int getMaxVariable()
public void addComponent(SolverComponent module)
module
- the module to add to the solverpublic final void unitPropagate()
public void triggerIdleEvent()
public void triggerLearnEvent(MapClause clauseToLearn)
clauseToLearn
- the clause which is learntpublic void triggerConflictEvent(MapClause clause)
clause
- an unsatisfiable clause.public void triggerPropagateEvent(int literal, int unitClauseId)
literal
- the unique unset literal, which must be true for the
clause to be satisfiedunitClauseId
- the unique id of the unit clause that propagatespublic void triggerBackjumpEvent(int level)
level
- the level to backjump topublic void triggerRestartEvent()
public void triggerSatEvent()
public void triggerUnsatEvent()
public final void markTime(String s)
s
- the mark of current timepublic final long getTime(String s)
s
- the markpublic final long getTimeDiff(String s)
s
- the markpublic final void logc(String s, Object... args)
s
- the messageargs
- the arguments for the messagepublic final void logc(int level, String s, Object... args)
level
- verbosity levels
- the messageargs
- the arguments for the messagepublic final boolean hasSolution()
public final void printSolution()
public final int getReturnCode()
public void initialize(Core core)
SolverComponent
initialize
in interface SolverComponent
core
- core component to initializeCopyright © 2022. All rights reserved.