use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.
the class GEO158 method bounds.
/**
* Returns a bounds with the given number of maximum curves and points
*
* @return a bounds with the given number of maximum curves and points
*/
public Bounds bounds(int scope) {
assert scope > 0;
List<String> atoms = new ArrayList<String>(scope);
for (int i = 0; i < scope; i++) atoms.add("c" + i);
for (int i = 0; i < scope; i++) atoms.add("p" + i);
final Universe u = new Universe(atoms);
final TupleFactory f = u.factory();
final Bounds b = new Bounds(u);
final TupleSet c = f.range(f.tuple("c0"), f.tuple("c" + (scope - 1)));
final TupleSet p = f.range(f.tuple("p0"), f.tuple("p" + (scope - 1)));
final TupleSet cc = c.product(c), pc = p.product(c);
b.bound(curve, c);
b.bound(point, p);
b.bound(partOf, cc);
b.bound(incident, pc);
b.bound(sum, c.product(cc));
b.bound(endPoint, pc);
b.bound(innerPoint, pc);
b.bound(meet, pc.product(c));
b.bound(closed, c);
b.bound(open, c);
return b;
}
use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.
the class GRA013_026 method main.
/**
* Usage: java examples.tptp.GRA013_026 <graph size> <clique size>
*/
public static void main(String[] args) {
if (args.length < 2)
usage();
try {
final GRA013_026 model = new GRA013_026(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
final Bounds b = model.bounds();
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSat);
solver.options().setReporter(new ConsoleReporter());
final Formula f = model.checkGoalToBeProved();
System.out.println(PrettyPrinter.print(f, 2));
// System.out.println(b);
final Solution s = solver.solve(f, b);
System.out.println(s);
// System.out.println((new Evaluator(s.instance())).evaluate(f));
} catch (HigherOrderDeclException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnboundLeafException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NumberFormatException nfe) {
usage();
}
}
use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.
the class GRA013_026 method bounds.
/**
* Returns the bounds.
*
* @return the bounds
*/
public final Bounds bounds() {
final List<String> atoms = new ArrayList<String>(graphSize);
for (int i = 1; i <= graphSize; i++) atoms.add("n" + i);
atoms.add("goal");
final Universe u = new Universe(atoms);
final TupleFactory f = u.factory();
final Bounds b = new Bounds(u);
b.bound(goal, f.setOf("goal"));
final TupleSet ns = f.range(f.tuple("n1"), f.tuple("n" + graphSize));
b.boundExactly(node, ns);
final TupleSet s = f.noneOf(2);
for (int i = 1; i < graphSize; i++) {
for (int j = i + 1; j < graphSize; j++) s.add(f.tuple("n" + i, "n" + j));
}
b.boundExactly(lessThan, s);
b.bound(red, s);
b.bound(green, s);
return b;
}
use of kodkod.instance.Bounds 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.instance.Bounds 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();
}
}
Aggregations