|
|
@ -685,17 +685,14 @@ public class ProbModelChecker extends NonProbModelChecker |
|
|
*/ |
|
|
*/ |
|
|
protected StateValues checkExpressionReward(Model model, ExpressionReward expr) throws PrismException |
|
|
protected StateValues checkExpressionReward(Model model, ExpressionReward expr) throws PrismException |
|
|
{ |
|
|
{ |
|
|
Object rs; // Reward struct index |
|
|
|
|
|
RewardStruct rewStruct = null; // Reward struct object |
|
|
|
|
|
Expression rb; // Reward bound (expression) |
|
|
Expression rb; // Reward bound (expression) |
|
|
double r = 0; // Reward bound (actual value) |
|
|
double r = 0; // Reward bound (actual value) |
|
|
RelOp relOp; // Relational operator |
|
|
RelOp relOp; // Relational operator |
|
|
StateValues rews = null; |
|
|
StateValues rews = null; |
|
|
Rewards rewards = null; |
|
|
Rewards rewards = null; |
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
// Get info from R operator |
|
|
// Get info from R operator |
|
|
rs = expr.getRewardStructIndex(); |
|
|
|
|
|
|
|
|
RewardStruct rewStruct = expr.getRewardStructByIndexObject(modulesFile, constantValues); |
|
|
relOp = expr.getRelOp(); |
|
|
relOp = expr.getRelOp(); |
|
|
rb = expr.getReward(); |
|
|
rb = expr.getReward(); |
|
|
if (rb != null) { |
|
|
if (rb != null) { |
|
|
@ -704,23 +701,6 @@ public class ProbModelChecker extends NonProbModelChecker |
|
|
throw new PrismException("Invalid reward bound " + r + " in R[] formula"); |
|
|
throw new PrismException("Invalid reward bound " + r + " in R[] formula"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Get reward info |
|
|
|
|
|
if (modulesFile == null) |
|
|
|
|
|
throw new PrismException("No model file to obtain reward structures"); |
|
|
|
|
|
if (modulesFile.getNumRewardStructs() == 0) |
|
|
|
|
|
throw new PrismException("Model has no rewards specified"); |
|
|
|
|
|
if (rs == null) { |
|
|
|
|
|
rewStruct = modulesFile.getRewardStruct(0); |
|
|
|
|
|
} else if (rs instanceof Expression) { |
|
|
|
|
|
i = ((Expression) rs).evaluateInt(constantValues); |
|
|
|
|
|
rs = new Integer(i); // for better error reporting below |
|
|
|
|
|
rewStruct = modulesFile.getRewardStruct(i - 1); |
|
|
|
|
|
} else if (rs instanceof String) { |
|
|
|
|
|
rewStruct = modulesFile.getRewardStructByName((String) rs); |
|
|
|
|
|
} |
|
|
|
|
|
if (rewStruct == null) |
|
|
|
|
|
throw new PrismException("Invalid reward structure index \"" + rs + "\""); |
|
|
|
|
|
|
|
|
|
|
|
// Build rewards |
|
|
// Build rewards |
|
|
mainLog.println("Building reward structure..."); |
|
|
mainLog.println("Building reward structure..."); |
|
|
ConstructRewards constructRewards = new ConstructRewards(mainLog); |
|
|
ConstructRewards constructRewards = new ConstructRewards(mainLog); |
|
|
|