Пример #1
0
  /** Model check a P operator. */
  private Result checkExpressionProb(ExpressionProb expr) throws PrismException {
    boolean min;
    ExpressionTemporal exprTemp;
    Expression exprTarget;
    BitSet targetLocs;
    int timeBound;
    boolean timeBoundStrict;
    double prob;

    // Check whether Pmin=? or Pmax=? (only two cases allowed)
    if (expr.getProb() != null) {
      throw new PrismException(
          "PTA model checking currently only supports Pmin=? and Pmax=? properties (try the digital clocks engine instead)");
    }
    min = expr.getRelOp().equals("min=");

    // Check this is a F path property (only case allowed at the moment)
    if (!(expr.getExpression() instanceof ExpressionTemporal))
      throw new PrismException(
          "PTA model checking currently only supports the F path operator (try the digital clocks engine instead)");
    exprTemp = (ExpressionTemporal) expr.getExpression();
    if (exprTemp.getOperator() != ExpressionTemporal.P_F || !exprTemp.isSimplePathFormula())
      throw new PrismException(
          "PTA model checking currently only supports the F path operator (try the digital clocks engine instead)");

    // Determine locations satisfying target
    exprTarget = exprTemp.getOperand2();
    targetLocs = checkLocationExpression(exprTarget);
    mainLog.println(
        "Target (" + exprTarget + ") satisfied by " + targetLocs.cardinality() + " locations.");
    // mainLog.println(targetLocs);

    // If there is a time bound, add a clock and encode this into target
    if (exprTemp.hasBounds()) {
      mainLog.println("Modifying PTA to encode time bound from property...");
      // Get time bound info (is always of form <=T or <T)
      timeBound = exprTemp.getUpperBound().evaluateInt(constantValues);
      timeBoundStrict = exprTemp.upperBoundIsStrict();
      // Modify PTA to include time bound; get new target
      targetLocs = buildTimeBoundIntoPta(pta, targetLocs, timeBound, timeBoundStrict);
      mainLog.println("New PTA: " + pta.infoString());
    }

    // Compute probability of reaching the set of target locations
    prob = computeProbabilisticReachability(targetLocs, min);

    // Return result
    return new Result(new Double(prob));
  }
Пример #2
0
 /**
  * Create a sampler for an expression (P=? or R=?). Expression should contain no
  * constants/formula/etc. The model to which the property applies should also be specified.
  */
 public static Sampler createSampler(Expression expr, ModulesFile mf) throws PrismException {
   Sampler sampler = null;
   // P=?
   if (expr instanceof ExpressionProb) {
     ExpressionProb propProb = (ExpressionProb) expr;
     // Test whether this is a simple path formula (i.e. non-LTL)
     if (propProb.getExpression().isSimplePathFormula()) {
       sampler = createSamplerForProbPathPropertySimple(propProb.getExpression(), mf);
     } else {
       throw new PrismException("LTL-style path formulas are not supported by the simulator");
     }
   }
   // R=?
   else if (expr instanceof ExpressionReward) {
     sampler = createSamplerForRewardProperty((ExpressionReward) expr, mf);
   }
   // Neither
   else {
     throw new PrismException("Can't create sampler for property \"" + expr + "\"");
   }
   return sampler;
 }