Search in sources :

Example 6 with LongRunningTag

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

the class CnfMethodComparisonTest method compareFullBackbonesOnLargeFormulas.

@ParameterizedTest
@MethodSource("cnfConfigurations")
@LongRunningTag
public void compareFullBackbonesOnLargeFormulas(final CNFConfig cnfConfig, final MiniSatConfig.CNFMethod cnfMethod) throws IOException, ParserException {
    final String baseDir = "src/test/resources/formulas/";
    final List<String> fileNames = Arrays.asList("formula1.txt", "formula2.txt", "formula3.txt", "large_formula.txt", "small_formulas.txt");
    for (final String fileName : fileNames) {
        final String filePath = baseDir + fileName;
        final Backbone backboneReference = computeBackbone(filePath, CNFConfig.builder().build(), MiniSatConfig.builder().build().getCnfMethod());
        final Backbone backbone = computeBackbone(filePath, cnfConfig, cnfMethod);
        assertThat(backboneReference).isEqualTo(backbone);
    }
}
Also used : Backbone(org.logicng.backbones.Backbone) LongRunningTag(org.logicng.LongRunningTag) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 7 with LongRunningTag

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

the class DnnfCompilerTest method testAllSmallFormulas.

@Test
@LongRunningTag
public void testAllSmallFormulas() throws IOException, ParserException {
    final Formula formulas = FormulaReader.readPseudoBooleanFormula("src/test/resources/formulas/small_formulas.txt", this.f);
    formulas.stream().forEach(f -> testFormula(f, false));
}
Also used : Formula(org.logicng.formulas.Formula) LongRunningTag(org.logicng.LongRunningTag) Test(org.junit.jupiter.api.Test)

Example 8 with LongRunningTag

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

the class DRUPTest method testUnsatCoresFromLargeTestset.

@Test
@LongRunningTag
public void testUnsatCoresFromLargeTestset() throws IOException {
    final File testFolder = new File("src/test/resources/sat");
    final File[] files = testFolder.listFiles();
    assert files != null;
    int count = 0;
    for (final SATSolver solver : this.solvers) {
        for (final File file : files) {
            final String fileName = file.getName();
            if (fileName.endsWith(".cnf")) {
                final List<Formula> cnf = DimacsReader.readCNF(file, this.f);
                solver.add(cnf);
                if (solver.sat() == FALSE) {
                    final UNSATCore<Proposition> unsatCore = solver.unsatCore();
                    verifyCore(unsatCore, cnf);
                    count++;
                }
                solver.reset();
            }
        }
        solver.reset();
    }
    assertThat(count).isEqualTo(11 * this.solvers.length);
}
Also used : SATSolver(org.logicng.solvers.SATSolver) Formula(org.logicng.formulas.Formula) StandardProposition(org.logicng.propositions.StandardProposition) Proposition(org.logicng.propositions.Proposition) ExtendedProposition(org.logicng.propositions.ExtendedProposition) File(java.io.File) LongRunningTag(org.logicng.LongRunningTag) LogicNGTest(org.logicng.LogicNGTest) Test(org.junit.jupiter.api.Test)

Example 9 with LongRunningTag

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

the class CCIncrementalFormulaTest method testLargeModularTotalizerAMK.

@Test
@LongRunningTag
public void testLargeModularTotalizerAMK() {
    for (final SATSolver solver : this.solvers) {
        final CCEncoder encoder = this.encoders[2];
        final CCEncoder initialEncoder = new CCEncoder(this.f);
        final int numLits = 100;
        int currentBound = numLits - 1;
        final Variable[] vars = new Variable[numLits];
        for (int i = 0; i < numLits; i++) {
            vars[i] = this.f.variable("v" + i);
        }
        final Pair<List<Formula>, CCIncrementalData> cc = encoder.encodeIncremental((CardinalityConstraint) this.f.cc(CType.LE, currentBound, vars));
        final CCIncrementalData incData = cc.second();
        solver.reset();
        // >= 42
        solver.add(initialEncoder.encode((CardinalityConstraint) this.f.cc(CType.GE, 42, vars)));
        solver.add(cc.first());
        // search the lower bound
        while (solver.sat() == Tristate.TRUE) {
            // <= currentBound - 1
            solver.add(incData.newUpperBound(--currentBound));
        }
        assertThat(currentBound).isEqualTo(41);
    }
}
Also used : SATSolver(org.logicng.solvers.SATSolver) Variable(org.logicng.formulas.Variable) CardinalityConstraint(org.logicng.formulas.CardinalityConstraint) List(java.util.List) CardinalityConstraint(org.logicng.formulas.CardinalityConstraint) LongRunningTag(org.logicng.LongRunningTag) Test(org.junit.jupiter.api.Test) LogicNGTest(org.logicng.LogicNGTest)

Example 10 with LongRunningTag

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

the class CCIncrementalSolverTest method testVeryLargeModularTotalizerAMK.

@Test
@LongRunningTag
public void testVeryLargeModularTotalizerAMK() {
    this.f.putConfiguration(this.configs[2]);
    final int numLits = 300;
    int currentBound = numLits - 1;
    final Variable[] vars = new Variable[numLits];
    for (int i = 0; i < numLits; i++) {
        vars[i] = this.f.variable("v" + i);
    }
    final SATSolver solver = this.solvers[3];
    solver.reset();
    solver.add(this.f.cc(CType.GE, 234, vars));
    final CCIncrementalData incData = solver.addIncrementalCC((CardinalityConstraint) this.f.cc(CType.LE, currentBound, vars));
    // search the lower bound
    while (solver.sat() == Tristate.TRUE) {
        incData.newUpperBoundForSolver(--currentBound);
    }
    assertThat(currentBound).isEqualTo(233);
}
Also used : SATSolver(org.logicng.solvers.SATSolver) Variable(org.logicng.formulas.Variable) CardinalityConstraint(org.logicng.formulas.CardinalityConstraint) LongRunningTag(org.logicng.LongRunningTag) Test(org.junit.jupiter.api.Test) LogicNGTest(org.logicng.LogicNGTest)

Aggregations

LongRunningTag (org.logicng.LongRunningTag)18 Test (org.junit.jupiter.api.Test)12 Formula (org.logicng.formulas.Formula)10 LogicNGTest (org.logicng.LogicNGTest)8 FormulaFactory (org.logicng.formulas.FormulaFactory)8 Variable (org.logicng.formulas.Variable)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 MethodSource (org.junit.jupiter.params.provider.MethodSource)6 CardinalityConstraint (org.logicng.formulas.CardinalityConstraint)6 SATSolver (org.logicng.solvers.SATSolver)6 ArrayList (java.util.ArrayList)5 Assignment (org.logicng.datastructures.Assignment)4 BufferedReader (java.io.BufferedReader)3 FileReader (java.io.FileReader)3 List (java.util.List)3 Backbone (org.logicng.backbones.Backbone)3 File (java.io.File)2 BoundedOptimizationHandler (org.logicng.handlers.BoundedOptimizationHandler)2 OptimizationHandler (org.logicng.handlers.OptimizationHandler)2 TimeoutOptimizationHandler (org.logicng.handlers.TimeoutOptimizationHandler)2