Search in sources :

Example 6 with ConsoleReporter

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

the class AbstractWorldDefinitions method main.

/**
 * Usage: java examples.AbstractWorldDefinitions [A241 | AbOp_total |
 * AbIgnore_inv | AbTransfer_inv] [univ size]
 */
public static void main(String[] args) {
    if (args.length < 2)
        usage();
    try {
        final String assertion = args[0];
        final int n = Integer.parseInt(args[1]);
        if (n < 1)
            usage();
        final AbstractWorldDefinitions model = new AbstractWorldDefinitions();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        solver.options().setReporter(new ConsoleReporter());
        // solver.options().setFlatten(true);
        final Method method = model.getClass().getMethod(assertion);
        final Formula f = model.decls().and(((Formula) method.invoke(model)).not());
        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();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        usage();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Solver(kodkod.engine.Solver) ConsoleReporter(kodkod.engine.config.ConsoleReporter) Bounds(kodkod.instance.Bounds) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) Formula(kodkod.ast.Formula) Solution(kodkod.engine.Solution)

Aggregations

Formula (kodkod.ast.Formula)6 Solution (kodkod.engine.Solution)6 Solver (kodkod.engine.Solver)6 ConsoleReporter (kodkod.engine.config.ConsoleReporter)6 Bounds (kodkod.instance.Bounds)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Decls (kodkod.ast.Decls)1 Expression (kodkod.ast.Expression)1 IntExpression (kodkod.ast.IntExpression)1 Relation (kodkod.ast.Relation)1 Variable (kodkod.ast.Variable)1 Evaluator (kodkod.engine.Evaluator)1 HigherOrderDeclException (kodkod.engine.fol2sat.HigherOrderDeclException)1 UnboundLeafException (kodkod.engine.fol2sat.UnboundLeafException)1 TupleFactory (kodkod.instance.TupleFactory)1 TupleSet (kodkod.instance.TupleSet)1 Universe (kodkod.instance.Universe)1