Search in sources :

Example 51 with Universe

use of kodkod.instance.Universe 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;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 52 with Universe

use of kodkod.instance.Universe 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;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 53 with Universe

use of kodkod.instance.Universe in project org.alloytools.alloy by AlloyTools.

the class Dijkstra method bounds.

/**
 * Returns the bounds corresponding to the given scopes.
 *
 * @return bounds
 */
public Bounds bounds(int states, int processes, int mutexes) {
    final List<String> atoms = new ArrayList<String>(states + processes + mutexes);
    for (int i = 0; i < states; i++) {
        atoms.add("State" + i);
    }
    for (int i = 0; i < processes; i++) {
        atoms.add("Process" + i);
    }
    for (int i = 0; i < mutexes; i++) {
        atoms.add("Mutex" + i);
    }
    final Universe u = new Universe(atoms);
    final TupleFactory f = u.factory();
    final Bounds b = new Bounds(u);
    final TupleSet sb = f.range(f.tuple("State0"), f.tuple("State" + (states - 1)));
    final TupleSet pb = f.range(f.tuple("Process0"), f.tuple("Process" + (processes - 1)));
    final TupleSet mb = f.range(f.tuple("Mutex0"), f.tuple("Mutex" + (mutexes - 1)));
    b.bound(State, sb);
    b.bound(holds, sb.product(pb).product(mb));
    b.bound(waits, sb.product(pb).product(mb));
    b.bound(sfirst, sb);
    b.bound(slast, sb);
    b.bound(sord, sb.product(sb));
    b.bound(Process, pb);
    b.bound(Mutex, mb);
    b.bound(mfirst, mb);
    b.bound(mlast, mb);
    b.bound(mord, mb.product(mb));
    return b;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 54 with Universe

use of kodkod.instance.Universe in project org.alloytools.alloy by AlloyTools.

the class NUM374 method bounds.

/**
 * Returns the bounds for the given scope.
 *
 * @return bounds for the given scope
 */
public final Bounds bounds(int n) {
    assert n > 0;
    final List<String> atoms = new ArrayList<String>(n);
    for (int i = 0; i < n; i++) atoms.add("a" + i);
    final Universe u = new Universe(atoms);
    final Bounds b = new Bounds(u);
    final TupleFactory f = u.factory();
    final TupleSet all3 = f.allOf(3);
    b.bound(sum, all3);
    b.bound(product, all3);
    b.bound(exponent, all3);
    b.bound(n1, f.allOf(1));
    return b;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 55 with Universe

use of kodkod.instance.Universe in project org.alloytools.alloy by AlloyTools.

the class Quasigroups7 method bounds.

/**
 * Returns the partial bounds the problem (axioms 1, 4, 9-11).
 *
 * @return the partial bounds for the problem
 */
public Bounds bounds() {
    final List<String> atoms = new ArrayList<String>(14);
    for (int i = 0; i < 7; i++) atoms.add("e1" + i);
    for (int i = 0; i < 7; i++) atoms.add("e2" + i);
    final Universe u = new Universe(atoms);
    final Bounds b = new Bounds(u);
    final TupleFactory f = u.factory();
    b.boundExactly(s1, f.range(f.tuple("e10"), f.tuple("e16")));
    b.boundExactly(s2, f.range(f.tuple("e20"), f.tuple("e26")));
    // axioms 9, 10, 11
    for (int i = 0; i < 7; i++) {
        b.boundExactly(e1[i], f.setOf("e1" + i));
        b.boundExactly(e2[i], f.setOf("e2" + i));
    }
    // axom 1
    final TupleSet op1h = f.area(f.tuple("e10", "e10", "e10"), f.tuple("e16", "e16", "e16"));
    // axiom 4
    final TupleSet op2h = f.area(f.tuple("e20", "e20", "e20"), f.tuple("e26", "e26", "e26"));
    b.bound(op1, op1h);
    b.bound(op2, op2h);
    return b;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Aggregations

Universe (kodkod.instance.Universe)83 Bounds (kodkod.instance.Bounds)79 TupleFactory (kodkod.instance.TupleFactory)77 TupleSet (kodkod.instance.TupleSet)50 ArrayList (java.util.ArrayList)46 Relation (kodkod.ast.Relation)45 Formula (kodkod.ast.Formula)37 Solution (kodkod.engine.Solution)32 Solver (kodkod.engine.Solver)26 Variable (kodkod.ast.Variable)21 Expression (kodkod.ast.Expression)20 IntExpression (kodkod.ast.IntExpression)20 Instance (kodkod.instance.Instance)14 Decls (kodkod.ast.Decls)11 Evaluator (kodkod.engine.Evaluator)9 LinkedList (java.util.LinkedList)4 Tuple (kodkod.instance.Tuple)4 LinkedHashSet (java.util.LinkedHashSet)3 Map (java.util.Map)2 Set (java.util.Set)2