Browse Source

accessors for model

main
Sebastian Junges 4 years ago
parent
commit
00a85cb184
  1. 22
      src/storm/models/sparse/Model.cpp
  2. 14
      src/storm/models/sparse/Model.h

22
src/storm/models/sparse/Model.cpp

@ -111,6 +111,11 @@ namespace storm {
return this->getStates("init"); return this->getStates("init");
} }
template<typename ValueType, typename RewardModelType>
void Model<ValueType, RewardModelType>::setInitialStates(storm::storage::BitVector const& states) {
return this->getStateLabeling().setStates("init", states);
}
template<typename ValueType, typename RewardModelType> template<typename ValueType, typename RewardModelType>
storm::storage::BitVector const& Model<ValueType, RewardModelType>::getStates(std::string const& label) const { storm::storage::BitVector const& Model<ValueType, RewardModelType>::getStates(std::string const& label) const {
return stateLabeling.getStates(label); return stateLabeling.getStates(label);
@ -159,6 +164,23 @@ namespace storm {
return it->second; return it->second;
} }
template<typename ValueType, typename RewardModelType>
RewardModelType& Model<ValueType, RewardModelType>::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<typename ValueType, typename RewardModelType> template<typename ValueType, typename RewardModelType>
void Model<ValueType, RewardModelType>::addRewardModel(std::string const& rewardModelName, RewardModelType const& newRewardModel) { void Model<ValueType, RewardModelType>::addRewardModel(std::string const& rewardModelName, RewardModelType const& newRewardModel) {
if (this->hasRewardModel(rewardModelName)) { if (this->hasRewardModel(rewardModelName)) {

14
src/storm/models/sparse/Model.h

@ -91,6 +91,13 @@ namespace storm {
*/ */
storm::storage::BitVector const& getInitialStates() const; 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. * Returns the sets of states labeled with the given label.
* *
@ -150,6 +157,13 @@ namespace storm {
*/ */
RewardModelType const& getRewardModel(std::string const& rewardModelName) const; 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. * Retrieves the unique reward model, if there exists exactly one. Otherwise, an exception is thrown.
* *

Loading…
Cancel
Save