Browse Source

RewardModelInformation: Fixed getting wrong reward informations in case of non-transient variables in reward expression.

tempestpy_adaptions
TimQu 6 years ago
parent
commit
415e806531
  1. 6
      src/storm/storage/jani/traverser/RewardModelInformation.cpp

6
src/storm/storage/jani/traverser/RewardModelInformation.cpp

@ -19,15 +19,19 @@ namespace storm {
RewardModelInformation::RewardModelInformation(Model const& model, storm::expressions::Expression const& rewardModelExpression) : stateRewards(false), actionRewards(false), transitionRewards(false) {
auto variablesInRewardExpression = rewardModelExpression.getVariables();
std::map<storm::expressions::Variable, storm::expressions::Expression> initialSubstitution;
bool containsNonTransientVariable = false;
for (auto const& v : variablesInRewardExpression) {
STORM_LOG_ASSERT(model.hasGlobalVariable(v.getName()), "Unable to find global variable " << v.getName() << " occurring in a reward expression.");
auto const& janiVar = model.getGlobalVariable(v.getName());
if (janiVar.hasInitExpression()) {
initialSubstitution.emplace(v, janiVar.getInitExpression());
}
if (!janiVar.isTransient()) {
containsNonTransientVariable = true;
}
}
auto initExpr = storm::jani::substituteJaniExpression(rewardModelExpression, initialSubstitution);
if (initExpr.containsVariables() || !storm::utility::isZero(initExpr.evaluateAsRational())) {
if (containsNonTransientVariable || initExpr.containsVariables() || !storm::utility::isZero(initExpr.evaluateAsRational())) {
stateRewards = true;
actionRewards = true;
transitionRewards = true;

Loading…
Cancel
Save