Search in sources :

Example 11 with StandardProposition

use of org.logicng.propositions.StandardProposition 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 12 with StandardProposition

use of org.logicng.propositions.StandardProposition in project LogicNG by logic-ng.

the class MUSGenerationTest method testSATFormulaSetDeletionBasedMUS.

@Test
public void testSATFormulaSetDeletionBasedMUS() {
    final MUSGeneration mus = new MUSGeneration();
    final StandardProposition proposition = new StandardProposition(this.f.variable("a"));
    assertThatThrownBy(() -> mus.computeMUS(Collections.singletonList(proposition), this.f, MUSConfig.builder().algorithm(MUSConfig.Algorithm.DELETION).build())).isInstanceOf(IllegalArgumentException.class);
}
Also used : StandardProposition(org.logicng.propositions.StandardProposition) Test(org.junit.jupiter.api.Test)

Example 13 with StandardProposition

use of org.logicng.propositions.StandardProposition in project LogicNG by logic-ng.

the class MUSGenerationTest method testSATFormulaSetPlainInsertionBasedMUS.

@Test
public void testSATFormulaSetPlainInsertionBasedMUS() {
    final MUSGeneration mus = new MUSGeneration();
    final StandardProposition proposition = new StandardProposition(this.f.variable("a"));
    assertThatThrownBy(() -> mus.computeMUS(Collections.singletonList(proposition), this.f, MUSConfig.builder().algorithm(MUSConfig.Algorithm.PLAIN_INSERTION).build())).isInstanceOf(IllegalArgumentException.class);
}
Also used : StandardProposition(org.logicng.propositions.StandardProposition) Test(org.junit.jupiter.api.Test)

Example 14 with StandardProposition

use of org.logicng.propositions.StandardProposition 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 15 with StandardProposition

use of org.logicng.propositions.StandardProposition in project LogicNG by logic-ng.

the class MUSGenerationTest method generatePGPropositions.

private List<StandardProposition> generatePGPropositions(final int n) {
    final List<StandardProposition> result = new ArrayList<>();
    final Formula pgf = this.pg.generate(n);
    for (final Formula f : pgf) {
        result.add(new StandardProposition(f));
    }
    return result;
}
Also used : StandardProposition(org.logicng.propositions.StandardProposition) Formula(org.logicng.formulas.Formula) ArrayList(java.util.ArrayList)

Aggregations

StandardProposition (org.logicng.propositions.StandardProposition)18 Test (org.junit.jupiter.api.Test)13 LogicNGTest (org.logicng.LogicNGTest)9 SATSolver (org.logicng.solvers.SATSolver)9 Proposition (org.logicng.propositions.Proposition)6 ExtendedProposition (org.logicng.propositions.ExtendedProposition)5 FormulaFactory (org.logicng.formulas.FormulaFactory)4 ArrayList (java.util.ArrayList)3 Formula (org.logicng.formulas.Formula)3 LinkedHashSet (java.util.LinkedHashSet)2 UNSATCore (org.logicng.explanations.UNSATCore)2 BoundedSatHandler (org.logicng.handlers.BoundedSatHandler)2 SATHandler (org.logicng.handlers.SATHandler)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LNGIntVector (org.logicng.collections.LNGIntVector)1 LNGVector (org.logicng.collections.LNGVector)1 DRUPTrim (org.logicng.explanations.drup.DRUPTrim)1