Browse Source

Removed debug output and fixed the reward issue a bit more.

Former-commit-id: ecbbeff14e
tempestpy_adaptions
dehnert 10 years ago
parent
commit
a7bce9e520
  1. 3
      src/adapters/ExplicitModelAdapter.h
  2. 5
      src/storage/prism/Program.cpp
  3. 8
      src/storage/prism/Program.h

3
src/adapters/ExplicitModelAdapter.h

@ -110,7 +110,7 @@ namespace storm {
// all expressions in the program so we can then evaluate them without having to store the values of the // all expressions in the program so we can then evaluate them without having to store the values of the
// constants in the state (i.e., valuation). // constants in the state (i.e., valuation).
preparedProgram = preparedProgram.substituteConstants(); preparedProgram = preparedProgram.substituteConstants();
storm::prism::RewardModel const& rewardModel = rewardModelName != "" ? preparedProgram.getRewardModel(rewardModelName) : storm::prism::RewardModel();
storm::prism::RewardModel const& rewardModel = rewardModelName != "" || preparedProgram.hasRewardModel(rewardModelName) ? preparedProgram.getRewardModel(rewardModelName) : storm::prism::RewardModel();
ModelComponents modelComponents = buildModelComponents(preparedProgram, rewardModel); ModelComponents modelComponents = buildModelComponents(preparedProgram, rewardModel);
@ -526,7 +526,6 @@ namespace storm {
// Now add all rewards that match this choice. // Now add all rewards that match this choice.
for (auto const& transitionReward : transitionRewards) { for (auto const& transitionReward : transitionRewards) {
std::cout << transitionReward.getStatePredicateExpression() << std::endl;
if (transitionReward.getActionName() == "" && transitionReward.getStatePredicateExpression().evaluateAsBool(stateInformation.reachableStates.at(currentState))) { if (transitionReward.getActionName() == "" && transitionReward.getStatePredicateExpression().evaluateAsBool(stateInformation.reachableStates.at(currentState))) {
stateToRewardMap[stateProbabilityPair.first] += ValueType(transitionReward.getRewardValueExpression().evaluateAsDouble(stateInformation.reachableStates.at(currentState))); stateToRewardMap[stateProbabilityPair.first] += ValueType(transitionReward.getRewardValueExpression().evaluateAsDouble(stateInformation.reachableStates.at(currentState)));
} }

5
src/storage/prism/Program.cpp

@ -149,6 +149,11 @@ namespace storm {
return !this->rewardModels.empty(); return !this->rewardModels.empty();
} }
bool Program::hasRewardModel(std::string const& name) const {
auto const& nameIndexPair = this->rewardModelToIndexMap.find(name);
return nameIndexPair != this->rewardModelToIndexMap.end();
}
std::vector<storm::prism::RewardModel> const& Program::getRewardModels() const { std::vector<storm::prism::RewardModel> const& Program::getRewardModels() const {
return this->rewardModels; return this->rewardModels;
} }

8
src/storage/prism/Program.h

@ -226,6 +226,14 @@ namespace storm {
*/ */
bool hasRewardModel() const; bool hasRewardModel() const;
/*!
* Retrieves whether the program has a reward model with the given name.
*
* @param name The name of the reward model to look for.
* @return True iff the program has a reward model with the given name.
*/
bool hasRewardModel(std::string const& name) const;
/*! /*!
* Retrieves the reward models of the program. * Retrieves the reward models of the program.
* *
Loading…
Cancel
Save