Search in sources :

Example 36 with BDDKernel

use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.

the class Formula method bdd.

/**
 * Generates a BDD from this formula with a given variable ordering.  This is done by generating a new BDD factory,
 * generating the variable order for this formula, and building a new BDD.  If more sophisticated operations should
 * be performed on the BDD or more than one formula should be constructed on the BDD, an own instance of
 * {@link BDDFactory} should be created and used.
 * @param variableOrdering the variable ordering
 * @return the BDD for this formula with the given ordering
 */
public BDD bdd(final VariableOrdering variableOrdering) {
    final Formula formula = this.nnf();
    final int varNum = formula.variables().size();
    final BDDKernel kernel;
    if (variableOrdering == null) {
        kernel = new BDDKernel(this.f, varNum, varNum * 30, varNum * 20);
    } else {
        final VariableOrderingProvider provider = variableOrdering.provider();
        kernel = new BDDKernel(this.f, provider.getOrder(formula), varNum * 30, varNum * 20);
    }
    return BDDFactory.build(formula, kernel, null);
}
Also used : BDDKernel(org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel) VariableOrderingProvider(org.logicng.knowledgecompilation.bdds.orderings.VariableOrderingProvider)

Aggregations

BDDKernel (org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel)36 Test (org.junit.jupiter.api.Test)23 Formula (org.logicng.formulas.Formula)20 FormulaFactory (org.logicng.formulas.FormulaFactory)17 PropositionalParser (org.logicng.io.parsers.PropositionalParser)6 BDDOperations (org.logicng.knowledgecompilation.bdds.jbuddy.BDDOperations)6 Variable (org.logicng.formulas.Variable)5 BDD (org.logicng.knowledgecompilation.bdds.BDD)5 VariableOrderingProvider (org.logicng.knowledgecompilation.bdds.orderings.VariableOrderingProvider)5 Assignment (org.logicng.datastructures.Assignment)4 NQueensGenerator (org.logicng.testutils.NQueensGenerator)4 NumberOfNodesBDDHandler (org.logicng.handlers.NumberOfNodesBDDHandler)3 BDDInnerNode (org.logicng.knowledgecompilation.bdds.datastructures.BDDInnerNode)3 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 TimeoutBDDHandler (org.logicng.handlers.TimeoutBDDHandler)2 LngBDDFunction (org.logicng.knowledgecompilation.bdds.functions.LngBDDFunction)2