- java.lang.Object
-
- org.logicng.knowledgecompilation.dnnf.DnnfCompiler
-
public class DnnfCompiler extends Object
Implementation of a DNNF compiler based on ideas by Adnan Darwiche in "New advances in compiling CNF to decomposable negation normal form."- Since:
- 2.0.0
- Version:
- 2.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<BitSet,Formula>cacheprotected Formulacnfprotected FormulaFactoryfprotected DnnfCompilationHandlerhandlerprotected List<Literal>leafCurrentLiteralsprotected List<Formula>leafResultOperandsprotected BitSet[][]localCacheKeysprotected int[][][]localOccurrencesprotected FormulanonUnitClausesprotected intnumberOfVariablesprotected DnnfSatSolversolverprotected FormulaunitClauses
-
Constructor Summary
Constructors Constructor Description DnnfCompiler(Formula formula)Constructs a new DNNF compiler for the given formula.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intchooseShannonVariable(DTree tree, BitSet separator, int currentShannons)protected Formulacnf2Ddnnf(DTree tree)protected Formulacnf2Ddnnf(DTree tree, int currentShannons)protected FormulacnfAux(DTree tree, int currentShannons)Formulacompile(DTreeGenerator generator)Performs the compilation using the given DTree generator.Formulacompile(DTreeGenerator generator, DnnfCompilationHandler handler)Performs the compilation using the given DTree generator and the compilation handler.protected Formulacompile(DTree dTree, DnnfCompilationHandler handler)protected BitSetcomputeCacheKey(DTreeNode tree, int currentShannons)protected intcomputeMaxClauseSize(Formula cnf)protected Formulaconjoin(Formula implied, DTreeNode tree, int currentShannons)protected DTreegenerateDTree(DTreeGenerator generator)protected voidinitializeCaches(DTree dTree)protected Pair<Formula,Formula>initializeClauses()protected Formulaleaf2Ddnnf(DTreeLeaf leaf)protected FormulanewlyImpliedLiterals(BitSet knownVariables)
-
-
-
Field Detail
-
f
protected final FormulaFactory f
-
cnf
protected final Formula cnf
-
unitClauses
protected final Formula unitClauses
-
nonUnitClauses
protected final Formula nonUnitClauses
-
solver
protected final DnnfSatSolver solver
-
numberOfVariables
protected final int numberOfVariables
-
handler
protected DnnfCompilationHandler handler
-
localCacheKeys
protected BitSet[][] localCacheKeys
-
localOccurrences
protected int[][][] localOccurrences
-
-
Constructor Detail
-
DnnfCompiler
public DnnfCompiler(Formula formula)
Constructs a new DNNF compiler for the given formula.- Parameters:
formula- the formula to compile
-
-
Method Detail
-
compile
public Formula compile(DTreeGenerator generator)
Performs the compilation using the given DTree generator.- Parameters:
generator- the DTree generator- Returns:
- the compiled DNNF
-
compile
public Formula compile(DTreeGenerator generator, DnnfCompilationHandler handler)
Performs the compilation using the given DTree generator and the compilation handler.- Parameters:
generator- the DTree generatorhandler- the compilation handler- Returns:
- the compiled DNNF
-
computeMaxClauseSize
protected int computeMaxClauseSize(Formula cnf)
-
generateDTree
protected DTree generateDTree(DTreeGenerator generator)
-
compile
protected Formula compile(DTree dTree, DnnfCompilationHandler handler)
-
initializeCaches
protected void initializeCaches(DTree dTree)
-
cnf2Ddnnf
protected Formula cnf2Ddnnf(DTree tree) throws TimeoutException
- Throws:
TimeoutException
-
cnf2Ddnnf
protected Formula cnf2Ddnnf(DTree tree, int currentShannons) throws TimeoutException
- Throws:
TimeoutException
-
chooseShannonVariable
protected int chooseShannonVariable(DTree tree, BitSet separator, int currentShannons)
-
conjoin
protected Formula conjoin(Formula implied, DTreeNode tree, int currentShannons) throws TimeoutException
- Throws:
TimeoutException
-
cnfAux
protected Formula cnfAux(DTree tree, int currentShannons) throws TimeoutException
- Throws:
TimeoutException
-
-