Browse Source

ModelInfo: add method to query the existence of transition rewards, add check for explicit DTMC/CTMC reward construction

During reward construction in the explicit engine using the new ModelGenerator
functionality (see SVN 11772), the check for transition rewards was missing
(he explicit engine currently does not support transition rewards for DTMCs and CTMCs).

This commit adds functionality to ModelInfo to determine whether a reward structure
defines transition rewards and adds a corresponding check during reward construction.

Example: prism-examples/dice/dice.pm with R=?[ F s=7 ] and -explicit returns 0 instead
of an error message.


git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11802 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Joachim Klein 9 years ago
parent
commit
e113bff2c7
  1. 5
      prism/src/explicit/rewards/ConstructRewards.java
  2. 7
      prism/src/parser/ast/ModulesFile.java
  3. 9
      prism/src/prism/ModelInfo.java
  4. 6
      prism/src/prism/TestModelGenerator.java
  5. 6
      prism/src/simulator/ModulesFileModelGenerator.java
  6. 6
      prism/src/simulator/ModulesFileModelGeneratorSymbolic.java

5
prism/src/explicit/rewards/ConstructRewards.java

@ -230,6 +230,11 @@ public class ConstructRewards
*/ */
public MCRewards buildMCRewardStructure(DTMC mc, ModelGenerator modelGen, int r) throws PrismException public MCRewards buildMCRewardStructure(DTMC mc, ModelGenerator modelGen, int r) throws PrismException
{ {
if (modelGen.rewardStructHasTransitionRewards(r)) {
// TODO
throw new PrismNotSupportedException("Explicit engine does not yet handle transition rewards for D/CTMCs");
}
int numStates = mc.getNumStates(); int numStates = mc.getNumStates();
List<State> statesList = mc.getStatesList(); List<State> statesList = mc.getStatesList();
StateRewardsArray rewSA = new StateRewardsArray(numStates); StateRewardsArray rewSA = new StateRewardsArray(numStates);

7
prism/src/parser/ast/ModulesFile.java

@ -1183,6 +1183,13 @@ public class ModulesFile extends ASTElement implements ModelInfo
findAllVars(varNames, varTypes); findAllVars(varNames, varTypes);
} }
@Override
public boolean rewardStructHasTransitionRewards(int i)
{
RewardStruct rewStr = getRewardStruct(i);
return rewStr.getNumTransItems() > 0;
}
/** /**
* Create a VarList object storing information about all variables in this model. * Create a VarList object storing information about all variables in this model.
* Assumes that values for constants have been provided for the model. * Assumes that values for constants have been provided for the model.

9
prism/src/prism/ModelInfo.java

@ -138,7 +138,14 @@ public interface ModelInfo
* Returns null if index is out of range. * Returns null if index is out of range.
*/ */
public RewardStruct getRewardStruct(int i); public RewardStruct getRewardStruct(int i);
/**
* Returns true if the reward structure with index i
* (indexed from 0, not from 1 like at the user (property language) level)
* defines transition rewards.
*/
public boolean rewardStructHasTransitionRewards(int i);
// TODO: can we remove this? // TODO: can we remove this?
public VarList createVarList() throws PrismException; public VarList createVarList() throws PrismException;
} }

6
prism/src/prism/TestModelGenerator.java

@ -164,6 +164,12 @@ public class TestModelGenerator extends DefaultModelGenerator
} }
} }
@Override
public boolean rewardStructHasTransitionRewards(int i)
{
return false;
}
@Override @Override
public VarList createVarList() public VarList createVarList()
{ {

6
prism/src/simulator/ModulesFileModelGenerator.java

@ -414,4 +414,10 @@ public class ModulesFileModelGenerator extends DefaultModelGenerator
} }
return transitionList; return transitionList;
} }
@Override
public boolean rewardStructHasTransitionRewards(int i)
{
return modulesFile.rewardStructHasTransitionRewards(i);
}
} }

6
prism/src/simulator/ModulesFileModelGeneratorSymbolic.java

@ -462,4 +462,10 @@ public class ModulesFileModelGeneratorSymbolic extends DefaultModelGenerator imp
} }
return constantList.getConstant(i); return constantList.getConstant(i);
} }
@Override
public boolean rewardStructHasTransitionRewards(int i)
{
return modulesFile.rewardStructHasTransitionRewards(i);
}
} }
Loading…
Cancel
Save