use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.
the class LargeBDDTest method testNumberOfNodesHandler.
@Test
public void testNumberOfNodesHandler() throws ParserException {
final FormulaFactory f = new FormulaFactory();
final Formula formula = f.parse("A <=> ~(B => C & F & G & ~H | A & D & ~E)");
final BDDKernel kernel = new BDDKernel(f, formula.variables().size(), 10000, 10000);
final NumberOfNodesBDDHandler handler = new NumberOfNodesBDDHandler(5);
final BDD bdd = BDDFactory.build(formula, kernel, handler);
assertThat(handler.aborted()).isTrue();
assertThat(bdd.index()).isEqualTo(BDDKernel.BDD_ABORT);
}
use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.
the class LargeBDDTest method testNumberOfNodesHandlerLarge.
@Test
public void testNumberOfNodesHandlerLarge() {
final FormulaFactory f = new FormulaFactory();
final NQueensGenerator generator = new NQueensGenerator(f);
final Formula queens = generator.generate(10);
final BDDKernel kernel = new BDDKernel(f, queens.variables().size(), 10000, 10000);
final NumberOfNodesBDDHandler handler = new NumberOfNodesBDDHandler(5);
final BDD bdd = BDDFactory.build(queens, kernel, handler);
assertThat(handler.aborted()).isTrue();
assertThat(bdd.index()).isEqualTo(BDDKernel.BDD_ABORT);
}
use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.
the class LargeBDDTest method testTimeoutBDDHandlerLarge.
@Test
public void testTimeoutBDDHandlerLarge() {
final FormulaFactory f = new FormulaFactory();
final NQueensGenerator generator = new NQueensGenerator(f);
final Formula queens = generator.generate(10);
final BDDKernel kernel = new BDDKernel(f, queens.variables().size(), 10000, 10000);
final TimeoutBDDHandler handler = new TimeoutBDDHandler(1000L);
final BDD bdd = BDDFactory.build(queens, kernel, handler);
assertThat(handler.aborted()).isTrue();
assertThat(bdd.index()).isEqualTo(BDDKernel.BDD_ABORT);
}
use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.
the class SimpleBDDTest method testAnd.
@Test
public void testAnd() throws ParserException {
final FormulaFactory f = new FormulaFactory();
final PropositionalParser parser = new PropositionalParser(f);
final List<Variable> ordering = Arrays.asList(f.variable("A"), f.variable("B"), f.variable("C"));
final BDDKernel kernel = new BDDKernel(f, ordering, 1000, 1000);
final BDD bdd = BDDFactory.build(parser.parse("A & B & ~C"), kernel, null);
assertThat(bdd.isTautology()).isFalse();
assertThat(bdd.isContradiction()).isFalse();
assertThat(bdd.cnf()).isEqualTo(parser.parse("A & (~A | B) & (~A | ~B | ~C)"));
assertThat(bdd.dnf()).isEqualTo(parser.parse("A & B & ~C"));
assertThat(bdd.modelCount()).isEqualTo(BigInteger.valueOf(1));
assertThat(bdd.underlyingKernel().factory()).isSameAs(f);
assertThat(bdd.enumerateAllModels()).containsExactlyInAnyOrder(new Assignment(f.literal("A", true), f.literal("B", true), f.literal("C", false)));
assertThat(bdd.numberOfClausesCNF()).isEqualTo(BigInteger.valueOf(3));
assertThat(bdd.toLngBdd().toString()).isEqualTo("<A | low=<$false> high=<B | low=<$false> high=<C | low=<$true> high=<$false>>>>");
}
use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.
the class BDDDotFileWriterTest method testWriter.
@Test
public void testWriter() throws IOException, ParserException {
final FormulaFactory f = new FormulaFactory();
final PropositionalParser p = new PropositionalParser(f);
final List<Variable> ordering = Arrays.asList(f.variable("A"), f.variable("B"), f.variable("C"), f.variable("D"));
final BDDKernel kernel = new BDDKernel(f, ordering, 1000, 1000);
testFiles("false", BDDFactory.build(p.parse("$false"), kernel));
testFiles("true", BDDFactory.build(p.parse("$true"), kernel));
testFiles("a", BDDFactory.build(p.parse("A"), kernel));
testFiles("not_a", BDDFactory.build(p.parse("~A"), kernel));
testFiles("impl", BDDFactory.build(p.parse("A => ~C"), kernel));
testFiles("equiv", BDDFactory.build(p.parse("A <=> ~C"), kernel));
testFiles("or", BDDFactory.build(p.parse("A | B | ~C"), kernel));
testFiles("and", BDDFactory.build(p.parse("A & B & ~C"), kernel));
testFiles("not", BDDFactory.build(p.parse("~(A & B & ~C)"), kernel));
testFiles("formula", BDDFactory.build(p.parse("(A => (B|~C)) & (B => C & D) & (D <=> A)"), kernel));
}
Aggregations