Пример #1
0
  protected StateValues checkProbBoundedUntil(Model model, ExpressionTemporal expr, boolean min)
      throws PrismException {
    double uTime;
    BitSet b1, b2;
    StateValues probs = null;
    ModelCheckerResult res = null;

    // get info from bounded until
    uTime = expr.getUpperBound().evaluateDouble(constantValues);
    if (uTime < 0 || (uTime == 0 && expr.upperBoundIsStrict())) {
      String bound = (expr.upperBoundIsStrict() ? "<" : "<=") + uTime;
      throw new PrismException("Invalid upper bound " + bound + " in time-bounded until formula");
    }

    // model check operands first
    b1 = checkExpression(model, expr.getOperand1()).getBitSet();
    b2 = checkExpression(model, expr.getOperand2()).getBitSet();

    // compute probabilities

    // a trivial case: "U<=0"
    if (uTime == 0) {
      // prob is 1 in b2 states, 0 otherwise
      probs = StateValues.createFromBitSetAsDoubles(b2, model);
    } else {
      res = computeBoundedUntilProbs((CTMDP) model, b1, b2, uTime, min);
      probs = StateValues.createFromDoubleArray(res.soln, model);
    }

    return probs;
  }
Пример #2
0
  /** Compute probabilities for a bounded until operator. */
  protected StateValues checkProbBoundedUntil(
      Model model, ExpressionTemporal expr, boolean min1, boolean min2) throws PrismException {
    int time;
    BitSet b1, b2;
    StateValues probs = null;
    ModelCheckerResult res = null;

    // get info from bounded until
    time = expr.getUpperBound().evaluateInt(constantValues);
    if (expr.upperBoundIsStrict()) time--;
    if (time < 0) {
      String bound = expr.upperBoundIsStrict() ? "<" + (time + 1) : "<=" + time;
      throw new PrismException("Invalid bound " + bound + " in bounded until formula");
    }

    // model check operands first
    b1 = checkExpression(model, expr.getOperand1()).getBitSet();
    b2 = checkExpression(model, expr.getOperand2()).getBitSet();

    // print out some info about num states
    // mainLog.print("\nb1 = " + JDD.GetNumMintermsString(b1,
    // allDDRowVars.n()));
    // mainLog.print(" states, b2 = " + JDD.GetNumMintermsString(b2,
    // allDDRowVars.n()) + " states\n");

    // Compute probabilities

    // a trivial case: "U<=0"
    if (time == 0) {
      // prob is 1 in b2 states, 0 otherwise
      probs = StateValues.createFromBitSetAsDoubles(b2, model);
    } else {
      res = computeBoundedUntilProbs((STPG) model, b1, b2, time, min1, min2);
      probs = StateValues.createFromDoubleArray(res.soln, model);
    }

    return probs;
  }
Пример #3
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));
  }