Class UnaryClausesDatabase
- java.lang.Object
-
- org.jacop.jasat.core.clauses.AbstractClausesDatabase
-
- org.jacop.jasat.core.clauses.UnaryClausesDatabase
-
- All Implemented Interfaces:
ClauseDatabaseInterface,SolverComponent
public final class UnaryClausesDatabase extends AbstractClausesDatabase
A database for unit clauses (length 1). It only accepts those.- Version:
- 4.8
-
-
Field Summary
Fields Modifier and Type Field Description private int[]clausesprivate intcurrentIndexprivate static intINITIAL_SIZETODO: Radek, just curiousprivate intnumRemoved-
Fields inherited from class org.jacop.jasat.core.clauses.AbstractClausesDatabase
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 Summary
Constructors Constructor Description UnaryClausesDatabase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddClause(int[] clause, boolean isModel)TODO: Radek,voidassertLiteral(int literal)It informs the ClausesDatabase that this literal is set, so that it can perform unit propagation.voidbackjump(int level)Do everything needed to return to the given level.booleancanRemove(int clauseId)It tells if the implementation of ClausesDatabase can remove clauses or notintrateThisClause(int[] clause)Indicates how much this database is optimized for this clause.voidremoveClause(int clauseId)It removes the clause which unique ID is @param clauseId.MapClauseresolutionWith(int clauseId, MapClause clause)It returns the clause obtained by resolution between clauseIndex and clause.intsize()number of clauses in the databasevoidtoCNF(java.io.BufferedWriter output)It creates a CNF description of the clauses stored in this database.java.lang.StringtoString(java.lang.String prefix)prints the content of the database in a nice way, each line being prefixed with-
Methods inherited from class org.jacop.jasat.core.clauses.AbstractClausesDatabase
addWatch, doesWatch, ensureWatch, getDatabaseIndex, indexToUniqueId, initialize, removeWatch, setDatabaseIndex, swap, toString, uniqueIdToIndex
-
-
-
-
Field Detail
-
INITIAL_SIZE
private static final int INITIAL_SIZE
TODO: Radek, just curioushow is the conflict raised by this database? how is the propagation done? After clauses are added, how is the unit propagation taking place?
=> conflicts are only raised when a clause is added, because either we propagate the only literal of the clause, either it is false (=> conflict) However, a good question is: what if we add such a clause at level > 0 and some backjump goes under this level, maybe we should watch literals after all. ==> FIXME
Is the addClause a right place to do above? Would it cause troubles for consistency of state of different components?
- See Also:
- Constant Field Values
-
clauses
private int[] clauses
-
currentIndex
private int currentIndex
-
numRemoved
private int numRemoved
-
-
Method Detail
-
addClause
public int addClause(int[] clause, boolean isModel)TODO: Radek,why would you bother with having any code for removal when nothing is being actually removed. Why not disallow removal altogether and call it StaticUnaryClausesDatabase?
- Parameters:
clause- the clause to addisModel- defined if the clause is model clause- Returns:
- the unique ID referring to the clause
-
removeClause
public void removeClause(int clauseId)
Description copied from interface:ClauseDatabaseInterfaceIt removes the clause which unique ID is @param clauseId.- Parameters:
clauseId- clause id
-
canRemove
public boolean canRemove(int clauseId)
Description copied from interface:ClauseDatabaseInterfaceIt tells if the implementation of ClausesDatabase can remove clauses or not- Parameters:
clauseId- the unique Id of the clause- Returns:
- true iff removal of clauses is possible
-
resolutionWith
public MapClause resolutionWith(int clauseId, MapClause clause)
Description copied from interface:ClauseDatabaseInterfaceIt returns the clause obtained by resolution between clauseIndex and clause. It will also modify in place the given SetClause (avoid allocating).- Parameters:
clauseId- the unique id of the clauseclause- an explanation clause that is modified by resolution- Returns:
- the clause obtained by resolution
-
backjump
public void backjump(int level)
Description copied from interface:ClauseDatabaseInterfaceDo everything needed to return to the given level.- Parameters:
level- the level to return to. Must be < solver.getCurrentLevel().
-
assertLiteral
public void assertLiteral(int literal)
Description copied from interface:ClauseDatabaseInterfaceIt informs the ClausesDatabase that this literal is set, so that it can perform unit propagation.- Parameters:
literal- the literal that is set
-
rateThisClause
public int rateThisClause(int[] clause)
Description copied from class:AbstractClausesDatabaseIndicates how much this database is optimized for this clause. The Database that gives the higher rank will get the clause.- Specified by:
rateThisClausein classAbstractClausesDatabase- Parameters:
clause- a clause to rate- Returns:
- a non negative integer indicating how much the database is interested in this clause
-
toString
public java.lang.String toString(java.lang.String prefix)
Description copied from class:AbstractClausesDatabaseprints the content of the database in a nice way, each line being prefixed with- Overrides:
toStringin classAbstractClausesDatabase- Parameters:
prefix- prefix for printed line- Returns:
- a String representation of the database
-
size
public int size()
Description copied from class:AbstractClausesDatabasenumber of clauses in the database- Specified by:
sizein interfaceClauseDatabaseInterface- Specified by:
sizein classAbstractClausesDatabase- Returns:
- the number of clauses in the database
-
toCNF
public void toCNF(java.io.BufferedWriter output) throws java.io.IOExceptionDescription copied from class:AbstractClausesDatabaseIt creates a CNF description of the clauses stored in this database.- Specified by:
toCNFin interfaceClauseDatabaseInterface- Specified by:
toCNFin classAbstractClausesDatabase- Parameters:
output- it specifies the target to which the description will be written.- Throws:
java.io.IOException- execption from java.io package
-
-