Browse Source

interface for rew. model extended for reinforcement learning

Former-commit-id: b69474fc4f
tempestpy_adaptions
sjunges 9 years ago
parent
commit
98162d1d7e
  1. 18
      src/models/sparse/StandardRewardModel.cpp
  2. 9
      src/models/sparse/StandardRewardModel.h

18
src/models/sparse/StandardRewardModel.cpp

@ -37,11 +37,13 @@ namespace storm {
template<typename ValueType>
std::vector<ValueType> const& StandardRewardModel<ValueType>::getStateRewardVector() const {
assert(this->hasStateRewards());
return this->optionalStateRewardVector.get();
}
template<typename ValueType>
std::vector<ValueType>& StandardRewardModel<ValueType>::getStateRewardVector() {
assert(this->hasStateRewards());
return this->optionalStateRewardVector.get();
}
@ -49,6 +51,13 @@ namespace storm {
boost::optional<std::vector<ValueType>> const& StandardRewardModel<ValueType>::getOptionalStateRewardVector() const {
return this->optionalStateRewardVector;
}
template<typename ValueType>
ValueType const& StandardRewardModel<ValueType>::getStateReward(uint_fast64_t state) const {
assert(this->hasStateRewards());
assert(state < this->optionalStateRewardVector.get().size());
return this->optionalStateRewardVector.get()[state];
}
template<typename ValueType>
bool StandardRewardModel<ValueType>::hasStateActionRewards() const {
@ -57,13 +66,22 @@ namespace storm {
template<typename ValueType>
std::vector<ValueType> const& StandardRewardModel<ValueType>::getStateActionRewardVector() const {
assert(this->hasStateActionRewards());
return this->optionalStateActionRewardVector.get();
}
template<typename ValueType>
std::vector<ValueType>& StandardRewardModel<ValueType>::getStateActionRewardVector() {
assert(this->hasStateActionRewards());
return this->optionalStateActionRewardVector.get();
}
template<typename ValueType>
ValueType const& StandardRewardModel<ValueType>::getStateActionReward(uint_fast64_t choiceIndex) const {
assert(this->hasStateActionRewards());
assert(choiceIndex < this->optionalStateActionRewardVector.get().size());
return this->optionalStateActionRewardVector.get()[choiceIndex];
}
template<typename ValueType>
boost::optional<std::vector<ValueType>> const& StandardRewardModel<ValueType>::getOptionalStateActionRewardVector() const {

9
src/models/sparse/StandardRewardModel.h

@ -74,6 +74,8 @@ namespace storm {
* @return The state reward vector.
*/
std::vector<ValueType>& getStateRewardVector();
ValueType const& getStateReward(uint_fast64_t state) const;
/*!
* Retrieves an optional value that contains the state reward vector if there is one.
@ -104,7 +106,12 @@ namespace storm {
* @return The state-action reward vector.
*/
std::vector<ValueType>& getStateActionRewardVector();
/*!
* Retrieves the state-action reward for the given choice.
*/
ValueType const& getStateActionReward(uint_fast64_t choiceIndex) const;
/*!
* Retrieves an optional value that contains the state-action reward vector if there is one.
*

Loading…
Cancel
Save