Package edu.mit.csail.sdg.alloy4

Examples of edu.mit.csail.sdg.alloy4.A4Reporter


  }

  public static long run(String theory) {
    VizGUI viz = null;
    int i = 0;
    A4Reporter rep = new A4Reporter() {
      @Override
      public void warning(ErrorWarning msg) {
        System.out.print("Relevance Warning:\n"
            + (msg.toString().trim()) + "\n\n");
        System.out.flush();
View Full Code Here


  }


 
  protected A4Reporter createA4Reporter() {
    return new A4Reporter() {
      @Override
      public void warning(ErrorWarning msg) {
        System.out.print("Relevance Warning:\n"
            + (msg.toString().trim()) + "\n\n");
        System.out.flush();
View Full Code Here

  @Override
  protected void initializeAlloyAnalyzer() {
    // Alloy4 sends diagnostic messages and progress reports to the
    // A4Reporter.
    A4Reporter rep = createA4Reporter();

    try {

      javaMetamodel = CompUtil.parseEverything_fromFile(rep, null,
          alloyTheory);
View Full Code Here

               if (solved[0]) return; else solved[0]=true; // initially solved[0] is true, so we won't report the # of vars/clauses
               if (rep!=null) rep.solve(primaryVars, vars, clauses);
           }
        });
        if (!opt.solver.equals(SatSolver.CNF) && !opt.solver.equals(SatSolver.KK) && tryBookExamples) { // try book examples
           A4Reporter r = "yes".equals(System.getProperty("debug")) ? rep : null;
           try { sol = BookExamples.trial(r, this, fgoal, solver, cmd.check); } catch(Throwable ex) { sol = null; }
        }
        solved[0] = false; // this allows the reporter to report the # of vars/clauses
        for(Relation r: bounds.relations()) { formulas.add(r.eq(r)); } // Without this, kodkod refuses to grow unmentioned relations
        fgoal = Formula.and(formulas);
        // Now pick the solver and solve it!
        if (opt.solver.equals(SatSolver.KK)) {
            File tmpCNF = File.createTempFile("tmp", ".java", new File(opt.tempDirectory));
            String out = tmpCNF.getAbsolutePath();
View Full Code Here

        // The visualizer (We will initialize it to nonnull when we visualize an Alloy solution)
        VizGUI viz = null;

        // Alloy4 sends diagnostic messages and progress reports to the A4Reporter.
        // By default, the A4Reporter ignores all these events (but you can extend the A4Reporter to display the event for the user)
        A4Reporter rep = new A4Reporter() {
            // For example, here we choose to display each "warning" by printing it to System.out
            @Override public void warning(ErrorWarning msg) {
                System.out.print("Relevance Warning:\n"+(msg.toString().trim())+"\n\n");
                System.out.flush();
            }
View Full Code Here

        try {
            long start = System.currentTimeMillis();
            GreedySimulator sim = new GreedySimulator();
            sim.allSigs = sigs;
            sim.partial = null;
            A4Reporter rep2 = new A4Reporter(rep) {
                private boolean first = true;
                public void translate(String solver, int bitwidth, int maxseq, int skolemDepth, int symmetry) { if (first) super.translate(solver, bitwidth, maxseq, skolemDepth, symmetry); first=false; }
                public void resultSAT(Object command, long solvingTime, Object solution) { }
                public void resultUNSAT(Object command, long solvingTime, Object solution) { }
            };
View Full Code Here

                      return;
                   }
                }
            }
            if (msg instanceof Err) {
                Err ex = (Err)msg;
                String text = "fatal";
                boolean fatal = false;
                if (ex instanceof ErrorSyntax) text="syntax"; else if (ex instanceof ErrorType) text="type"; else fatal=true;
                if (ex.pos==Pos.UNKNOWN)
                    span.logBold("A "+text+" error has occurred:  ");
                else
                    span.logLink("A "+text+" error has occurred:  ", "POS: "+ex.pos.x+" "+ex.pos.y+" "+ex.pos.x2+" "+ex.pos.y2+" "+ex.pos.filename);
                if (verbosity>2) {
                    span.log("(see the "); span.logLink("stacktrace", "MSG: "+ex.dump()); span.log(")\n");
                } else {
                    span.log("\n");
                }
                span.logIndented(ex.msg.trim());
                span.log("\n");
                if (fatal && latestVersion>Version.buildNumber())
                    span.logBold(
                       "\nNote: You are running Alloy build#"+Version.buildNumber()+
                       ",\nbut the most recent is Alloy build#"+latestVersion+
                       ":\n( version "+latestName+" )\nPlease try to upgrade to the newest version,"+
                       "\nas the problem may have been fixed already.\n");
                span.flush();
                if (!fatal) gui.doVisualize("POS: "+ex.pos.x+" "+ex.pos.y+" "+ex.pos.x2+" "+ex.pos.y2+" "+ex.pos.filename);
                return;
            }
            if (msg instanceof Throwable) { Throwable ex = (Throwable)msg; span.logBold(ex.toString().trim()+"\n"); span.flush(); return; }
            if (!(msg instanceof Object[])) return;
            Object[] array = (Object[]) msg;
            if (array[0].equals("pop")) { span.setLength(len2); String x=(String)(array[1]); if (viz!=null && x.length()>0) OurDialog.alert(x); }
            if (array[0].equals("declare")) { gui.doSetLatest((String)(array[1])); }
            if (array[0].equals("S2")) { len3=len2=span.getLength(); span.logBold(""+array[1]); }
View Full Code Here

     * <p> The resulting instance may or may not satisfy all facts, and should be checked for consistency.
     */
    public void init(Field field, SimTupleset value) throws Err {
        if (value==null) { sfs.remove(field); return; }
        if (!value.empty() && value.arity()!=field.type().arity()) throw new ErrorType("Evaluator encountered an error: field "+field.label+" arity must not be " + value.arity());
        if (field.defined) throw new ErrorAPI("Evaluator cannot prebind the value of a defined field.");
        sfs.put(field, value);
        cacheUNIV = null;
        cacheSTRING = null;
        cacheForConstants.clear();
    }
View Full Code Here

    /** Returns an arbitrary atom from an arbitrary tuple.
     * @throws - ErrorAPI if this tupleset is empty
     */
    public SimAtom getAtom() throws ErrorAPI {
        if (tuples.size()>0) return tuples.get(0).get(0);
        if (min>=max) throw new ErrorAPI("This tupleset is empty");
        return SimAtom.make(min);
    }
View Full Code Here

    /** Returns an arbitrary tuple.
     * @throws - ErrorAPI if this tupleset is empty
     */
    public SimTuple getTuple() throws ErrorAPI {
        if (tuples.size()>0) return tuples.get(0);
        if (min>=max) throw new ErrorAPI("This tupleset is empty");
        SimAtom a = SimAtom.make(min);
        if (next) return SimTuple.make(a, SimAtom.make(min+1)); else return SimTuple.make(a);
    }
View Full Code Here

TOP

Related Classes of edu.mit.csail.sdg.alloy4.A4Reporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.