use of kodkod.ast.Formula 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.ast.Formula in project org.alloytools.alloy by AlloyTools.
the class RingElection method looplessPath.
/**
* Returns the looplessPath predicate
*
* @return
*
* <pre>
* pred looplessPath () {no disj t, t': Time | toSend.t = toSend.t'}
* </pre>
*/
public Formula looplessPath() {
final Variable t1 = Variable.unary("t");
final Variable t2 = Variable.unary("t'");
// all t, t': Time | some t&t' || !(toSend.t = toSend.t')
final Formula f1 = t1.intersection(t2).some().or(toSend.join(t1).eq(toSend.join(t2)).not());
return f1.forAll(t1.oneOf(Time).and(t2.oneOf(Time)));
}
use of kodkod.ast.Formula 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.ast.Formula in project org.alloytools.alloy by AlloyTools.
the class Trees method statement5.
/**
* Returns statement 5.
*
* @return
*
* <pre>
* pred Statement5() {
* Acyclic() and
* all u,v: V | (u->v) not in E implies Cyclic(E + (u->v) + (v->u))
* }
* </pre>
*/
public final Formula statement5() {
final Variable u = Variable.unary("u");
final Variable v = Variable.unary("v");
final Formula f0 = u.product(v).in(E).not().implies(cyclic(E.union(u.product(v).union(v.product(u)))));
final Formula f1 = f0.forAll(u.oneOf(V).and(v.oneOf(V)));
return acyclic().and(f1);
}
use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.
the class Trees method declsAndFacts.
/**
* Returns the declarations and facts of the model.
*
* @return
*
* <pre>
* sig V { E: set V }
* fact UndirectedGraph { E = ~E }
* fact NonEmpty { some V }
* </pre>
*/
public final Formula declsAndFacts() {
final Formula f0 = E.in(V.product(V));
final Formula f1 = E.eq(E.transpose());
final Formula f2 = V.some();
return f0.and(f1).and(f2);
}
Aggregations