public final class DomainClausesDatabase extends AbstractClausesDatabase implements WrapperComponent
This database must be added in the SAT solver (ideally at first position) and linked to the wrapper; it can then propagate literals that have a CP semantic with respect to their meaning about domains.
CLAUSE_RATE_AVERAGE, CLAUSE_RATE_I_WANT_THIS_CLAUSE, CLAUSE_RATE_LOW, CLAUSE_RATE_UNSUPPORTED, CLAUSE_RATE_WELL_SUPPORTED, core, databaseIndex, dbStore, MINIMUM_VAR_WATCH_SIZE, pool, trail, watchLists
Constructor and Description |
---|
DomainClausesDatabase() |
Modifier and Type | Method and Description |
---|---|
int |
addClause(int[] clause,
boolean isModel)
It adds a clause to the database.
|
void |
assertLiteral(int assertedLiteral)
this is responsible for propagating literals within the SAT solver
to keep domain constraints coherent.
|
void |
backjump(int level)
Do everything needed to return to the given level.
|
boolean |
canRemove(int clauseId)
It tells if the implementation of ClausesDatabase can remove clauses or not
|
void |
initialize(SatWrapper wrapper)
connect the component to the wrapper
|
void |
propagate(int literal,
int assertedLiteral)
propagates the literal directly in the SAT solver
|
int |
rateThisClause(int[] clause)
Indicates how much this database is optimized for this clause.
|
void |
removeClause(int clauseId)
It removes the clause which unique ID is @param clauseId.
|
MapClause |
resolutionWith(int clauseIndex,
MapClause clause)
to get a real clause to resolve with, we seek for the clause at the
origin of the propagation.
|
int |
size()
number of clauses in the database
|
void |
toCNF(BufferedWriter output)
It creates a CNF description of the clauses stored in this database.
|
String |
toString(String prefix)
prints the content of the database in a nice way, each line being
prefixed with
|
addWatch, doesWatch, ensureWatch, getDatabaseIndex, indexToUniqueId, initialize, removeWatch, setDatabaseIndex, swap, toString, uniqueIdToIndex
public void assertLiteral(int assertedLiteral)
assertLiteral
in interface ClauseDatabaseInterface
assertedLiteral
- the literal that is setpublic void propagate(int literal, int assertedLiteral)
literal
- the literal to propagateassertedLiteral
- the literal that has been the origin of the propagationpublic MapClause resolutionWith(int clauseIndex, MapClause clause)
resolutionWith
in interface ClauseDatabaseInterface
clauseIndex
- the unique id of the clauseclause
- an explanation clause that is modified by resolutionpublic void backjump(int level)
ClauseDatabaseInterface
backjump
in interface ClauseDatabaseInterface
level
- the level to return to. Must be < solver.getCurrentLevel().public int rateThisClause(int[] clause)
AbstractClausesDatabase
rateThisClause
in class AbstractClausesDatabase
clause
- a clause to ratepublic int size()
AbstractClausesDatabase
size
in interface ClauseDatabaseInterface
size
in class AbstractClausesDatabase
public int addClause(int[] clause, boolean isModel)
ClauseDatabaseInterface
addClause
in interface ClauseDatabaseInterface
clause
- the clause to addisModel
- defined if the clause is model clausepublic void removeClause(int clauseId)
ClauseDatabaseInterface
removeClause
in interface ClauseDatabaseInterface
clauseId
- clause idpublic boolean canRemove(int clauseId)
ClauseDatabaseInterface
canRemove
in interface ClauseDatabaseInterface
clauseId
- the unique Id of the clausepublic String toString(String prefix)
AbstractClausesDatabase
toString
in class AbstractClausesDatabase
prefix
- prefix for printed linepublic void initialize(SatWrapper wrapper)
WrapperComponent
initialize
in interface WrapperComponent
wrapper
- the wrapperpublic void toCNF(BufferedWriter output) throws IOException
AbstractClausesDatabase
toCNF
in interface ClauseDatabaseInterface
toCNF
in class AbstractClausesDatabase
output
- it specifies the target to which the description will be written.IOException
- execption from java.io packageCopyright © 2022. All rights reserved.