use of org.logicng.LongRunningTag in project LogicNG by logic-ng.
the class CCIncrementalFormulaTest method testVeryLargeModularTotalizerAMK.
@Test
@LongRunningTag
public void testVeryLargeModularTotalizerAMK() {
final CCEncoder encoder = this.encoders[2];
final CCEncoder initivalEncoder = new CCEncoder(this.f);
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 Pair<List<Formula>, CCIncrementalData> cc = encoder.encodeIncremental((CardinalityConstraint) this.f.cc(CType.LE, currentBound, vars));
final CCIncrementalData incData = cc.second();
final SATSolver solver = this.solvers[3];
solver.reset();
solver.add(initivalEncoder.encode((CardinalityConstraint) this.f.cc(CType.GE, 234, vars)));
solver.add(cc.first());
// search the lower bound
while (solver.sat() == Tristate.TRUE) {
solver.add(incData.newUpperBound(--currentBound));
}
assertThat(currentBound).isEqualTo(233);
}
use of org.logicng.LongRunningTag in project LogicNG by logic-ng.
the class CCIncrementalSolverTest method testLargeModularTotalizerAMK.
@Test
@LongRunningTag
public void testLargeModularTotalizerAMK() {
for (final SATSolver solver : this.solvers) {
if (solver != null) {
this.f.putConfiguration(this.configs[2]);
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);
}
solver.reset();
// >= 42
solver.add(this.f.cc(CType.GE, 42, vars));
final CCIncrementalData incData = solver.addIncrementalCC((CardinalityConstraint) this.f.cc(CType.LE, currentBound, vars));
// search the lower bound
while (solver.sat() == Tristate.TRUE) {
// <= currentBound - 1
incData.newUpperBoundForSolver(--currentBound);
}
assertThat(currentBound).isEqualTo(41);
}
}
}
use of org.logicng.LongRunningTag in project LogicNG by logic-ng.
the class CCPerformanceTest method testAMKPerformance.
@Test
@LongRunningTag
public void testAMKPerformance() {
for (final CCConfig config : this.configs) {
final FormulaFactory f = new FormulaFactory();
f.putConfiguration(config);
buildAMK(10_000, f, false);
assertThat(f.newCCVariable().name()).endsWith("_0");
}
}
use of org.logicng.LongRunningTag in project LogicNG by logic-ng.
the class CCAMKTest method testLargeAMK.
@Test
@LongRunningTag
public void testLargeAMK() {
final FormulaFactory f = new FormulaFactory();
int counter = 0;
for (final CCConfig config : this.configs) {
f.putConfiguration(config);
testCC(150, 2, 1 + 150 + 11175, f, false);
assertThat(f.newCCVariable().name()).endsWith("_" + counter++);
}
}
use of org.logicng.LongRunningTag in project LogicNG by logic-ng.
the class SATTest method testDimacsFilesWithSelectionOrder.
@Test
@LongRunningTag
public void testDimacsFilesWithSelectionOrder() throws IOException {
final Map<String, Boolean> expectedResults = new HashMap<>();
final BufferedReader reader = new BufferedReader(new FileReader("src/test/resources/sat/results.txt"));
while (reader.ready()) {
final String[] tokens = reader.readLine().split(";");
expectedResults.put(tokens[0], Boolean.valueOf(tokens[1]));
}
final File testFolder = new File("src/test/resources/sat");
final File[] files = testFolder.listFiles();
assert files != null;
for (final SATSolver solver : this.solvers) {
for (final File file : files) {
final String fileName = file.getName();
if (fileName.endsWith(".cnf")) {
readCNF(solver, file);
final List<Literal> selectionOrder = new ArrayList<>();
for (final Variable var : FormulaHelper.variables(solver.execute(FormulaOnSolverFunction.get()))) {
if (selectionOrder.size() < 10) {
selectionOrder.add(var.negate());
}
}
final boolean res = solver.satWithSelectionOrder(selectionOrder) == Tristate.TRUE;
assertThat(res).isEqualTo(expectedResults.get(fileName));
if (expectedResults.get(fileName)) {
final Assignment assignment = solver.model();
testLocalMinimum(solver, assignment, selectionOrder);
testHighestLexicographicalAssignment(solver, assignment, selectionOrder);
}
}
}
solver.reset();
}
}
Aggregations