|
|
|
@ -571,8 +571,28 @@ public class ProbModelChecker extends NonProbModelChecker |
|
|
|
*/ |
|
|
|
protected StateValues checkProbNext(Model model, ExpressionTemporal expr, MinMax minMax) throws PrismException |
|
|
|
{ |
|
|
|
// To be overridden by subclasses |
|
|
|
throw new PrismException("Computation not implemented yet"); |
|
|
|
// Model check the operand |
|
|
|
BitSet target = checkExpression(model, expr.getOperand2()).getBitSet(); |
|
|
|
|
|
|
|
// Compute/return the probabilities |
|
|
|
ModelCheckerResult res = null; |
|
|
|
switch (model.getModelType()) { |
|
|
|
case CTMC: |
|
|
|
res = ((CTMCModelChecker) this).computeNextProbs((CTMC) model, target); |
|
|
|
break; |
|
|
|
case DTMC: |
|
|
|
res = ((DTMCModelChecker) this).computeNextProbs((DTMC) model, target); |
|
|
|
break; |
|
|
|
case MDP: |
|
|
|
res = ((MDPModelChecker) this).computeNextProbs((MDP) model, target, minMax.isMin()); |
|
|
|
break; |
|
|
|
case STPG: |
|
|
|
res = ((STPGModelChecker) this).computeNextProbs((STPG) model, target, minMax.isMin1(), minMax.isMin2()); |
|
|
|
break; |
|
|
|
default: |
|
|
|
throw new PrismException("Cannot model check " + expr + " for " + model.getModelType() + "s"); |
|
|
|
} |
|
|
|
return StateValues.createFromDoubleArray(res.soln, model); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -580,8 +600,43 @@ public class ProbModelChecker extends NonProbModelChecker |
|
|
|
*/ |
|
|
|
protected StateValues checkProbBoundedUntil(Model model, ExpressionTemporal expr, MinMax minMax) throws PrismException |
|
|
|
{ |
|
|
|
// To be overridden by subclasses |
|
|
|
throw new PrismException("Computation not implemented yet"); |
|
|
|
// This method just handles discrete time |
|
|
|
// Continuous-time model checkers will override this method |
|
|
|
|
|
|
|
// Get info from bounded until |
|
|
|
int 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 |
|
|
|
BitSet b1 = checkExpression(model, expr.getOperand1()).getBitSet(); |
|
|
|
BitSet b2 = checkExpression(model, expr.getOperand2()).getBitSet(); |
|
|
|
|
|
|
|
// Compute/return the probabilities |
|
|
|
// A trivial case: "U<=0" (prob is 1 in b2 states, 0 otherwise) |
|
|
|
if (time == 0) { |
|
|
|
return StateValues.createFromBitSetAsDoubles(b2, model); |
|
|
|
} |
|
|
|
// Otherwise: numerical solution |
|
|
|
ModelCheckerResult res = null; |
|
|
|
switch (model.getModelType()) { |
|
|
|
case DTMC: |
|
|
|
res = ((DTMCModelChecker) this).computeBoundedUntilProbs((DTMC) model, b1, b2, time); |
|
|
|
break; |
|
|
|
case MDP: |
|
|
|
res = ((MDPModelChecker) this).computeBoundedUntilProbs((MDP) model, b1, b2, time, minMax.isMin()); |
|
|
|
break; |
|
|
|
case STPG: |
|
|
|
res = ((STPGModelChecker) this).computeBoundedUntilProbs((STPG) model, b1, b2, time, minMax.isMin1(), minMax.isMin2()); |
|
|
|
break; |
|
|
|
default: |
|
|
|
throw new PrismException("Cannot model check " + expr + " for " + model.getModelType() + "s"); |
|
|
|
} |
|
|
|
return StateValues.createFromDoubleArray(res.soln, model); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -589,8 +644,30 @@ public class ProbModelChecker extends NonProbModelChecker |
|
|
|
*/ |
|
|
|
protected StateValues checkProbUntil(Model model, ExpressionTemporal expr, MinMax minMax) throws PrismException |
|
|
|
{ |
|
|
|
// To be overridden by subclasses |
|
|
|
throw new PrismException("Computation not implemented yet"); |
|
|
|
// Model check operands first |
|
|
|
BitSet b1 = checkExpression(model, expr.getOperand1()).getBitSet(); |
|
|
|
BitSet b2 = checkExpression(model, expr.getOperand2()).getBitSet(); |
|
|
|
|
|
|
|
// Compute/return the probabilities |
|
|
|
ModelCheckerResult res = null; |
|
|
|
switch (model.getModelType()) { |
|
|
|
case CTMC: |
|
|
|
res = ((CTMCModelChecker) this).computeUntilProbs((CTMC) model, b1, b2); |
|
|
|
break; |
|
|
|
case DTMC: |
|
|
|
res = ((DTMCModelChecker) this).computeUntilProbs((DTMC) model, b1, b2); |
|
|
|
break; |
|
|
|
case MDP: |
|
|
|
res = ((MDPModelChecker) this).computeUntilProbs((MDP) model, b1, b2, minMax.isMin()); |
|
|
|
result.setStrategy(res.strat); |
|
|
|
break; |
|
|
|
case STPG: |
|
|
|
res = ((STPGModelChecker) this).computeUntilProbs((STPG) model, b1, b2, minMax.isMin1(), minMax.isMin2()); |
|
|
|
break; |
|
|
|
default: |
|
|
|
throw new PrismException("Cannot model check " + expr + " for " + model.getModelType() + "s"); |
|
|
|
} |
|
|
|
return StateValues.createFromDoubleArray(res.soln, model); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|