コード例 #1
0
 @Override
 public void exportToPrismExplicitTra(PrismLog out) {
   int i;
   TreeMap<Integer, Pair<Double, Object>> sorted;
   // Output transitions to .tra file
   out.print(numStates + " " + getNumTransitions() + "\n");
   sorted = new TreeMap<Integer, Pair<Double, Object>>();
   for (i = 0; i < numStates; i++) {
     // Extract transitions and sort by destination state index (to match PRISM-exported files)
     Iterator<Map.Entry<Integer, Pair<Double, Object>>> iter = getTransitionsAndActionsIterator(i);
     while (iter.hasNext()) {
       Map.Entry<Integer, Pair<Double, Object>> e = iter.next();
       sorted.put(e.getKey(), e.getValue());
     }
     // Print out (sorted) transitions
     for (Map.Entry<Integer, Pair<Double, Object>> e : sorted.entrySet()) {
       // Note use of PrismUtils.formatDouble to match PRISM-exported files
       out.print(i + " " + e.getKey() + " " + PrismUtils.formatDouble(e.getValue().first));
       Object action = e.getValue().second;
       if (action != null && !"".equals(action)) out.print(" " + action);
       out.print("\n");
     }
     sorted.clear();
   }
 }
コード例 #2
0
 @Override
 public void exportTransitionsToDotFile(int i, PrismLog out) {
   Iterator<Map.Entry<Integer, Double>> iter = getTransitionsIterator(i);
   while (iter.hasNext()) {
     Map.Entry<Integer, Double> e = iter.next();
     out.print(i + " -> " + e.getKey() + " [ label=\"");
     out.print(e.getValue() + "\" ];\n");
   }
 }
コード例 #3
0
 @Override
 protected void exportTransitionsToDotFile(int i, PrismLog out) {
   int j, k;
   String nij, nijk;
   j = -1;
   for (DistributionSet distrs : trans.get(i)) {
     j++;
     nij = "n" + i + "_" + j;
     out.print(i + " -> " + nij + " [ arrowhead=none,label=\"" + j + "\" ];\n");
     out.print(nij + " [ shape=circle,width=0.1,height=0.1,label=\"\" ];\n");
     k = -1;
     for (Distribution distr : distrs) {
       k++;
       nijk = "n" + i + "_" + j + "_" + k;
       out.print(nij + " -> " + nijk + " [ arrowhead=none,label=\"" + k + "\" ];\n");
       out.print(nijk + " [ shape=point,label=\"\" ];\n");
       for (Map.Entry<Integer, Double> e : distr) {
         out.print(nijk + " -> " + e.getKey() + " [ label=\"" + e.getValue() + "\" ];\n");
       }
     }
   }
 }
コード例 #4
0
 @Override
 public void exportToPrismExplicitTra(PrismLog out) {
   int i, j, k;
   TreeMap<Integer, Double> sorted;
   // Output transitions to .tra file
   out.print(numStates + " " + numDistrSets + " " + numDistrs + " " + numTransitions + "\n");
   sorted = new TreeMap<Integer, Double>();
   for (i = 0; i < numStates; i++) {
     j = -1;
     for (DistributionSet distrs : trans.get(i)) {
       j++;
       k = -1;
       for (Distribution distr : distrs) {
         k++;
         // Extract transitions and sort by destination state index (to match PRISM-exported files)
         for (Map.Entry<Integer, Double> e : distr) {
           sorted.put(e.getKey(), e.getValue());
         }
         // Print out (sorted) transitions
         for (Map.Entry<Integer, Double> e : distr) {
           // Note use of PrismUtils.formatDouble to match PRISM-exported files
           out.print(
               i
                   + " "
                   + j
                   + " "
                   + k
                   + " "
                   + e.getKey()
                   + " "
                   + PrismUtils.formatDouble(e.getValue())
                   + "\n");
         }
         sorted.clear();
       }
     }
   }
 }
コード例 #5
0
  /** Model check a property. */
  public Result check(Expression expr) throws PrismException {
    Modules2PTA m2pta;
    Result res;
    String resultString;
    long timer;

    // Starting model checking
    timer = System.currentTimeMillis();

    // Check for system...endsystem - not supported yet
    if (modulesFile.getSystemDefn() != null) {
      throw new PrismException(
          "The system...endsystem construct is not supported yet (try the digital clocks engine instead)");
    }

    // Translate ModulesFile object into a PTA object
    mainLog.println("\nBuilding PTA...");
    m2pta = new Modules2PTA(prism, modulesFile);
    pta = m2pta.translate();
    mainLog.println("\nPTA: " + pta.infoString());

    // Check for references to clocks - not allowed (yet)
    // (do this before modifications below for better error reporting)
    expr.accept(
        new ASTTraverseModify() {
          public Object visit(ExpressionVar e) throws PrismLangException {
            if (e.getType() instanceof TypeClock) {
              throw new PrismLangException(
                  "Properties cannot contain references to clocks (try the digital clocks engine instead)",
                  e);
            } else {
              return e;
            }
          }
        });

    // Take a copy of property, since will modify
    expr = expr.deepCopy();
    // Remove property refs ands labels from property
    expr = (Expression) expr.expandPropRefsAndLabels(propertiesFile, labelList);
    // Evaluate constants in property (easier to do now)
    expr = (Expression) expr.replaceConstants(constantValues);
    // Also simplify expression to optimise model checking
    expr = (Expression) expr.simplify();

    // Do model checking
    res = checkExpression(expr);

    // Model checking complete
    timer = System.currentTimeMillis() - timer;
    mainLog.println("\nModel checking completed in " + (timer / 1000.0) + " secs.");

    // Print result to log
    resultString = "Result";
    if (!("Result".equals(expr.getResultName())))
      resultString += " (" + expr.getResultName().toLowerCase() + ")";
    resultString += ": " + res;
    mainLog.print("\n" + resultString + "\n");

    // Return result
    return res;
  }