Browse Source

accessors for model

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

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

@ -110,12 +110,17 @@ namespace storm {
storm::storage::BitVector const& Model<ValueType, RewardModelType>::getInitialStates() const {
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>
storm::storage::BitVector const& Model<ValueType, RewardModelType>::getStates(std::string const& label) const {
return stateLabeling.getStates(label);
}
template<typename ValueType, typename RewardModelType>
bool Model<ValueType, RewardModelType>::hasLabel(std::string const& label) const {
return stateLabeling.containsLabel(label);
@ -159,6 +164,23 @@ namespace storm {
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>
void Model<ValueType, RewardModelType>::addRewardModel(std::string const& rewardModelName, RewardModelType const& newRewardModel) {
if (this->hasRewardModel(rewardModelName)) {

14
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.
*

Loading…
Cancel
Save