diff --git a/src/storm/models/sparse/StandardRewardModel.cpp b/src/storm/models/sparse/StandardRewardModel.cpp index 190449ea6..159c39446 100644 --- a/src/storm/models/sparse/StandardRewardModel.cpp +++ b/src/storm/models/sparse/StandardRewardModel.cpp @@ -138,6 +138,20 @@ namespace storm { } return StandardRewardModel(std::move(newStateRewardVector), std::move(newStateActionRewardVector), std::move(newTransitionRewardMatrix)); } + + template + StandardRewardModel StandardRewardModel::permuteActions(std::vector const& inversePermutation) const { + boost::optional> newStateRewardVector(this->getOptionalStateRewardVector()); + boost::optional> newStateActionRewardVector; + if (this->hasStateActionRewards()) { + newStateActionRewardVector = storm::utility::vector::applyInversePermutation(inversePermutation, this->getStateActionRewardVector()); + } + boost::optional> newTransitionRewardMatrix; + if (this->hasTransitionRewards()) { + newTransitionRewardMatrix = this->getTransitionRewardMatrix().permuteRows(inversePermutation); + } + return StandardRewardModel(std::move(newStateRewardVector), std::move(newStateActionRewardVector), std::move(newTransitionRewardMatrix)); + } template template diff --git a/src/storm/models/sparse/StandardRewardModel.h b/src/storm/models/sparse/StandardRewardModel.h index ac725d06c..2bfed8143 100644 --- a/src/storm/models/sparse/StandardRewardModel.h +++ b/src/storm/models/sparse/StandardRewardModel.h @@ -187,6 +187,13 @@ namespace storm { * @return The restricted reward model. */ StandardRewardModel 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 permuteActions(std::vector const& inversePermutation) const; /*! * Reduces the transition-based rewards to state-action rewards by taking the average of each row. If