From 08959a6a32767608e91ae5dc9dc42d607cfa1b6b Mon Sep 17 00:00:00 2001 From: dehnert Date: Thu, 27 Nov 2014 18:36:08 +0100 Subject: [PATCH] Intermediate commit. Former-commit-id: d3c8fe1b9b443187c0cff0be57a4c26a68cd960e --- src/adapters/ExplicitModelAdapter.h | 2 +- src/storage/prism/Program.cpp | 5 +++++ src/storage/prism/Program.h | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/adapters/ExplicitModelAdapter.h b/src/adapters/ExplicitModelAdapter.h index 5ae6a6a99..e341507a2 100644 --- a/src/adapters/ExplicitModelAdapter.h +++ b/src/adapters/ExplicitModelAdapter.h @@ -116,7 +116,7 @@ namespace storm { // 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). 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); diff --git a/src/storage/prism/Program.cpp b/src/storage/prism/Program.cpp index 58d749ad8..ebf622c60 100644 --- a/src/storage/prism/Program.cpp +++ b/src/storage/prism/Program.cpp @@ -149,6 +149,11 @@ namespace storm { 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 const& Program::getRewardModels() const { return this->rewardModels; } diff --git a/src/storage/prism/Program.h b/src/storage/prism/Program.h index 56321600d..ad7777f85 100644 --- a/src/storage/prism/Program.h +++ b/src/storage/prism/Program.h @@ -226,6 +226,14 @@ namespace storm { */ 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. *