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

@ -139,6 +139,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>
ValueType StandardRewardModel<ValueType>::getTotalStateActionReward(uint_fast64_t stateIndex, uint_fast64_t choiceIndex, storm::storage::SparseMatrix<MatrixValueType> const& transitionMatrix, MatrixValueType const& stateRewardWeight, MatrixValueType const& actionRewardWeight) const {

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

@ -188,6 +188,13 @@ namespace storm {
*/
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
* the corresponding flag is set, the state-action rewards and the state rewards are summed so the model

Loading…
Cancel
Save