Search in sources :

Example 1 with TimeoutBDDHandler

use of org.logicng.handlers.TimeoutBDDHandler 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 2 with TimeoutBDDHandler

use of org.logicng.handlers.TimeoutBDDHandler 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);
}
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)

Aggregations

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