From 7e7e025900b58ef4486846dabfd7176ddfcf2f74 Mon Sep 17 00:00:00 2001 From: sjunges Date: Tue, 29 Sep 2015 16:07:33 +0200 Subject: [PATCH] modifying reward models Former-commit-id: 401410cee6b55ba457dc2738328b1cd5d542a750 --- src/models/sparse/NondeterministicModel.cpp | 20 ++++++++++++++++++++ src/models/sparse/NondeterministicModel.h | 8 +++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/models/sparse/NondeterministicModel.cpp b/src/models/sparse/NondeterministicModel.cpp index 9cfbe75f9..d0b0a5a25 100644 --- a/src/models/sparse/NondeterministicModel.cpp +++ b/src/models/sparse/NondeterministicModel.cpp @@ -62,6 +62,24 @@ namespace storm { } } } + + template + template + void NondeterministicModel::modifyStateActionRewards(std::string const& modelName, std::map const& modifications) { + RewardModelType& rewardModel = this->rewardModel(modelName); + for(auto const& mod : modifications) { + rewardModel.setStateActionReward(mod.first, mod.second); + } + }; + + template + template + void NondeterministicModel::modifyStateRewards(std::string const& modelName, std::map const& modifications) { + RewardModelType& rewardModel = this->rewardModel(modelName); + for(auto const& mod : modifications) { + rewardModel.setStateReward(mod.first, mod.second); + } + }; template void NondeterministicModel::reduceToStateBasedRewards() { @@ -152,6 +170,8 @@ namespace storm { #ifdef STORM_HAVE_CARL template class NondeterministicModel>; + template void NondeterministicModel>::modifyStateActionRewards(std::string const& modelName, std::map const& modifications); + template void NondeterministicModel>::modifyStateRewards(std::string const& modelName, std::map const& modifications); template class NondeterministicModel; #endif diff --git a/src/models/sparse/NondeterministicModel.h b/src/models/sparse/NondeterministicModel.h index 5bacf6dd7..e236cbca7 100644 --- a/src/models/sparse/NondeterministicModel.h +++ b/src/models/sparse/NondeterministicModel.h @@ -81,7 +81,13 @@ namespace storm { * @param modifications A mapping from state-action pairs to the their new reward values. */ void modifyStateActionRewards(RewardModelType& rewardModel, std::map, typename RewardModelType::ValueType> const& modifications) const; - + + template + void modifyStateActionRewards(std::string const& modelName, std::map const& modifications); + template + void modifyStateRewards(std::string const& modelName, std::map const& modifications); + + virtual void reduceToStateBasedRewards() override; virtual void printModelInformationToStream(std::ostream& out) const override;