- java.lang.Object
-
- org.logicng.solvers.sat.MiniSatStyleSolver
-
- org.logicng.solvers.sat.MiniSat2Solver
-
- org.logicng.knowledgecompilation.dnnf.DnnfMiniSatStyleSolver
-
- All Implemented Interfaces:
DnnfSatSolver
public class DnnfMiniSatStyleSolver extends MiniSat2Solver implements DnnfSatSolver
A variation of the MiniSat solver used during the DNNF compilation process.- Since:
- 2.0.0
- Version:
- 2.0.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.logicng.solvers.sat.MiniSatStyleSolver
MiniSatStyleSolver.ProofInformation
-
-
Field Summary
Fields Modifier and Type Field Description protected intassertionLevelprotected Tristate[]assignmentprotected FormulaFactoryfprotected List<Literal>impliedOperandsprotected LNGIntVectorlastLearntprotected booleannewlyImpliedDirty-
Fields inherited from class org.logicng.solvers.sat.MiniSat2Solver
unitClauses
-
Fields inherited from class org.logicng.solvers.sat.MiniSatStyleSolver
analyzeBtLevel, analyzeStack, analyzeToClear, assumptions, backboneAssumptions, backboneCandidates, backboneMap, canceledByHandler, ccminMode, claInc, clauseDecay, clauses, clausesLiterals, computingBackbone, config, conflict, handler, idx2name, incremental, learnts, learntsizeAdjustCnt, learntsizeAdjustConfl, learntsizeAdjustInc, learntsizeAdjustStartConfl, learntsizeFactor, learntsizeInc, learntsLiterals, LIT_UNDEF, maxLearnts, model, name2idx, ok, orderHeap, pgOriginalClauses, pgProof, qhead, restartFirst, restartInc, seen, selectionOrder, selectionOrderIdx, shouldRemoveSatsisfied, simpDBAssigns, simpDBProps, trail, trailLim, varDecay, varInc, vars, watches
-
-
Constructor Summary
Constructors Constructor Description DnnfMiniSatStyleSolver(FormulaFactory f, int numberOfVariables)Constructs a new DNNF MiniSat solver with the given number of variables.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Formula formula)Adds a formula to the solver.booleanassertCdLiteral()Enqueues the literal which was computed by the latest backtracking, performs UP and returnfalseif UP finds a contradiction, otherwisetrue.booleanatAssertionLevel()Returnstrueif the current decision level was previously selected as backtrack level.protected voidcancelUntil(int level)booleandecide(int var, boolean phase)Performs a decision of the given variable to the given phase and performs UP.protected LNGIntVectorgenerateClauseVector(Collection<Literal> literals)protected voidhandleConflict(MSClause conflict)protected LiteralintToLiteral(int lit)LiterallitForIdx(int var)Returns the literal corresponding to the given variable index.FormulanewlyImplied(BitSet knownVariables)Returns a conjunction of all literals in the known variables which were propagated by the last UP.static booleanphase(int lit)Returns the phase of the given solver literal.protected booleanpropagateAfterDecide()booleanstart()Initializes the solver by performing unit propagation and returnsfalseif UP finds a contradiction, otherwisetrue.protected voiduncheckedEnqueue(int lit, MSClause reason)Assigns a literal (= a variable to the respective value).voidundoDecide(int var)Reverts the decision of the given variable.TristatevalueOf(int lit)Returns the current assignment of the given literal.static intvar(int lit)Returns the variable index for a given literal.intvariableIndex(Literal lit)Returns the index of the variable of the given literal.-
Methods inherited from class org.logicng.solvers.sat.MiniSat2Solver
addClause, analyze, analyzeFinal, attachClause, completeBacktrack, detachClause, initializeMiniSAT, litRedundant, loadState, newVar, propagate, reduceDB, removeClause, removeSatisfied, reset, satisfied, saveState, search, simpleRemoveClause, simplify, simplifyClause, solve
-
Methods inherited from class org.logicng.solvers.sat.MiniSatStyleSolver
abstractLevel, addBackboneLiteral, addClause, addName, buildBackbone, claBumpActivity, claDecayActivity, clauses, computeBackbone, computeBackbone, computeBackbone, conflict, createInitialCandidates, decayActivities, decisionLevel, getName2idx, getRelevantVarIndices, idxForName, initBackboneDS, initialize, initializeConfig, insertVarOrder, isBothOrNegativeType, isBothOrPositiveType, isBothType, isRotatable, isUnit, isUPZeroLit, locked, lt, luby, mkLit, model, name2idx, nameForIdx, nAssigns, not, nVars, ok, pgOriginalClauses, pgProof, pickBranchLit, rebuildOrderHeap, refineUpperBound, resetSelectionOrder, setSelectionOrder, sign, solve, solveWithLit, toString, upZeroLiterals, v, value, varBumpActivity, varBumpActivity, varDecayActivity, variables
-
-
-
-
Field Detail
-
newlyImpliedDirty
protected boolean newlyImpliedDirty
-
assertionLevel
protected int assertionLevel
-
lastLearnt
protected LNGIntVector lastLearnt
-
f
protected final FormulaFactory f
-
assignment
protected final Tristate[] assignment
-
-
Constructor Detail
-
DnnfMiniSatStyleSolver
public DnnfMiniSatStyleSolver(FormulaFactory f, int numberOfVariables)
Constructs a new DNNF MiniSat solver with the given number of variables.- Parameters:
f- the formula factorynumberOfVariables- the number of variables
-
-
Method Detail
-
start
public boolean start()
Description copied from interface:DnnfSatSolverInitializes the solver by performing unit propagation and returnsfalseif UP finds a contradiction, otherwisetrue.- Specified by:
startin interfaceDnnfSatSolver- Returns:
falseif UP finds a contradiction, otherwisetrue
-
valueOf
public Tristate valueOf(int lit)
Description copied from interface:DnnfSatSolverReturns the current assignment of the given literal.- Specified by:
valueOfin interfaceDnnfSatSolver- Parameters:
lit- the literal- Returns:
- the current assignment of the given literal
-
variableIndex
public int variableIndex(Literal lit)
Description copied from interface:DnnfSatSolverReturns the index of the variable of the given literal.- Specified by:
variableIndexin interfaceDnnfSatSolver- Parameters:
lit- the literal- Returns:
- the index of the literal's variable
-
litForIdx
public Literal litForIdx(int var)
Description copied from interface:DnnfSatSolverReturns the literal corresponding to the given variable index.- Specified by:
litForIdxin interfaceDnnfSatSolver- Parameters:
var- the variable index- Returns:
- the literal corresponding to the given variable index
-
var
public static int var(int lit)
Returns the variable index for a given literal.- Parameters:
lit- the literal- Returns:
- the variable index of the literal
-
phase
public static boolean phase(int lit)
Returns the phase of the given solver literal.- Parameters:
lit- the solver literal- Returns:
trueif the literal has a positive phase,falseif the literal has a negative phase (literal is negated)
-
add
public void add(Formula formula)
Description copied from interface:DnnfSatSolverAdds a formula to the solver. The formula is first converted to CNF.- Specified by:
addin interfaceDnnfSatSolver- Parameters:
formula- the formula
-
generateClauseVector
protected LNGIntVector generateClauseVector(Collection<Literal> literals)
-
decide
public boolean decide(int var, boolean phase)Description copied from interface:DnnfSatSolverPerforms a decision of the given variable to the given phase and performs UP.- Specified by:
decidein interfaceDnnfSatSolver- Parameters:
var- the variablephase- the phase- Returns:
falseif UP finds a contradiction, otherwisetrue
-
undoDecide
public void undoDecide(int var)
Description copied from interface:DnnfSatSolverReverts the decision of the given variable.- Specified by:
undoDecidein interfaceDnnfSatSolver- Parameters:
var- the variable
-
atAssertionLevel
public boolean atAssertionLevel()
Description copied from interface:DnnfSatSolverReturnstrueif the current decision level was previously selected as backtrack level.- Specified by:
atAssertionLevelin interfaceDnnfSatSolver- Returns:
trueif the current decision level was previously selected as backtrack level, otherwisefalse
-
assertCdLiteral
public boolean assertCdLiteral()
Description copied from interface:DnnfSatSolverEnqueues the literal which was computed by the latest backtracking, performs UP and returnfalseif UP finds a contradiction, otherwisetrue.- Specified by:
assertCdLiteralin interfaceDnnfSatSolver- Returns:
falseif UP finds a contradiction, otherwisetrue
-
newlyImplied
public Formula newlyImplied(BitSet knownVariables)
Description copied from interface:DnnfSatSolverReturns a conjunction of all literals in the known variables which were propagated by the last UP.- Specified by:
newlyImpliedin interfaceDnnfSatSolver- Parameters:
knownVariables- the known variables- Returns:
- a conjunction of the relevant propagated literals
-
intToLiteral
protected Literal intToLiteral(int lit)
-
propagateAfterDecide
protected boolean propagateAfterDecide()
-
uncheckedEnqueue
protected void uncheckedEnqueue(int lit, MSClause reason)Description copied from class:MiniSatStyleSolverAssigns a literal (= a variable to the respective value).- Overrides:
uncheckedEnqueuein classMiniSat2Solver- Parameters:
lit- the literalreason- the reason clause of the assignment (conflict resolution) ornullif it was a decision
-
cancelUntil
protected void cancelUntil(int level)
- Overrides:
cancelUntilin classMiniSatStyleSolver
-
handleConflict
protected void handleConflict(MSClause conflict)
-
-