Examples of ErrorAPI


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

     * <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

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

    /** 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

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

    /** 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

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

    /** Returns a modifiable copy of the list of all i-th atom from all tuples in some arbitrary order (0 is first atom, 1 is second atom...)
     * @throws - ErrorAPI if this tupleset contains at least one tuple whose length is less than or equal to i
     */
    public List<SimAtom> getAllAtoms(int column) throws ErrorAPI {
        if (empty()) return new ArrayList<SimAtom>(0);
        if (column<0 || column>=arity()) throw new ErrorAPI("This tupleset does not have an \""+column+"th\" column.");
        IdentityHashMap<SimAtom,Boolean> ans = new IdentityHashMap<SimAtom,Boolean>();
        for(SimTuple x: this) ans.put(x.get(column), Boolean.TRUE);
        return new ArrayList<SimAtom>(ans.keySet());
    }
View Full Code Here

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

        solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);
     }

    /** Construct a new A4Solution that is the continuation of the old one, but with the "next" instance. */
    private A4Solution(A4Solution old) throws Err {
        if (!old.solved) throw new ErrorAPI("This solution is not yet solved, so next() is not allowed.");
        if (old.kEnumerator==null) throw new ErrorAPI("This solution was not generated by an incremental SAT solver.\n" + "Solution enumeration is currently only implemented for MiniSat and SAT4J.");
        if (old.eval==null) throw new ErrorAPI("This solution is already unsatisfiable, so you cannot call next() to get the next solution.");
        Instance inst = old.kEnumerator.next().instance();
        unrolls = old.unrolls;
        originalOptions = old.originalOptions;
        originalCommand = old.originalCommand;
        bitwidth = old.bitwidth;
View Full Code Here

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

       TupleSet oldL = bounds.lowerBound(relation);
       TupleSet oldU = bounds.upperBound(relation);
       if (oldU.containsAll(upperBound) && upperBound.containsAll(lowerBound) && lowerBound.containsAll(oldL)) {
          bounds.bound(relation, lowerBound, upperBound);
       } else {
          throw new ErrorAPI("Inconsistent bounds shrinking on relation: "+relation);
       }
    }
View Full Code Here

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

    /** If this solution is solved and satisfiable, evaluates the given expression and returns an A4TupleSet, a java Integer, or a java Boolean. */
    public Object eval(Expr expr) throws Err {
        try {
           if (expr instanceof Sig) return eval((Sig)expr);
           if (expr instanceof Field) return eval((Field)expr);
           if (!solved) throw new ErrorAPI("This solution is not yet solved, so eval() is not allowed.");
           if (eval==null) throw new ErrorAPI("This solution is unsatisfiable, so eval() is not allowed.");
           if (expr.ambiguous && !expr.errors.isEmpty()) expr = expr.resolve(expr.type(), null);
           if (!expr.errors.isEmpty()) throw expr.errors.pick();
           Object result = TranslateAlloyToKodkod.alloy2kodkod(this, expr);
           if (result instanceof IntExpression) return eval.evaluate((IntExpression)result);
           if (result instanceof Formula) return eval.evaluate((Formula)result);
View Full Code Here

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

        }
    }

    /** Returns the Kodkod instance represented by this solution; throws an exception if the problem is not yet solved or if it is unsatisfiable. */
    public Instance debugExtractKInstance() throws Err {
        if (!solved) throw new ErrorAPI("This solution is not yet solved, so instance() is not allowed.");
        if (eval==null) throw new ErrorAPI("This solution is unsatisfiable, so instance() is not allowed.");
        return eval.instance().unmodifiableView();
    }
View Full Code Here

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

    /** Create a fresh atom for the given sig, then return the newly created atom.
     * @throws ErrorAPI if attempting to add an atom to an abstract sig with children, or a builtin sig, or a subset sig.
     */
    public SimAtom makeAtom(Sig sig) throws Err {
        if (sig.builtin) throw new ErrorAPI("Cannot add an atom to a builtin sig.");
        if (!(sig instanceof PrimSig)) throw new ErrorAPI("Cannot add an atom to a subset sig.");
        PrimSig s = (PrimSig)sig;
        if (s.isAbstract!=null && !s.children().isEmpty()) throw new ErrorAPI("Cannot add an atom to an abstract parent sig.");
        String label = sig.label + "$";
        if (label.startsWith("this/")) label=label.substring(5);
        for(int i=0; ;i++) {
          SimAtom atom = SimAtom.make(label + i);
          if (hasAtom(atom)) continue;
View Full Code Here

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

     * <p> The resulting instance may or may not satisfy all facts, and should be checked for consistency.
     */
    public void init(Sig sig, SimTupleset value) throws Err {
        if (value==null) { sfs.remove(sig); return; }
        if (value.arity()>1) throw new ErrorType("Evaluator encountered an error: sig "+sig.label+" arity must not be " + value.arity());
        if (sig.builtin) throw new ErrorAPI("Evaluator cannot prebind the builtin sig \"" + sig.label + "\"");
        sfs.put(sig, value);
        cacheUNIV = null;
        cacheSTRING = null;
        cacheForConstants.clear();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.