use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.
the class AbstractWorldDefinitions method main.
/**
* Usage: java examples.AbstractWorldDefinitions [A241 | AbOp_total |
* AbIgnore_inv | AbTransfer_inv] [univ size]
*/
public static void main(String[] args) {
if (args.length < 2)
usage();
try {
final String assertion = args[0];
final int n = Integer.parseInt(args[1]);
if (n < 1)
usage();
final AbstractWorldDefinitions model = new AbstractWorldDefinitions();
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSat);
solver.options().setReporter(new ConsoleReporter());
// solver.options().setFlatten(true);
final Method method = model.getClass().getMethod(assertion);
final Formula f = model.decls().and(((Formula) method.invoke(model)).not());
final Bounds b = model.bounds(n);
System.out.println(f);
final Solution sol = solver.solve(f, b);
System.out.println(sol);
} catch (NumberFormatException nfe) {
usage();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
usage();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.
the class DNACuts method main.
/**
* Usage: java examples.alloy.DNACuts [cut chain length] [# links]
*/
public static void main(String[] args) {
if (args.length < 2)
usage();
try {
final DNACuts model = new DNACuts(Integer.parseInt(args[0]));
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.DefaultSAT4J);
Formula f = model.show();
Bounds b = model.bounds(Integer.parseInt(args[1]));
System.out.println("solving...");
Solution sol = solver.solve(f, b);
// System.out.println(f);
// System.out.println(b);
System.out.println(sol.outcome());
System.out.println(sol.stats());
} catch (NumberFormatException nfe) {
usage();
}
}
use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.
the class SET948 method main.
/**
* Usage: java examples.tptp.SET948 [univ size]
*/
public static void main(String[] args) {
if (args.length < 1)
usage();
try {
final int n = Integer.parseInt(args[0]);
if (n < 1)
usage();
final SET948 model = new SET948();
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSat);
// solver.options().setSymmetryBreaking(n*n);
// solver.options().setFlatten(false);
final Formula f = model.checkT101_zfmisc_1();
final Bounds b = model.bounds(n);
System.out.println(f);
final Solution sol = solver.solve(f, b);
System.out.println(sol);
} catch (NumberFormatException nfe) {
usage();
}
}
use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.
the class GEO159 method main.
/**
* Usage: ava examples.tptp.GEO159 [scope]
*/
public static void main(String[] args) {
if (args.length < 1)
usage();
try {
final int n = Integer.parseInt(args[0]);
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSat);
final GEO159 model = new GEO159();
final Formula f = model.checkDefs();
final Bounds b = model.bounds(n);
final Solution sol = solver.solve(f, b);
System.out.println(sol);
} catch (NumberFormatException nfe) {
usage();
}
}
use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.
the class KK method main.
public static void main(String[] args) throws Exception {
Relation x6 = Relation.unary("R");
int[] ints = new int[] { 0, 1, 2 };
List<Object> atomlist = new LinkedList<Object>();
atomlist.add("R$0");
atomlist.add("R$1");
atomlist.add("R$2");
for (int i : ints) atomlist.add(i);
Universe universe = new Universe(atomlist);
TupleFactory factory = universe.factory();
Bounds bounds = new Bounds(universe);
TupleSet x6_upper = factory.noneOf(1);
x6_upper.add(factory.tuple("R$0"));
x6_upper.add(factory.tuple("R$1"));
x6_upper.add(factory.tuple("R$2"));
bounds.bound(x6, x6_upper);
for (int i : ints) {
bounds.boundExactly(i, factory.setOf(i));
}
Formula x11 = x6.some();
IntExpression x5 = x6.count();
Formula x9 = x11.implies(x5.gt(IntConstant.constant(0)));
Formula x7 = x9.not();
Solver solver = new Solver();
solver.options().setSolver(SATFactory.DefaultSAT4J);
solver.options().setBitwidth(2);
// solver.options().setFlatten(false);
solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);
solver.options().setSymmetryBreaking(20);
solver.options().setSkolemDepth(0);
System.out.println("Solving...");
System.out.println(PrettyPrinter.print(x7, 0));
System.out.println(bounds);
Solution sol = solver.solve(x7, bounds);
System.out.println(sol.toString());
Instance inst = sol.instance();
Evaluator ev = new Evaluator(inst);
System.out.println(ev.evaluate(x6.some()));
System.out.println(ev.evaluate(x5));
System.out.println(ev.evaluate(x5.gt(IntConstant.constant(0))));
System.out.println(ev.evaluate(x6.some().implies(x5.gt(IntConstant.constant(0))).not()));
System.out.println(ev.evaluate(x7));
}
Aggregations