|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsavi.alg.sat3.Formula
public class Formula
Class representing boolean formula in CNF.
Field Summary | |
---|---|
protected Clause[] |
clauses
list of clauses in formula |
protected int |
varsCount
number of variables in formula |
Constructor Summary | |
---|---|
Formula(java.io.BufferedReader br)
Creates a new instance of Formula, read it from stream (expecting stream with DIMACS format). |
|
Formula(int countClauses,
int varsCount)
Creates a new instance of Formula, randomly generate clauses from given parameters. |
Method Summary | |
---|---|
int |
clausesCount()
Return count of clauses. |
Formula |
clone()
Creates and returns a copy of this object. |
int |
countSatisfactClauses(boolean[] vars)
Return number of satisfied clauses. |
Clause[] |
getClauses()
Return number of clauses. |
boolean |
isSatisfact(boolean[] vars)
Return true if formula is satisfied with given variables assignment. |
double |
percentualSatisfact(boolean[] vars)
Return percentual satisfaction of the formula with given variables assignment. 0 means no one clause is satisfied, 1 means formula is satisfied |
protected void |
readFromStream(java.io.BufferedReader br)
Read formula from stream (expecting stream with DIMACS format). |
void |
reduceNumberOfClauses(double finalPercent)
Reduce number of clauses in the formula. |
int |
varsCount()
Return count of variables. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Clause[] clauses
protected int varsCount
Constructor Detail |
---|
public Formula(int countClauses, int varsCount)
countClauses
- number of clauses in formulavarsCount
- number of variables in formulapublic Formula(java.io.BufferedReader br) throws WrongInputFormulaData
br
- stream with buffer reader
WrongInputFormulaData
- syntax error exceptionMethod Detail |
---|
public boolean isSatisfact(boolean[] vars)
true
if formula is satisfied with given variables assignment.
vars
- variables assignment
true
if formula is satisfiedpublic double percentualSatisfact(boolean[] vars)
vars
- variables assignment
public int countSatisfactClauses(boolean[] vars)
vars
- variables assignment
public int varsCount()
public int clausesCount()
public void reduceNumberOfClauses(double finalPercent) throws WrongFormulaException
finalPercent
- percentual count, how many clauses should remain
WrongFormulaException
- the formula is reduced too manyprotected void readFromStream(java.io.BufferedReader br) throws WrongInputFormulaData
br
- stream with buffer reader
WrongInputFormulaData
- syntax error exceptionpublic Clause[] getClauses()
public Formula clone()
clone
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |