diff --git a/src/storm/models/sparse/Model.cpp b/src/storm/models/sparse/Model.cpp index bf9d69d4c..d9aec86fb 100644 --- a/src/storm/models/sparse/Model.cpp +++ b/src/storm/models/sparse/Model.cpp @@ -110,12 +110,17 @@ namespace storm { storm::storage::BitVector const& Model::getInitialStates() const { return this->getStates("init"); } + + template + void Model::setInitialStates(storm::storage::BitVector const& states) { + return this->getStateLabeling().setStates("init", states); + } template storm::storage::BitVector const& Model::getStates(std::string const& label) const { return stateLabeling.getStates(label); } - + template bool Model::hasLabel(std::string const& label) const { return stateLabeling.containsLabel(label); @@ -159,6 +164,23 @@ namespace storm { return it->second; } + template + RewardModelType& Model::getRewardModel(std::string const& rewardModelName) { + auto it = this->rewardModels.find(rewardModelName); + if (it == this->rewardModels.end()) { + if (rewardModelName.empty()) { + if (this->hasUniqueRewardModel()) { + return this->getUniqueRewardModel(); + } else { + STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentException, "Unable to refer to default reward model, because there is no default model or it is not unique."); + } + } else { + STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentException, "The requested reward model '" << rewardModelName << "' does not exist."); + } + } + return it->second; + } + template void Model::addRewardModel(std::string const& rewardModelName, RewardModelType const& newRewardModel) { if (this->hasRewardModel(rewardModelName)) { diff --git a/src/storm/models/sparse/Model.h b/src/storm/models/sparse/Model.h index 7c747f0a9..962e17dbf 100644 --- a/src/storm/models/sparse/Model.h +++ b/src/storm/models/sparse/Model.h @@ -90,6 +90,13 @@ namespace storm { * @return The initial states of the model represented by a bit vector. */ storm::storage::BitVector const& getInitialStates() const; + + /*! + * Overwrites the initial states of the model. + * + * @param states the new initial states + */ + void setInitialStates(storm::storage::BitVector const& states); /*! * Returns the sets of states labeled with the given label. @@ -150,6 +157,13 @@ namespace storm { */ RewardModelType const& getRewardModel(std::string const& rewardModelName) const; + /*! + * Retrieves the reward model with the given name, if one exists. Otherwise, an exception is thrown. + * + * @return The reward model with the given name, if it exists. + */ + RewardModelType& getRewardModel(std::string const& rewardModelName); + /*! * Retrieves the unique reward model, if there exists exactly one. Otherwise, an exception is thrown. *