Java Code Examples for kodkod.engine.Evaluator#evaluate()
The following examples show how to use
kodkod.engine.Evaluator#evaluate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockedNQueens2.java From kodkod with MIT License | 6 votes |
/** * Prints the given solution using the given options to the console */ void print(Instance instance, Options options) { final Evaluator eval = new Evaluator(instance, options); final int n = instance.universe().size(); for(int i = 0; i < n; i++) { Expression x = IntConstant.constant(i).toExpression(); for(int j = 0; j < n; j++) { Expression y = IntConstant.constant(j).toExpression(); if (eval.evaluate(x.product(y).in(queen))) { System.out.print(" Q"); } else { System.out.print(" ."); } } System.out.println(); } // System.out.println(instance); }
Example 2
Source File: BlockedNQueens.java From kodkod with MIT License | 6 votes |
/** * Prints the given solution using the given options to the console */ void print(Instance instance, Options options) { final Evaluator eval = new Evaluator(instance, options); final int n = instance.tuples(queen).size(); for(int i = 0; i < n; i++) { Expression ci = IntConstant.constant(i).toExpression(); for(int j = 0; j < n; j++) { Expression cj = IntConstant.constant(j).toExpression(); if (eval.evaluate(x.join(ci).intersection(y.join(cj)).some())) { System.out.print(" Q"); } else { System.out.print(" ."); } } System.out.println(); } // System.out.println(instance); }
Example 3
Source File: NQueens.java From kodkod with MIT License | 6 votes |
/** * Prints the given solution */ void print(Instance instance, Options options) { final Evaluator eval = new Evaluator(instance, options); for(int i = 0; i < n; i++) { Expression ci = IntConstant.constant(i).toExpression(); for(int j = 0; j < n; j++) { Expression cj = IntConstant.constant(j).toExpression(); if (eval.evaluate(x.join(ci).intersection(y.join(cj)).some())) { System.out.print(" Q"); } else { System.out.print(" ."); } } System.out.println(); } // System.out.println(instance); }
Example 4
Source File: NQueens.java From kodkod with MIT License | 6 votes |
/** * Prints the given solution */ void print(Instance instance, Options options) { final Evaluator eval = new Evaluator(instance, options); for(int i = 0; i < n; i++) { IntExpression ci = IntConstant.constant(i); for(int j = 0; j < n; j++) { IntExpression cj = IntConstant.constant(j); Variable q = Variable.unary("q"); if (eval.evaluate(q.join(x).sum().eq(ci).and(q.join(y).sum().eq(cj)).forSome(q.oneOf(queen)))) { System.out.print(" Q"); } else { System.out.print(" ."); } } System.out.println(); } }
Example 5
Source File: NQueens.java From kodkod with MIT License | 6 votes |
/** * Prints the given solution */ void print(Instance instance, Options options) { final Evaluator eval = new Evaluator(instance, options); for(int i = 0; i < n; i++) { Expression ci = IntConstant.constant(i).toExpression(); for(int j = 0; j < n; j++) { Expression cj = IntConstant.constant(j).toExpression(); if (eval.evaluate(x.join(ci).intersection(y.join(cj)).some())) { System.out.print(" Q"); } else { System.out.print(" ."); } } System.out.println(); } }
Example 6
Source File: IntConstraints.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Prints the solution to the screen. */ private final void print(Solution sol, Options options) { System.out.println(sol.stats()); final Evaluator eval = new Evaluator(sol.instance(), options); final long mask = -1L >>> 32; for (int i = 0; i < 1000; i++) { long min = (low + 10 * i) & mask, max = (min + 10) & mask; long result = eval.evaluate(var[i].sum()) & mask; System.out.println(min + " <= [var_" + (i + 1) + "=" + result + "] <= " + max); } }
Example 7
Source File: ConfigAssure.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Displays an instance obtained with the given options. * * @requires inst != null and opt != null */ private final void display(Instance inst, Options opt) { final Universe univ = inst.universe(); final Evaluator eval = new Evaluator(inst, opt); final TupleFactory factory = univ.factory(); final List<TupleSet> subnets = new ArrayList<TupleSet>(); System.out.println("address\t\tnetwork id\tmask\tdevice-interface"); for (int i = 0, ports = univ.size() - 32; i < ports; i++) { final Object atom = univ.atom(i); final Relation p = Relation.unary(atom.toString()); inst.add(p, factory.setOf(atom)); System.out.print(toQuad(eval.evaluate(addr(p))) + "\t"); System.out.print(toQuad(eval.evaluate(netid(p))) + "\t"); System.out.print(eval.evaluate(implicitMask(p)) + "\t"); System.out.println(p); final TupleSet members = eval.evaluate(subnet(p)); if (!members.isEmpty()) subnets.add(members); } System.out.println("\nsubnets:"); for (TupleSet sub : subnets) { System.out.println(sub); } }
Example 8
Source File: BugTests.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
public final void testFelix_01032007() { List<String> atomlist = Arrays.asList("-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "0", "1", "2", "3", "4", "5", "6", "7"); Universe universe = new Universe(atomlist); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); bounds.boundExactly(-8, factory.range(factory.tuple("-8"), factory.tuple("-8"))); bounds.boundExactly(-7, factory.range(factory.tuple("-7"), factory.tuple("-7"))); bounds.boundExactly(-6, factory.range(factory.tuple("-6"), factory.tuple("-6"))); bounds.boundExactly(-5, factory.range(factory.tuple("-5"), factory.tuple("-5"))); bounds.boundExactly(-4, factory.range(factory.tuple("-4"), factory.tuple("-4"))); bounds.boundExactly(-3, factory.range(factory.tuple("-3"), factory.tuple("-3"))); bounds.boundExactly(-2, factory.range(factory.tuple("-2"), factory.tuple("-2"))); bounds.boundExactly(-1, factory.range(factory.tuple("-1"), factory.tuple("-1"))); bounds.boundExactly(0, factory.range(factory.tuple("0"), factory.tuple("0"))); bounds.boundExactly(1, factory.range(factory.tuple("1"), factory.tuple("1"))); bounds.boundExactly(2, factory.range(factory.tuple("2"), factory.tuple("2"))); bounds.boundExactly(3, factory.range(factory.tuple("3"), factory.tuple("3"))); bounds.boundExactly(4, factory.range(factory.tuple("4"), factory.tuple("4"))); bounds.boundExactly(5, factory.range(factory.tuple("5"), factory.tuple("5"))); bounds.boundExactly(6, factory.range(factory.tuple("6"), factory.tuple("6"))); bounds.boundExactly(7, factory.range(factory.tuple("7"), factory.tuple("7"))); Expression set = IntConstant.constant(8).toExpression(); Solver solver = new Solver(); solver.options().setSolver(SATFactory.DefaultSAT4J); solver.options().setBitwidth(4); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); Solution sol = solver.solve(set.some(), bounds); assertNotNull("expected SATISFIABLE but was " + sol.outcome(), sol.instance()); Evaluator eval = new Evaluator(sol.instance(), solver.options()); TupleSet ts = eval.evaluate(set); assertFalse(ts.size() == 0); }
Example 9
Source File: RegressionTests.java From kodkod with MIT License | 5 votes |
@Test public final void testFelix_01032007() { List<String> atomlist = Arrays.asList( "-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "0", "1", "2", "3", "4", "5", "6", "7"); Universe universe = new Universe(atomlist); TupleFactory factory = universe.factory(); Bounds bounds = new Bounds(universe); bounds.boundExactly(-8,factory.range(factory.tuple("-8"),factory.tuple("-8"))); bounds.boundExactly(-7,factory.range(factory.tuple("-7"),factory.tuple("-7"))); bounds.boundExactly(-6,factory.range(factory.tuple("-6"),factory.tuple("-6"))); bounds.boundExactly(-5,factory.range(factory.tuple("-5"),factory.tuple("-5"))); bounds.boundExactly(-4,factory.range(factory.tuple("-4"),factory.tuple("-4"))); bounds.boundExactly(-3,factory.range(factory.tuple("-3"),factory.tuple("-3"))); bounds.boundExactly(-2,factory.range(factory.tuple("-2"),factory.tuple("-2"))); bounds.boundExactly(-1,factory.range(factory.tuple("-1"),factory.tuple("-1"))); bounds.boundExactly(0,factory.range(factory.tuple("0"),factory.tuple("0"))); bounds.boundExactly(1,factory.range(factory.tuple("1"),factory.tuple("1"))); bounds.boundExactly(2,factory.range(factory.tuple("2"),factory.tuple("2"))); bounds.boundExactly(3,factory.range(factory.tuple("3"),factory.tuple("3"))); bounds.boundExactly(4,factory.range(factory.tuple("4"),factory.tuple("4"))); bounds.boundExactly(5,factory.range(factory.tuple("5"),factory.tuple("5"))); bounds.boundExactly(6,factory.range(factory.tuple("6"),factory.tuple("6"))); bounds.boundExactly(7,factory.range(factory.tuple("7"),factory.tuple("7"))); Expression set=IntConstant.constant(8).toExpression(); Solver solver = new Solver(); solver.options().setSolver(SATFactory.DefaultSAT4J); solver.options().setBitwidth(4); solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT); Solution sol = solver.solve(set.some(), bounds); Evaluator eval = new Evaluator(sol.instance(), solver.options()); TupleSet ts = eval.evaluate(set); assertFalse(ts.size()==0); }
Example 10
Source File: HOLSome4AllTest.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
protected int eval(Solution sol, IntExpression ie) { Evaluator ev = new Evaluator(sol.instance()); return ev.evaluate(ie); }
Example 11
Source File: HOLSome4AllTest.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
protected TupleSet eval(Solution sol, Expression e) { Evaluator ev = new Evaluator(sol.instance()); return ev.evaluate(e); }
Example 12
Source File: HamiltonianCycle.java From kodkod with MIT License | 4 votes |
private final boolean verify(Instance instance) { final Evaluator eval = new Evaluator(instance); System.out.println(eval.evaluate(cycle)); return eval.evaluate(cycleDefinition()); }