Search in sources :

Example 86 with Solution

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

the class Toughnut method main.

/**
 * Usage: java examples.Toughnut [size of one side of the board; optional]
 */
public static void main(String[] args) {
    try {
        int n = args.length == 0 ? 4 : Integer.parseInt(args[0]);
        final Toughnut nut = new Toughnut();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final Formula covering = nut.checkBelowTooDoublePrime();
        final Bounds bounds = nut.bounds(n);
        // System.out.println(covering);
        // System.out.println(bounds);
        final Solution sol = solver.solve(covering, bounds);
        System.out.println(sol);
    } catch (NumberFormatException nfe) {
        System.out.println("Usage: java examples.Toughnut [size of one side of the board; optional]");
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 87 with Solution

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

the class Viktor method main.

/**
 * Usage: java tests.Viktor
 */
public static void main(String[] args) {
    final Viktor model = new Viktor();
    final Solver solver = new Solver();
    solver.options().setSolver(SATFactory.MiniSat);
    solver.options().setReporter(new ConsoleReporter());
    solver.options().setBitwidth(7);
    final Formula f = model.checkEquations();
    final Bounds b = model.bounds();
    System.out.println(f);
    System.out.println(b);
    final Solution sol = solver.solve(f, b);
    System.out.println(sol);
    if (sol.instance() != null)
        model.display(sol.instance(), solver.options());
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) ConsoleReporter(kodkod.engine.config.ConsoleReporter) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 88 with Solution

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

the class ConfigAssure method main.

/**
 * Usage: java examples.ConfigAssure <ipAddresses file> <subnets file>
 */
public static void main(String[] args) {
    if (args.length < 2)
        usage();
    try {
        final ConfigAssure ca = new ConfigAssure();
        final Solver solver = new Solver();
        solver.options().setBitwidth(32);
        solver.options().setSolver(SATFactory.MiniSat);
        final Formula formula = ca.requirements();
        final Bounds bounds = ca.bounds(args[0], args[1]);
        System.out.println("---explicit requirements (others are implicit in the bounds)---");
        System.out.println(PrettyPrinter.print(formula, 2));
        System.out.println("\n---solving with config files " + args[0] + " and " + args[1] + "---");
        final Solution sol = solver.solve(formula, bounds);
        System.out.println("\n---OUTCOME---");
        System.out.println(sol.outcome());
        System.out.println("\n---STATS---");
        System.out.println(sol.stats());
        if (sol.instance() != null) {
            System.out.println("\n---INSTANCE--");
            ca.display(sol.instance(), solver.options());
        }
    } catch (IOException ioe) {
        ioe.printStackTrace();
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) IOException(java.io.IOException) Solution(kodkod.engine.Solution)

Example 89 with Solution

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

the class Netconfig method main.

/**
 * Usage: java examples.Netconfig [# sites] [# hq] [# routers] [# time steps]
 */
public static void main(String[] args) {
    if (args.length < 4)
        usage();
    final Netconfig model = new Netconfig();
    final Solver solver = new Solver();
    // solver.options().setSolver(SATFactory.ZChaffMincost);
    solver.options().setSolver(SATFactory.MiniSat);
    try {
        final Formula show = model.show();
        final Solution sol = solver.solve(show, model.bounds(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])));
        // System.out.println(show);
        // System.out.println("p cnf " +
        // (solver.numberOfIntermediateVariables()+solver.numberOfPrimaryVariables())
        // + " " + solver.numberOfClauses());
        System.out.println(sol.outcome());
        System.out.println(sol.stats());
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Solution(kodkod.engine.Solution)

Example 90 with Solution

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

the class ALG212 method main.

/**
 * Usage: java examples.tptp.ALG212 [univ size]
 */
public static void main(String[] args) {
    if (args.length < 1)
        usage();
    try {
        final int n = Integer.parseInt(args[0]);
        if (n < 1)
            usage();
        final ALG212 model = new ALG212();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        // solver.options().setSymmetryBreaking(n*n);
        // solver.options().setFlatten(false);
        final Formula f = model.checkDistLong();
        final Bounds b = model.bounds(n);
        System.out.println(f);
        final Solution sol = solver.solve(f, b);
        System.out.println(sol);
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) 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