Browse Source

permute actions in reward models

tempestpy_adaptions
Sebastian Junges 5 years ago
parent
commit
a53b7ca005
  1. 14
      src/storm/models/sparse/StandardRewardModel.cpp
  2. 7
      src/storm/models/sparse/StandardRewardModel.h

14
src/storm/models/sparse/StandardRewardModel.cpp

@ -138,6 +138,20 @@ namespace storm {
}
return StandardRewardModel(std::move(newStateRewardVector), std::move(newStateActionRewardVector), std::move(newTransitionRewardMatrix));
}
template<typename ValueType>
StandardRewardModel<ValueType> StandardRewardModel<ValueType>::permuteActions(std::vector<uint64_t> const& inversePermutation) const {
boost::optional<std::vector<ValueType>> newStateRewardVector(this->getOptionalStateRewardVector());
boost::optional<std::vector<ValueType>> newStateActionRewardVector;
if (this->hasStateActionRewards()) {
newStateActionRewardVector = storm::utility::vector::applyInversePermutation(inversePermutation, this->getStateActionRewardVector());
}
boost::optional<storm::storage::SparseMatrix<ValueType>> newTransitionRewardMatrix;
if (this->hasTransitionRewards()) {
newTransitionRewardMatrix = this->getTransitionRewardMatrix().permuteRows(inversePermutation);
}
return StandardRewardModel(std::move(newStateRewardVector), std::move(newStateActionRewardVector), std::move(newTransitionRewardMatrix));
}
template<typename ValueType>
template<typename MatrixValueType>

7
src/storm/models/sparse/StandardRewardModel.h

@ -187,6 +187,13 @@ namespace storm {
* @return The restricted reward model.
*/
StandardRewardModel<ValueType> restrictActions(storm::storage::BitVector const& enabledActions) const;
/*!
* Creates a new reward model by permuting the actions.
* That is, in row i, write the action reward of row inversePermutation[i].
*
*/
StandardRewardModel<ValueType> permuteActions(std::vector<uint64_t> const& inversePermutation) const;
/*!
* Reduces the transition-based rewards to state-action rewards by taking the average of each row. If

Loading…
Cancel
Save