Search in sources :

Example 6 with UnboundLeafException

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

the class GRA013_026 method main.

/**
 * Usage: java examples.tptp.GRA013_026 <graph size> <clique size>
 */
public static void main(String[] args) {
    if (args.length < 2)
        usage();
    try {
        final GRA013_026 model = new GRA013_026(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
        final Bounds b = model.bounds();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        solver.options().setReporter(new ConsoleReporter());
        final Formula f = model.checkGoalToBeProved();
        System.out.println(PrettyPrinter.print(f, 2));
        // System.out.println(b);
        final Solution s = solver.solve(f, b);
        System.out.println(s);
    // System.out.println((new Evaluator(s.instance())).evaluate(f));
    } catch (HigherOrderDeclException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnboundLeafException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) UnboundLeafException(kodkod.engine.fol2sat.UnboundLeafException) ConsoleReporter(kodkod.engine.config.ConsoleReporter) Bounds(kodkod.instance.Bounds) HigherOrderDeclException(kodkod.engine.fol2sat.HigherOrderDeclException) Solution(kodkod.engine.Solution)

Example 7 with UnboundLeafException

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

the class BugTests method testFelix_08022006.

public final void testFelix_08022006() {
    Relation x = Relation.nary("P", 1);
    String[] atoms = { "-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1", "0", "1", "2", "3", "4", "5", "6", "7" };
    java.util.ArrayList<String> atomlist = new java.util.ArrayList<String>();
    for (String a : atoms) atomlist.add(a);
    Universe universe = new Universe(atomlist);
    TupleFactory factory = universe.factory();
    Bounds bounds = new Bounds(universe);
    for (int i = -8; i <= 7; i++) bounds.boundExactly(i, factory.setOf(String.valueOf(i)));
    bounds.bound(x, factory.allOf(1));
    Formula f = x.in(Expression.INTS).and(x.some());
    // System.out.println(bounds);
    Solver solver = new Solver();
    // solver.options().setSolver(SATFactory.ZChaff);
    solver.options().setSolver(SATFactory.DefaultSAT4J);
    solver.options().setBitwidth(4);
    solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);
    Solution sol;
    try {
        sol = solver.solve(f, bounds);
        assertNotNull(sol.instance());
    } catch (HigherOrderDeclException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnboundLeafException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Solver(kodkod.engine.Solver) UnboundLeafException(kodkod.engine.fol2sat.UnboundLeafException) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe) Formula(kodkod.ast.Formula) Relation(kodkod.ast.Relation) HigherOrderDeclException(kodkod.engine.fol2sat.HigherOrderDeclException) Solution(kodkod.engine.Solution)

Aggregations

Formula (kodkod.ast.Formula)7 Solution (kodkod.engine.Solution)7 Solver (kodkod.engine.Solver)7 HigherOrderDeclException (kodkod.engine.fol2sat.HigherOrderDeclException)7 UnboundLeafException (kodkod.engine.fol2sat.UnboundLeafException)7 Bounds (kodkod.instance.Bounds)7 ArrayList (java.util.ArrayList)2 Relation (kodkod.ast.Relation)2 TupleFactory (kodkod.instance.TupleFactory)2 Universe (kodkod.instance.Universe)2 Decls (kodkod.ast.Decls)1 Expression (kodkod.ast.Expression)1 IntExpression (kodkod.ast.IntExpression)1 Variable (kodkod.ast.Variable)1 ConsoleReporter (kodkod.engine.config.ConsoleReporter)1 TupleSet (kodkod.instance.TupleSet)1