use of kodkod.engine.Solver in project org.alloytools.alloy by AlloyTools.
the class Handshake method main.
/**
* Usage: java examples.Handshake [# persons, must be >= 2]
*/
public static void main(String[] args) {
if (args.length < 1)
usage();
final Handshake model = new Handshake();
final Solver solver = new Solver();
try {
final int persons = Integer.parseInt(args[0]);
if (persons < 2)
usage();
solver.options().setBitwidth(6);
// solver.options().setSolver(SATFactory.ZChaff);
solver.options().setSolver(SATFactory.MiniSat);
solver.options().setSymmetryBreaking(0);
solver.options().setBitwidth(32 - Integer.numberOfLeadingZeros(persons));
solver.options().setReporter(new ConsoleReporter());
final Bounds b = model.bounds(persons);
// .and(model.Person.count().eq(IntConstant.constant(persons)));
final Formula f = model.runPuzzle();
Solution sol = solver.solve(f, b);
System.out.println(sol);
} catch (NumberFormatException nfe) {
usage();
}
}
use of kodkod.engine.Solver in project org.alloytools.alloy by AlloyTools.
the class Lists method main.
/**
* Usage: java examples.Lists [scope]
*/
public static void main(String[] args) {
if (args.length < 1)
usage();
try {
final int n = Integer.parseInt(args[0]);
final Lists model = new Lists();
final Bounds b = model.bounds(n);
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSat);
// solver.options().setFlatten(false);
// solver.options().setSkolemize(false);
Formula f = model.runShow();
System.out.println("running show");
Solution s = solver.solve(f, b);
System.out.println(s);
f = model.checkEmpties();
System.out.println("checking empties");
s = solver.solve(f, b);
System.out.println(s);
f = model.checkReflexive();
System.out.println("checking reflexive");
s = solver.solve(f, b);
System.out.println(s);
f = model.checkSymmetric();
System.out.println("checking symmetric");
s = solver.solve(f, b);
System.out.println(s);
} catch (NumberFormatException nfe) {
usage();
} catch (HigherOrderDeclException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnboundLeafException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of kodkod.engine.Solver in project org.alloytools.alloy by AlloyTools.
the class RingElection method main.
/**
* Usage: java examples.RingElection [# processes] [# times]
*/
public static void main(String[] args) {
if (args.length < 2)
usage();
try {
final RingElection model = new RingElection();
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSat);
final int p = Integer.parseInt(args[0]);
final int t = Integer.parseInt(args[1]);
final Formula checkAtMostOneElected = model.checkAtMostOneElected();
final Bounds boundspt = model.bounds(p, t);
System.out.println("*****check AtMostOneElected for " + p + " Process, " + t + " Time*****");
Solution sol1 = solver.solve(checkAtMostOneElected, boundspt);
System.out.println(sol1);
// // run looplessPath for 13 Time, 3 Process
// final Formula runLooplessPath =
// model.declsAndFacts();//.and(model.looplessPath());
// final Bounds bounds313 = model.bounds(p, t);
// System.out.println("*****run looplessPath for 13 Time, 3
// Process*****");
// System.out.println(runLooplessPath);
// System.out.println(bounds313);
// Solution sol2 = solver.solve(runLooplessPath, bounds313);
// System.out.println(sol2);
} catch (NumberFormatException nfe) {
usage();
}
}
use of kodkod.engine.Solver in project org.alloytools.alloy by AlloyTools.
the class ToyFilesystem method main.
/**
* Usage: java examples.alloy.ToyFilesystem
*/
public static void main(String[] args) {
final ToyFilesystem toy = new ToyFilesystem();
final Formula f = toy.constraints();
System.out.println(PrettyPrinter.print(f, 2));
final Bounds b = toy.bounds();
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSat);
final Solution s = solver.solve(f, b);
System.out.println(s);
}
use of kodkod.engine.Solver in project org.alloytools.alloy by AlloyTools.
the class IntConstraints method main.
/**
* Usage: java examples.IntConstraints
*/
public static void main(String[] args) {
final IntConstraints model = new IntConstraints();
final Bounds bounds = model.bounds();
final Formula formula = model.formula();
final Solver solver = new Solver();
solver.options().setBitwidth(32);
solver.options().setSolver(SATFactory.MiniSat);
final Solution sol = solver.solve(formula, bounds);
model.print(sol, solver.options());
}
Aggregations