use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.
the class LargeBDDTest method testNumberOfNodesHandlerSmall.
@Test
public void testNumberOfNodesHandlerSmall() {
final FormulaFactory f = new FormulaFactory();
final NQueensGenerator generator = new NQueensGenerator(f);
final Formula queens = generator.generate(4);
final BDDKernel kernel = new BDDKernel(f, queens.variables().size(), 10000, 10000);
final NumberOfNodesBDDHandler handler = new NumberOfNodesBDDHandler(1000);
final BDD bdd = BDDFactory.build(queens, kernel, handler);
assertThat(handler.aborted()).isFalse();
assertThat(bdd.index()).isNotEqualTo(BDDKernel.BDD_ABORT);
}
use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.
the class LargeBDDTest method testTimeoutBDDHandlerSmall.
@Test
public void testTimeoutBDDHandlerSmall() {
final FormulaFactory f = new FormulaFactory();
final NQueensGenerator generator = new NQueensGenerator(f);
final Formula queens = generator.generate(4);
final BDDKernel kernel = new BDDKernel(f, queens.variables().size(), 10000, 10000);
final TimeoutBDDHandler handler = new TimeoutBDDHandler(2000L);
final BDD bdd = BDDFactory.build(queens, kernel, handler);
assertThat(handler.aborted()).isFalse();
assertThat(bdd.index()).isNotEqualTo(BDDKernel.BDD_ABORT);
}
use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.
the class LargeBDDTest method testQueens.
private void testQueens(final FormulaFactory f, final NQueensGenerator generator, final int size, final int models) {
final Formula queens = generator.generate(size);
final BDDKernel kernel = new BDDKernel(f, queens.variables().size(), 10000, 10000);
final BDD bdd = BDDFactory.build(queens, kernel);
final Formula cnf = bdd.cnf();
assertThat(cnf.holds(CNFPredicate.get())).isTrue();
final BDD cnfBDD = BDDFactory.build(cnf, kernel);
assertThat(cnfBDD).isEqualTo(bdd);
assertThat(bdd.support()).isEqualTo(queens.variables());
assertThat(bdd.modelCount()).isEqualTo(BigInteger.valueOf(models));
}
use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.
the class LargeBDDTest method testPigeonHole.
private void testPigeonHole(final FormulaFactory f, final PigeonHoleGenerator generator, final int size) {
final Formula pigeon = generator.generate(size);
final BDDKernel kernel = new BDDKernel(f, pigeon.variables().size(), 10000, 10000);
final BDD bdd = BDDFactory.build(pigeon, kernel);
assertThat(bdd.isContradiction()).isTrue();
}
use of org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel in project LogicNG by logic-ng.
the class SimpleBDDTest method testFalse.
@Test
public void testFalse() {
final FormulaFactory f = new FormulaFactory();
final BDDKernel kernel = new BDDKernel(f, 0, 100, 100);
final BDD bdd = BDDFactory.build(f.falsum(), kernel, null);
assertThat(bdd.isTautology()).isFalse();
assertThat(bdd.isContradiction()).isTrue();
assertThat(bdd.cnf()).isEqualTo(f.falsum());
assertThat(bdd.dnf()).isEqualTo(f.falsum());
assertThat(bdd.modelCount()).isEqualTo(BigInteger.ZERO);
assertThat(bdd.underlyingKernel()).isSameAs(kernel);
assertThat(bdd.underlyingKernel().factory()).isSameAs(f);
assertThat(bdd.enumerateAllModels()).isEmpty();
assertThat(bdd.numberOfClausesCNF()).isEqualTo(BigInteger.ONE);
assertThat(bdd.toLngBdd()).isEqualTo(BDDConstant.getFalsumNode(f));
}
Aggregations