public final class DatabasesStore extends Object implements SolverComponent, ClauseDatabaseInterface
Modifier and Type | Field and Description |
---|---|
Core |
core |
int |
currentIndex |
AbstractClausesDatabase[] |
databases |
Constructor and Description |
---|
DatabasesStore() |
Modifier and Type | Method and Description |
---|---|
int |
addClause(int[] clause,
boolean isModelClause)
It adds a clause to the database.
|
void |
addDatabase(AbstractClausesDatabase database)
Adds a ClausesDatabase to the Store
|
void |
assertLiteral(int literal)
tells all databases that the literal is set, for unit propagation.
|
void |
backjump(int level)
tells all databases to backjump at this level
|
boolean |
canRemove(int clauseId)
It tells if the implementation of ClausesDatabase can remove clauses or not
|
int |
indexesToUniqueId(int clauseIndex,
int databaseIndex)
It gets a unique id from a clause index, relative to a database,
and a database index.
|
void |
initialize(Core core)
initializes the component with the given solver.
|
void |
removeClause(int clauseId)
removes this clause from the database it belongs to.
|
MapClause |
resolutionWith(int clauseId,
MapClause clause)
It returns the clause obtained by resolution between clauseIndex and clause.
|
int |
size()
the number of clauses in all databases
|
void |
toCNF(BufferedWriter output)
It writes the clauses of the databases in cnf format to the specified
writer.
|
String |
toString() |
int |
uniqueIdToDb(int clauseId)
returns the ClausesDatabase associated with this clauseId
|
int |
uniqueIdToIndex(int clauseId)
Removes the database index of the clause, to get a real clause index.
|
public AbstractClausesDatabase[] databases
public int currentIndex
public Core core
public int addClause(int[] clause, boolean isModelClause)
ClauseDatabaseInterface
addClause
in interface ClauseDatabaseInterface
clause
- the clause to addisModelClause
- defined if the clause is model clausepublic boolean canRemove(int clauseId)
ClauseDatabaseInterface
canRemove
in interface ClauseDatabaseInterface
clauseId
- the unique Id of the clausepublic void removeClause(int clauseId)
removeClause
in interface ClauseDatabaseInterface
clauseId
- the id of the clause to be deletedpublic MapClause resolutionWith(int clauseId, MapClause clause)
ClauseDatabaseInterface
resolutionWith
in interface ClauseDatabaseInterface
clauseId
- the unique id of the clauseclause
- an explanation clause that is modified by resolutionpublic void addDatabase(AbstractClausesDatabase database)
database
- the database to addpublic int size()
size
in interface ClauseDatabaseInterface
public void backjump(int level)
backjump
in interface ClauseDatabaseInterface
level
- the level to backjump topublic final void assertLiteral(int literal)
assertLiteral
in interface ClauseDatabaseInterface
literal
- the literalpublic final int uniqueIdToDb(int clauseId)
clauseId
- a unique clause Idpublic final int uniqueIdToIndex(int clauseId)
clauseId
- the unique clauseIdpublic final int indexesToUniqueId(int clauseIndex, int databaseIndex)
clauseIndex
- clause indexdatabaseIndex
- database indexpublic void initialize(Core core)
SolverComponent
initialize
in interface SolverComponent
core
- core component to initializepublic void toCNF(BufferedWriter output) throws IOException
ClauseDatabaseInterface
toCNF
in interface ClauseDatabaseInterface
output
- the output writer to which all the clauses will be written to.IOException
- execption from java.io packageCopyright © 2022. All rights reserved.