use of org.logicng.LongRunningTag in project LogicNG by logic-ng.
the class DnnfCompilerTest method testLargeFormula.
@Test
@LongRunningTag
public void testLargeFormula() throws IOException, ParserException {
final FormulaFactory f = new FormulaFactory();
f.putConfiguration(CCConfig.builder().amoEncoding(CCConfig.AMO_ENCODER.PURE).build());
final Formula parsed = FormulaReader.readPseudoBooleanFormula("src/test/resources/formulas/formula1.txt", f);
final DnnfFactory dnnfFactory = new DnnfFactory();
Dnnf dnnf = dnnfFactory.compile(parsed);
final BigInteger dnnfCount = dnnf.execute(DnnfModelCountFunction.get());
final List<Formula> formulas = new ArrayList<>();
final List<Formula> originalFormulas = new ArrayList<>();
for (final Formula formula : parsed) {
originalFormulas.add(formula);
if (formula instanceof PBConstraint) {
formulas.add(formula);
} else {
formulas.add(formula.transform(new CNFFactorization()));
}
}
final Graph<Variable> constraintGraph = ConstraintGraphGenerator.generateFromCnf(formulas);
final Set<Set<Node<Variable>>> ccs = ConnectedComponentsComputation.compute(constraintGraph);
final List<List<Formula>> split = ConnectedComponentsComputation.splitFormulasByComponent(originalFormulas, ccs);
BigInteger multipliedCount = BigInteger.ONE;
for (final List<Formula> component : split) {
dnnf = dnnfFactory.compile(f.and(component));
multipliedCount = multipliedCount.multiply(dnnf.execute(DnnfModelCountFunction.get()));
}
assertThat(dnnfCount).isEqualTo(multipliedCount);
}
use of org.logicng.LongRunningTag in project LogicNG by logic-ng.
the class CNFSubsumptionTest method testEvenLargerFormula.
@Test
@LongRunningTag
public void testEvenLargerFormula() throws IOException, ParserException {
final FormulaFactory f = new FormulaFactory();
final Formula formula = FormulaReader.readPseudoBooleanFormula("src/test/resources/formulas/large_formula.txt", f);
final Formula cnf = formula.transform(new CNFFactorization());
final Formula subsumed = cnf.transform(new CNFSubsumption());
assertThat(f.equivalence(cnf, subsumed).holds(new TautologyPredicate(f))).isTrue();
assertThat(cnf.numberOfOperands() > subsumed.numberOfOperands()).isTrue();
}
use of org.logicng.LongRunningTag in project LogicNG by logic-ng.
the class AdvancedSimplifierTest method testCancellationPoints.
@LongRunningTag
@Test
public void testCancellationPoints() throws ParserException {
final FormulaFactory f = new FormulaFactory();
final Formula formula = f.parse("~v16 & ~v22 & ~v12 & (~v4 | ~v14) & (~v4 | ~v15) & (v3 | v4) & (v3 | ~v14) & (v3 | ~v15) " + "& (~v20 | ~v8) & (v9 | ~v20) & (~v21 | ~v8) & (v9 | ~v21) & (~v21 | ~v10) & (~v21 | ~v11) & v19");
for (int numOptimizationStarts = 1; numOptimizationStarts < 30; numOptimizationStarts++) {
for (int numSatHandlerStarts = 1; numSatHandlerStarts < 500; numSatHandlerStarts++) {
final OptimizationHandler handler = new BoundedOptimizationHandler(numSatHandlerStarts, numOptimizationStarts);
testHandler(handler, formula, true);
}
}
}
Aggregations