Search in sources :

Example 1 with NQueensGenerator

use of org.logicng.testutils.NQueensGenerator 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);
}
Also used : Formula(org.logicng.formulas.Formula) FormulaFactory(org.logicng.formulas.FormulaFactory) BDDKernel(org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel) NumberOfNodesBDDHandler(org.logicng.handlers.NumberOfNodesBDDHandler) NQueensGenerator(org.logicng.testutils.NQueensGenerator) Test(org.junit.jupiter.api.Test)

Example 2 with NQueensGenerator

use of org.logicng.testutils.NQueensGenerator 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);
}
Also used : Formula(org.logicng.formulas.Formula) FormulaFactory(org.logicng.formulas.FormulaFactory) BDDKernel(org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel) TimeoutBDDHandler(org.logicng.handlers.TimeoutBDDHandler) NQueensGenerator(org.logicng.testutils.NQueensGenerator) Test(org.junit.jupiter.api.Test)

Example 3 with NQueensGenerator

use of org.logicng.testutils.NQueensGenerator in project LogicNG by logic-ng.

the class LargeBDDTest method testQueens.

@Test
public void testQueens() {
    final FormulaFactory f = new FormulaFactory();
    final NQueensGenerator generator = new NQueensGenerator(f);
    testQueens(f, generator, 4, 2);
    testQueens(f, generator, 5, 10);
    testQueens(f, generator, 6, 4);
    testQueens(f, generator, 7, 40);
    testQueens(f, generator, 8, 92);
}
Also used : FormulaFactory(org.logicng.formulas.FormulaFactory) NQueensGenerator(org.logicng.testutils.NQueensGenerator) Test(org.junit.jupiter.api.Test)

Example 4 with NQueensGenerator

use of org.logicng.testutils.NQueensGenerator in project LogicNG by logic-ng.

the class ModelCounterTest method testQueens.

@Test
public void testQueens() {
    final NQueensGenerator generator = new NQueensGenerator(this.f);
    testQueens(generator, 4, 2);
    testQueens(generator, 5, 10);
    testQueens(generator, 6, 4);
    testQueens(generator, 7, 40);
    testQueens(generator, 8, 92);
}
Also used : NQueensGenerator(org.logicng.testutils.NQueensGenerator) Test(org.junit.jupiter.api.Test)

Example 5 with NQueensGenerator

use of org.logicng.testutils.NQueensGenerator 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);
}
Also used : Formula(org.logicng.formulas.Formula) FormulaFactory(org.logicng.formulas.FormulaFactory) BDDKernel(org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel) NumberOfNodesBDDHandler(org.logicng.handlers.NumberOfNodesBDDHandler) NQueensGenerator(org.logicng.testutils.NQueensGenerator) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)6 NQueensGenerator (org.logicng.testutils.NQueensGenerator)6 FormulaFactory (org.logicng.formulas.FormulaFactory)5 Formula (org.logicng.formulas.Formula)4 BDDKernel (org.logicng.knowledgecompilation.bdds.jbuddy.BDDKernel)4 NumberOfNodesBDDHandler (org.logicng.handlers.NumberOfNodesBDDHandler)2 TimeoutBDDHandler (org.logicng.handlers.TimeoutBDDHandler)2