Search in sources :

Example 1 with Bounds

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

the class OverflowSigTest method createBounds.

protected void createBounds() {
    Collection<String> atoms = new ArrayList<String>(sAtoms.size() + xAtoms.size());
    atoms.addAll(sAtoms);
    atoms.addAll(xAtoms);
    final Universe universe = new Universe(atoms);
    this.factory = universe.factory();
    this.bounds = new Bounds(universe);
    TupleSet sTs = factory.setOf(sAtoms.toArray());
    TupleSet xTs = factory.setOf(xAtoms.toArray());
    bounds.bound(s, sTs);
    bounds.bound(x, xTs);
    bounds.bound(sa, sTs.product(xTs));
    bounds.bound(sb, sTs.product(xTs));
    bounds.bound(sc, sTs.product(xTs));
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) Universe(kodkod.instance.Universe)

Example 2 with Bounds

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

the class OverflowTheoremTest method setupBounds.

protected void setupBounds() {
    Relation ret = Relation.unary("ret");
    int min = min(bw);
    int max = max(bw);
    List<String> atoms = new ArrayList<String>(max - min + 1);
    for (int i = min; i <= max; i++) {
        atoms.add(String.valueOf(i));
    }
    final Universe universe = new Universe(atoms);
    TupleFactory factory = universe.factory();
    this.bounds = new Bounds(factory.universe());
    for (int i = min; i <= max; i++) {
        bounds.boundExactly(i, factory.setOf(String.valueOf(i)));
    }
    bounds.bound(ret, factory.noneOf(1), factory.allOf(1));
}
Also used : Relation(kodkod.ast.Relation) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 3 with Bounds

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

the class SymmetryBreakingTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    bounds = new Bounds(factory.universe());
}
Also used : Bounds(kodkod.instance.Bounds)

Example 4 with Bounds

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

the class BenchmarkSymmStats2 method printGBP.

// <symm time (ms)> <# of symms> <state bits> <SAT|UNSAT> <SAT time (ms)>
private static void printGBP(Formula formula, Bounds bounds) {
    final class SymmReporter extends AbstractReporter {

        long gbpTime;

        BigInteger symms;

        @Override
        public void detectingSymmetries(Bounds bounds) {
            gbpTime = bean.getCurrentThreadUserTime();
        }

        @Override
        public void detectedSymmetries(Set<IntSet> parts) {
            final long end = bean.getCurrentThreadUserTime();
            gbpTime = (end - gbpTime) / 1000000;
            symms = new BigInteger("1");
            for (IntSet s : parts) {
                symms = symms.multiply(fact(s.size()));
            }
        // System.out.println(parts);
        }
    }
    ;
    final SymmReporter reporter = new SymmReporter();
    final Solver solver = new Solver();
    solver.options().setBitwidth(8);
    solver.options().setSolver(SATFactory.MiniSat);
    solver.options().setReporter(reporter);
    final Solution sol = solver.solve(formula, bounds);
    // <gbp (ms)> <gbp (symms)>
    System.out.print(reporter.gbpTime + "\t");
    System.out.print(reporter.symms + "\t");
    // <state bits> <SAT|UNSAT> <SAT time (ms)>
    System.out.print(sol.stats().primaryVariables() + "\t");
    System.out.print(sol.instance() == null ? "UNSAT\t" : "SAT\t");
    System.out.print(sol.stats().solvingTime() + "\t");
}
Also used : Solver(kodkod.engine.Solver) LinkedHashSet(java.util.LinkedHashSet) TupleSet(kodkod.instance.TupleSet) IntTreeSet(kodkod.util.ints.IntTreeSet) IntSet(kodkod.util.ints.IntSet) Set(java.util.Set) IntSet(kodkod.util.ints.IntSet) Bounds(kodkod.instance.Bounds) AbstractReporter(kodkod.engine.config.AbstractReporter) BigInteger(java.math.BigInteger) Solution(kodkod.engine.Solution)

Example 5 with Bounds

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

the class BenchmarkSymmStats2 method printGAD.

// <symm time (ms)> <# of symms> <state bits> <SAT|UNSAT> <SAT time (ms)>
private static void printGAD(Formula formula, Bounds bounds) {
    final class SymmReporter extends AbstractReporter {

        String symms, time;

        Bounds bounds;

        @Override
        public void detectingSymmetries(Bounds bounds) {
            this.bounds = bounds.clone();
        }

        @Override
        public void detectedSymmetries(Set<IntSet> parts) {
            parts.clear();
            final SymmInfo allSymms = allSymms(bounds);
            parts.addAll(allSymms.parts);
            symms = allSymms.symms;
            time = allSymms.time;
        // System.out.println(parts);
        }
    }
    ;
    final SymmReporter reporter = new SymmReporter();
    final Solver solver = new Solver();
    solver.options().setBitwidth(8);
    solver.options().setSolver(SATFactory.MiniSat);
    solver.options().setReporter(reporter);
    final Solution sol = solver.solve(formula, bounds);
    // <gbp (ms)> <gbp (symms)>
    System.out.print(reporter.time + "\t");
    System.out.print(reporter.symms + "\t");
    // <state bits> <SAT|UNSAT> <SAT time (ms)>
    System.out.print(sol.stats().primaryVariables() + "\t");
    System.out.print(sol.instance() == null ? "UNSAT\t" : "SAT\t");
    System.out.print(sol.stats().solvingTime() + "\t");
}
Also used : Solver(kodkod.engine.Solver) LinkedHashSet(java.util.LinkedHashSet) TupleSet(kodkod.instance.TupleSet) IntTreeSet(kodkod.util.ints.IntTreeSet) IntSet(kodkod.util.ints.IntSet) Set(java.util.Set) Bounds(kodkod.instance.Bounds) AbstractReporter(kodkod.engine.config.AbstractReporter) Solution(kodkod.engine.Solution)

Aggregations

Bounds (kodkod.instance.Bounds)140 Formula (kodkod.ast.Formula)83 Universe (kodkod.instance.Universe)79 TupleFactory (kodkod.instance.TupleFactory)76 Solution (kodkod.engine.Solution)75 Solver (kodkod.engine.Solver)67 TupleSet (kodkod.instance.TupleSet)55 Relation (kodkod.ast.Relation)49 ArrayList (java.util.ArrayList)45 Expression (kodkod.ast.Expression)21 Variable (kodkod.ast.Variable)21 IntExpression (kodkod.ast.IntExpression)20 Instance (kodkod.instance.Instance)12 Decls (kodkod.ast.Decls)11 Evaluator (kodkod.engine.Evaluator)8 HigherOrderDeclException (kodkod.engine.fol2sat.HigherOrderDeclException)7 UnboundLeafException (kodkod.engine.fol2sat.UnboundLeafException)7 ConsoleReporter (kodkod.engine.config.ConsoleReporter)6 Tuple (kodkod.instance.Tuple)6 LinkedHashSet (java.util.LinkedHashSet)5