Search in sources :

Example 1 with Solution

use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.

the class OverflowSigTest method testOverBw.

@Test
public void testOverBw() {
    IntOperator[] ops = new IntOperator[] { IntOperator.PLUS, IntOperator.MULTIPLY };
    for (IntOperator op : ops) {
        for (int i = 1; i < 6; i++) {
            Solution solution = checkForBw(op, i);
            assertNoInstance(solution);
        }
    }
}
Also used : Solution(kodkod.engine.Solution) IntOperator(kodkod.ast.operator.IntOperator) Test(org.junit.Test)

Example 2 with Solution

use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.

the class OverflowTheoremTest method solve.

protected Solution[] solve(Formula formula) {
    Solution s1 = new Solver(options).solve(formula, bounds);
    Options opt2 = options.clone();
    opt2.setSkolemDepth(2);
    // Solution s2 = new Solver(opt2).solve(formula, bounds);
    return new Solution[] { s1 };
}
Also used : Options(kodkod.engine.config.Options) Solver(kodkod.engine.Solver) Solution(kodkod.engine.Solution)

Example 3 with Solution

use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.

the class SymmetryBreakingTest method solve.

private Instance solve(Formula f, Bounds b) {
    final Solution sol = solver.solve(f, b);
    final Statistics stats = sol.stats();
    pVars = stats.primaryVariables();
    iVars = stats.variables() - pVars;
    clauses = stats.clauses();
    return sol.instance();
}
Also used : Statistics(kodkod.engine.Statistics) Solution(kodkod.engine.Solution)

Example 4 with Solution

use of kodkod.engine.Solution 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 Solution

use of kodkod.engine.Solution 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

Solution (kodkod.engine.Solution)153 Formula (kodkod.ast.Formula)101 Bounds (kodkod.instance.Bounds)75 Solver (kodkod.engine.Solver)72 Universe (kodkod.instance.Universe)32 Relation (kodkod.ast.Relation)30 TupleFactory (kodkod.instance.TupleFactory)30 TupleSet (kodkod.instance.TupleSet)25 Variable (kodkod.ast.Variable)24 IntExpression (kodkod.ast.IntExpression)19 Expression (kodkod.ast.Expression)17 Test (org.junit.Test)16 QuantifiedFormula (kodkod.ast.QuantifiedFormula)15 Decls (kodkod.ast.Decls)11 Evaluator (kodkod.engine.Evaluator)10 HigherOrderDeclException (kodkod.engine.fol2sat.HigherOrderDeclException)7 UnboundLeafException (kodkod.engine.fol2sat.UnboundLeafException)7 ConsoleReporter (kodkod.engine.config.ConsoleReporter)6 Instance (kodkod.instance.Instance)6 ArrayList (java.util.ArrayList)5