Search in sources :

Example 61 with TupleSet

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

the class ALG197 method bounds.

/**
 * Returns the bounds the problem (axioms 1, 4, 9-11, last formula of 14-15, and
 * first formula of 16-22).
 *
 * @return the bounds for the problem
 */
@Override
public final Bounds bounds() {
    final Bounds b = super.bounds();
    final TupleFactory f = b.universe().factory();
    final TupleSet op1h = b.upperBound(op1).clone();
    final TupleSet op2h = b.upperBound(op2).clone();
    // axiom
    final TupleSet op1l = f.setOf(f.tuple("e16", "e16", "e15"));
    // 14,
    // line
    // 6
    // axiom
    final TupleSet op2l = f.setOf(f.tuple("e26", "e26", "e25"));
    // 15,
    // line
    // 6
    op1h.removeAll(f.area(f.tuple("e16", "e16", "e10"), f.tuple("e16", "e16", "e16")));
    op1h.addAll(op1l);
    op2h.removeAll(f.area(f.tuple("e26", "e26", "e20"), f.tuple("e26", "e26", "e26")));
    op2h.addAll(op2l);
    b.bound(op1, op1l, op1h);
    b.bound(op2, op2l, op2h);
    final TupleSet high = f.area(f.tuple("e10", "e20"), f.tuple("e15", "e26"));
    // first line of axioms 16-22
    for (int i = 0; i < 7; i++) {
        Tuple t = f.tuple("e16", "e2" + i);
        high.add(t);
        b.bound(h[i], f.setOf(t), high);
        high.remove(t);
    }
    return b;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) TupleFactory(kodkod.instance.TupleFactory) Tuple(kodkod.instance.Tuple)

Example 62 with TupleSet

use of kodkod.instance.TupleSet 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 63 with TupleSet

use of kodkod.instance.TupleSet 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 64 with TupleSet

use of kodkod.instance.TupleSet 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 65 with TupleSet

use of kodkod.instance.TupleSet 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)

Aggregations

TupleSet (kodkod.instance.TupleSet)89 TupleFactory (kodkod.instance.TupleFactory)55 Bounds (kodkod.instance.Bounds)53 Universe (kodkod.instance.Universe)50 Relation (kodkod.ast.Relation)43 ArrayList (java.util.ArrayList)30 Formula (kodkod.ast.Formula)29 Solution (kodkod.engine.Solution)23 Solver (kodkod.engine.Solver)21 Expression (kodkod.ast.Expression)20 IntExpression (kodkod.ast.IntExpression)18 Variable (kodkod.ast.Variable)15 Instance (kodkod.instance.Instance)13 Tuple (kodkod.instance.Tuple)12 Decls (kodkod.ast.Decls)10 Sig (edu.mit.csail.sdg.ast.Sig)7 PrimSig (edu.mit.csail.sdg.ast.Sig.PrimSig)7 Evaluator (kodkod.engine.Evaluator)7 Field (edu.mit.csail.sdg.ast.Sig.Field)5 Map (java.util.Map)5