use of kodkod.engine.Solver in project org.alloytools.alloy by AlloyTools.
the class OverflowTheoremTest method solve.
protected Solution[] solve(Formula formula) {
Solution s1 = new Solver(options).solve(formula, bounds);
Options opt2 = options.clone();
opt2.setSkolemDepth(2);
// Solution s2 = new Solver(opt2).solve(formula, bounds);
return new Solution[] { s1 };
}
use of kodkod.engine.Solver in project org.alloytools.alloy by AlloyTools.
the class BenchmarkSymmStats2 method printGBP.
// <symm time (ms)> <# of symms> <state bits> <SAT|UNSAT> <SAT time (ms)>
private static void printGBP(Formula formula, Bounds bounds) {
final class SymmReporter extends AbstractReporter {
long gbpTime;
BigInteger symms;
@Override
public void detectingSymmetries(Bounds bounds) {
gbpTime = bean.getCurrentThreadUserTime();
}
@Override
public void detectedSymmetries(Set<IntSet> parts) {
final long end = bean.getCurrentThreadUserTime();
gbpTime = (end - gbpTime) / 1000000;
symms = new BigInteger("1");
for (IntSet s : parts) {
symms = symms.multiply(fact(s.size()));
}
// System.out.println(parts);
}
}
;
final SymmReporter reporter = new SymmReporter();
final Solver solver = new Solver();
solver.options().setBitwidth(8);
solver.options().setSolver(SATFactory.MiniSat);
solver.options().setReporter(reporter);
final Solution sol = solver.solve(formula, bounds);
// <gbp (ms)> <gbp (symms)>
System.out.print(reporter.gbpTime + "\t");
System.out.print(reporter.symms + "\t");
// <state bits> <SAT|UNSAT> <SAT time (ms)>
System.out.print(sol.stats().primaryVariables() + "\t");
System.out.print(sol.instance() == null ? "UNSAT\t" : "SAT\t");
System.out.print(sol.stats().solvingTime() + "\t");
}
use of kodkod.engine.Solver in project org.alloytools.alloy by AlloyTools.
the class BenchmarkSymmStats2 method printGAD.
// <symm time (ms)> <# of symms> <state bits> <SAT|UNSAT> <SAT time (ms)>
private static void printGAD(Formula formula, Bounds bounds) {
final class SymmReporter extends AbstractReporter {
String symms, time;
Bounds bounds;
@Override
public void detectingSymmetries(Bounds bounds) {
this.bounds = bounds.clone();
}
@Override
public void detectedSymmetries(Set<IntSet> parts) {
parts.clear();
final SymmInfo allSymms = allSymms(bounds);
parts.addAll(allSymms.parts);
symms = allSymms.symms;
time = allSymms.time;
// System.out.println(parts);
}
}
;
final SymmReporter reporter = new SymmReporter();
final Solver solver = new Solver();
solver.options().setBitwidth(8);
solver.options().setSolver(SATFactory.MiniSat);
solver.options().setReporter(reporter);
final Solution sol = solver.solve(formula, bounds);
// <gbp (ms)> <gbp (symms)>
System.out.print(reporter.time + "\t");
System.out.print(reporter.symms + "\t");
// <state bits> <SAT|UNSAT> <SAT time (ms)>
System.out.print(sol.stats().primaryVariables() + "\t");
System.out.print(sol.instance() == null ? "UNSAT\t" : "SAT\t");
System.out.print(sol.stats().solvingTime() + "\t");
}
use of kodkod.engine.Solver in project org.alloytools.alloy by AlloyTools.
the class UCoreStats method solver.
private static Solver solver() {
final Solver solver = new Solver();
solver.options().setBitwidth(8);
solver.options().setSolver(SATFactory.MiniSatProver);
solver.options().setLogTranslation(1);
return solver;
}
use of kodkod.engine.Solver in project org.alloytools.alloy by AlloyTools.
the class UCoreStats method checkMinimal.
/**
* Checks that the given proof of unsatisfiablity for the given problem is
* miminal. This method assumes that the given proof is correct.
*
* @return true if the core is minimal; false otherwise.
*/
static boolean checkMinimal(Set<Formula> core, Bounds bounds) {
System.out.print("checking minimality ... ");
final long start = System.currentTimeMillis();
final Set<Formula> minCore = new LinkedHashSet<Formula>(core);
Solver solver = solver();
solver.options().setSolver(SATFactory.MiniSat);
for (Iterator<Formula> itr = minCore.iterator(); itr.hasNext(); ) {
Formula f = itr.next();
Formula noF = Formula.TRUE;
for (Formula f1 : minCore) {
if (f != f1)
noF = noF.and(f1);
}
if (solver.solve(noF, bounds).instance() == null) {
itr.remove();
}
}
final long end = System.currentTimeMillis();
if (minCore.size() == core.size()) {
System.out.println("minimal (" + (end - start) + " ms).");
return true;
} else {
System.out.println("not minimal (" + (end - start) + " ms). The minimal core has these " + minCore.size() + " formulas:");
for (Formula f : minCore) {
System.out.println(" " + f);
}
return false;
}
}
Aggregations