Search in sources :

Example 1 with BoundedSatHandler

use of org.logicng.handlers.BoundedSatHandler in project LogicNG by logic-ng.

the class BackboneGenerationTest method testCancellationPoints.

@Test
public void testCancellationPoints() throws IOException {
    final FormulaFactory f = new FormulaFactory();
    final List<Formula> formulas = DimacsReader.readCNF("src/test/resources/sat/term1_gr_rcs_w4.shuffled.cnf", f);
    for (int numStarts = 0; numStarts < 10; numStarts++) {
        final SATHandler handler = new BoundedSatHandler(numStarts);
        final Backbone result = BackboneGeneration.compute(formulas, FormulaHelper.variables(formulas), BackboneType.POSITIVE_AND_NEGATIVE, handler);
        assertThat(handler.aborted()).isTrue();
        assertThat(result).isNull();
    }
}
Also used : Formula(org.logicng.formulas.Formula) FormulaFactory(org.logicng.formulas.FormulaFactory) SATHandler(org.logicng.handlers.SATHandler) BoundedSatHandler(org.logicng.handlers.BoundedSatHandler) Test(org.junit.jupiter.api.Test)

Example 2 with BoundedSatHandler

use of org.logicng.handlers.BoundedSatHandler in project LogicNG by logic-ng.

the class MUSGenerationTest method testCancellationPoints.

@Test
public void testCancellationPoints() throws IOException {
    final MUSGeneration mus = new MUSGeneration();
    final List<StandardProposition> propositions = DimacsReader.readCNF("src/test/resources/sat/unsat/bf0432-007.cnf", f).stream().map(StandardProposition::new).collect(Collectors.toList());
    final List<MUSConfig.Algorithm> algorithms = Arrays.asList(MUSConfig.Algorithm.DELETION, MUSConfig.Algorithm.PLAIN_INSERTION);
    for (final MUSConfig.Algorithm algorithm : algorithms) {
        for (int numStarts = 0; numStarts < 10; numStarts++) {
            final SATHandler handler = new BoundedSatHandler(numStarts);
            final MUSConfig config = MUSConfig.builder().handler(handler).algorithm(algorithm).build();
            final UNSATCore<StandardProposition> result = mus.computeMUS(propositions, f, config);
            assertThat(handler.aborted()).isTrue();
            assertThat(result).isNull();
        }
    }
}
Also used : StandardProposition(org.logicng.propositions.StandardProposition) SATHandler(org.logicng.handlers.SATHandler) BoundedSatHandler(org.logicng.handlers.BoundedSatHandler) Test(org.junit.jupiter.api.Test)

Example 3 with BoundedSatHandler

use of org.logicng.handlers.BoundedSatHandler in project LogicNG by logic-ng.

the class MUSGenerationTest method testDeletionBasedCancellationPoints.

@Test
public void testDeletionBasedCancellationPoints() throws IOException {
    final MUSGeneration mus = new MUSGeneration();
    final List<StandardProposition> propositions = DimacsReader.readCNF("src/test/resources/sat/too_large_gr_rcs_w5.shuffled.cnf", f).stream().map(StandardProposition::new).collect(Collectors.toList());
    for (int numStarts = 0; numStarts < 20; numStarts++) {
        final SATHandler handler = new BoundedSatHandler(numStarts);
        final MUSConfig config = MUSConfig.builder().handler(handler).algorithm(MUSConfig.Algorithm.PLAIN_INSERTION).build();
        final UNSATCore<StandardProposition> result = mus.computeMUS(propositions, f, config);
        assertThat(handler.aborted()).isTrue();
        assertThat(result).isNull();
    }
}
Also used : StandardProposition(org.logicng.propositions.StandardProposition) SATHandler(org.logicng.handlers.SATHandler) BoundedSatHandler(org.logicng.handlers.BoundedSatHandler) Test(org.junit.jupiter.api.Test)

Example 4 with BoundedSatHandler

use of org.logicng.handlers.BoundedSatHandler in project LogicNG by logic-ng.

the class PrimeImplicantReductionTest method testCancellationPoints.

@Test
public void testCancellationPoints() throws ParserException, IOException {
    final Formula formula = FormulaReader.readPseudoBooleanFormula("src/test/resources/formulas/large_formula.txt", this.f);
    for (int numStarts = 0; numStarts < 20; numStarts++) {
        final SATHandler handler = new BoundedSatHandler(numStarts);
        testFormula(formula, handler, true);
    }
}
Also used : Formula(org.logicng.formulas.Formula) SATHandler(org.logicng.handlers.SATHandler) BoundedSatHandler(org.logicng.handlers.BoundedSatHandler) Test(org.junit.jupiter.api.Test)

Example 5 with BoundedSatHandler

use of org.logicng.handlers.BoundedSatHandler in project LogicNG by logic-ng.

the class PrimeImplicateReductionTest method testCancellationPoints.

@Test
public void testCancellationPoints() throws ParserException, IOException {
    final Formula formula = FormulaReader.readPseudoBooleanFormula("src/test/resources/formulas/large_formula.txt", this.f);
    for (int numStarts = 0; numStarts < 20; numStarts++) {
        final SATHandler handler = new BoundedSatHandler(numStarts);
        testFormula(formula, handler, true);
    }
}
Also used : Formula(org.logicng.formulas.Formula) SATHandler(org.logicng.handlers.SATHandler) BoundedSatHandler(org.logicng.handlers.BoundedSatHandler) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)5 BoundedSatHandler (org.logicng.handlers.BoundedSatHandler)5 SATHandler (org.logicng.handlers.SATHandler)5 Formula (org.logicng.formulas.Formula)3 StandardProposition (org.logicng.propositions.StandardProposition)2 FormulaFactory (org.logicng.formulas.FormulaFactory)1