Search in sources :

Example 31 with IntExpression

use of kodkod.ast.IntExpression in project org.alloytools.alloy by AlloyTools.

the class IntTest method nonConstants.

private IntExpression[] nonConstants() {
    final Options options = solver.options();
    final IntRange range = options.integers();
    final int min = range.min(), max = range.max();
    final int size = range.size();
    final Relation[] r = new Relation[size];
    final TupleFactory f = bounds.universe().factory();
    for (int i = 0; i < size; i++) {
        int arity = i % 3 + 1;
        r[i] = Relation.nary("r" + i, arity);
        TupleSet b = f.noneOf(arity);
        for (int j = (i / 3) * ((int) Math.pow(SIZE, arity - 1)), jmax = j + size; j < jmax; j++) {
            b.add(f.tuple(arity, j % b.capacity()));
        }
        bounds.bound(r[i], b);
    }
    final IntExpression[] vals = new IntExpression[max - min + 1];
    for (int i = 0; i < size; i++) {
        vals[i] = i + min < 0 ? r[i].count().negate() : r[i].count();
    }
    return vals;
}
Also used : Options(kodkod.engine.config.Options) TupleSet(kodkod.instance.TupleSet) Relation(kodkod.ast.Relation) IntExpression(kodkod.ast.IntExpression) IntRange(kodkod.util.ints.IntRange) TupleFactory(kodkod.instance.TupleFactory)

Example 32 with IntExpression

use of kodkod.ast.IntExpression in project org.alloytools.alloy by AlloyTools.

the class IntTest method constants.

private IntExpression[] constants() {
    final Options options = solver.options();
    final IntRange range = options.integers();
    final int min = range.min(), max = range.max();
    final IntExpression[] vals = new IntExpression[max - min + 1];
    for (int i = min; i <= max; i++) {
        vals[i - min] = constant(i);
    }
    return vals;
}
Also used : Options(kodkod.engine.config.Options) IntExpression(kodkod.ast.IntExpression) IntRange(kodkod.util.ints.IntRange)

Aggregations

IntExpression (kodkod.ast.IntExpression)32 Formula (kodkod.ast.Formula)16 Expression (kodkod.ast.Expression)13 BinaryIntExpression (kodkod.ast.BinaryIntExpression)11 IfIntExpression (kodkod.ast.IfIntExpression)11 NaryIntExpression (kodkod.ast.NaryIntExpression)11 UnaryIntExpression (kodkod.ast.UnaryIntExpression)11 Decls (kodkod.ast.Decls)10 BinaryExpression (kodkod.ast.BinaryExpression)8 Variable (kodkod.ast.Variable)8 Solution (kodkod.engine.Solution)8 QuantifiedFormula (kodkod.ast.QuantifiedFormula)7 Relation (kodkod.ast.Relation)7 TupleFactory (kodkod.instance.TupleFactory)6 TupleSet (kodkod.instance.TupleSet)6 SumExpression (kodkod.ast.SumExpression)5 Solver (kodkod.engine.Solver)5 Bounds (kodkod.instance.Bounds)5 Universe (kodkod.instance.Universe)5 ConstantExpression (kodkod.ast.ConstantExpression)4