use of org.logicng.handlers.BoundedOptimizationHandler in project LogicNG by logic-ng.
the class SmusComputationTest method testCancellationPoints.
@Test
public void testCancellationPoints() throws IOException {
final List<Formula> formulas = DimacsReader.readCNF("src/test/resources/sat/unsat/bf0432-007.cnf", this.f);
for (int numOptimizationStarts = 1; numOptimizationStarts < 5; numOptimizationStarts++) {
for (int numSatHandlerStarts = 1; numSatHandlerStarts < 10; numSatHandlerStarts++) {
final OptimizationHandler handler = new BoundedOptimizationHandler(numSatHandlerStarts, numOptimizationStarts);
testHandler(handler, formulas, true);
}
}
}
use of org.logicng.handlers.BoundedOptimizationHandler in project LogicNG by logic-ng.
the class SmusComputationTest method testHSolverCancelled.
@Test
public void testHSolverCancelled() throws ParserException {
final OptimizationHandler handler = new BoundedOptimizationHandler(-1, 3);
final List<Formula> formulas = Arrays.asList(this.f.parse("a"), this.f.parse("~a"), this.f.parse("c"));
testHandler(handler, formulas, true);
}
use of org.logicng.handlers.BoundedOptimizationHandler in project LogicNG by logic-ng.
the class SmusComputationTest method testMinimumHittingSetCancelled.
@Test
public void testMinimumHittingSetCancelled() throws ParserException {
final OptimizationHandler handler = new BoundedOptimizationHandler(-1, 0);
final List<Formula> formulas = Arrays.asList(this.f.parse("a"), this.f.parse("~a"));
testHandler(handler, formulas, true);
}
use of org.logicng.handlers.BoundedOptimizationHandler in project LogicNG by logic-ng.
the class OptimizationFunctionTest method testCancellationPoints.
@LongRunningTag
@ParameterizedTest
@MethodSource("solvers")
public void testCancellationPoints(final SATSolver solver) throws IOException {
final FormulaFactory f = new FormulaFactory();
final SortedSet<Variable> selVars = new TreeSet<>();
final List<Formula> clauses = DimacsReader.readCNF("src/test/resources/sat/c499_gr_rcs_w6.shuffled.cnf", f);
final List<Formula> formulas = new ArrayList<>();
for (final Formula clause : clauses) {
final Variable selVar = f.variable("@SEL_" + selVars.size());
selVars.add(selVar);
formulas.add(f.equivalence(selVar, clause));
}
for (int numSatHandlerStarts = 1; numSatHandlerStarts < 5; numSatHandlerStarts++) {
solver.reset();
solver.add(formulas);
final OptimizationHandler handler = new BoundedOptimizationHandler(numSatHandlerStarts, -1);
final OptimizationFunction optimizationFunction = OptimizationFunction.builder().handler(handler).literals(selVars).maximize().build();
final Assignment result = solver.execute(optimizationFunction);
assertThat(handler.aborted()).isTrue();
assertThat(result).isNull();
}
}
use of org.logicng.handlers.BoundedOptimizationHandler in project LogicNG by logic-ng.
the class PrimeCompilerTest method testCancellationPoints.
@Test
public void testCancellationPoints() throws IOException, ParserException {
final Formula formula = this.f.parse(Files.readAllLines(Paths.get("src/test/resources/formulas/simplify_formulas.txt")).get(0));
final List<Pair<PrimeCompiler, PrimeResult.CoverageType>> compilers = Arrays.asList(new Pair<>(PrimeCompiler.getWithMaximization(), PrimeResult.CoverageType.IMPLICANTS_COMPLETE), new Pair<>(PrimeCompiler.getWithMaximization(), PrimeResult.CoverageType.IMPLICATES_COMPLETE), new Pair<>(PrimeCompiler.getWithMinimization(), PrimeResult.CoverageType.IMPLICANTS_COMPLETE), new Pair<>(PrimeCompiler.getWithMinimization(), PrimeResult.CoverageType.IMPLICATES_COMPLETE));
for (final Pair<PrimeCompiler, PrimeResult.CoverageType> compiler : compilers) {
for (int numOptimizationStarts = 1; numOptimizationStarts < 5; numOptimizationStarts++) {
for (int numSatHandlerStarts = 1; numSatHandlerStarts < 10; numSatHandlerStarts++) {
final OptimizationHandler handler = new BoundedOptimizationHandler(numSatHandlerStarts, numOptimizationStarts);
testHandler(handler, formula, compiler.first(), compiler.second(), true);
}
}
}
}
Aggregations