8 std::vector<storm::prism::StateActionReward>
const& stateActionRewards,
9 std::vector<storm::prism::TransitionReward>
const& transitionRewards, std::string
const& filename, uint_fast64_t lineNumber)
11 rewardModelName(rewardModelName),
12 stateRewards(stateRewards),
13 stateActionRewards(stateActionRewards),
14 transitionRewards(transitionRewards) {
19 return this->rewardModelName;
27 return !this->stateRewards.empty();
31 return this->stateRewards;
35 return !this->stateActionRewards.empty();
39 return this->stateActionRewards;
43 return !this->transitionRewards.empty();
47 return this->transitionRewards;
51 std::vector<StateReward> newStateRewards;
54 newStateRewards.emplace_back(stateReward.substitute(substitution));
57 std::vector<StateActionReward> newStateActionRewards;
60 newStateActionRewards.emplace_back(stateActionReward.substitute(substitution));
63 std::vector<TransitionReward> newTransitionRewards;
66 newTransitionRewards.emplace_back(transitionReward.substitute(substitution));
73 if (stateReward.getStatePredicateExpression().containsVariable(undefinedConstantVariables)) {
78 if (stateActionReward.getStatePredicateExpression().containsVariable(undefinedConstantVariables)) {
83 if (transitionReward.getSourceStatePredicateExpression().containsVariable(undefinedConstantVariables)) {
86 if (transitionReward.getTargetStatePredicateExpression().containsVariable(undefinedConstantVariables)) {
94 std::vector<StateActionReward> newStateActionRewards;
96 if (actionIndicesToKeep.find(stateActionReward.getActionIndex()) != actionIndicesToKeep.end()) {
97 newStateActionRewards.emplace_back(stateActionReward);
101 std::vector<TransitionReward> newTransitionRewards;
103 if (actionIndicesToKeep.find(transitionReward.getActionIndex()) != actionIndicesToKeep.end()) {
104 newTransitionRewards.emplace_back(transitionReward);
112 std::vector<StateActionReward> newStateActionRewards;
113 std::vector<TransitionReward> newTransitionRewards;
116 if (reward.getActionIndex() == 0) {
117 for (
auto const& newAction : newActions) {
118 newStateActionRewards.emplace_back(newAction.first, newAction.second, reward.getStatePredicateExpression(), reward.getRewardValueExpression(),
119 reward.getFilename(), reward.getLineNumber());
122 newStateActionRewards.push_back(reward);
126 STORM_LOG_ASSERT(transitionRewards.empty(),
"Expected empty transition rewards.");
133 if (rewardModel.
getName() !=
"") {
134 stream <<
" \"" << rewardModel.
getName() <<
"\"";
138 stream << reward <<
'\n';
141 stream << reward <<
'\n';
144 stream << reward <<
'\n';
146 stream <<
"endrewards\n";
std::vector< storm::prism::StateReward > const & getStateRewards() const
Retrieves all state rewards associated with this reward model.
bool hasStateRewards() const
Retrieves whether there are any state rewards.
RewardModel labelUnlabelledCommands(std::vector< std::pair< uint64_t, std::string > > const &newActionNames) const
RewardModel substitute(std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution) const
Substitutes all variables in the reward model according to the given map.
bool containsVariablesOnlyInRewardValueExpressions(std::set< storm::expressions::Variable > const &undefinedConstantVariables) const
Checks whether any of the given variables only appear in the expressions defining the reward value.
bool hasTransitionRewards() const
Retrieves whether there are any transition rewards.
RewardModel restrictActionRelatedRewards(storm::storage::FlatSet< uint_fast64_t > const &actionIndicesToKeep) const
Restricts all action-related rewards of the reward model to the ones with an action index in the prov...
RewardModel(std::string const &rewardModelName, std::vector< storm::prism::StateReward > const &stateRewards, std::vector< storm::prism::StateActionReward > const &stateActionRewards, std::vector< storm::prism::TransitionReward > const &transitionRewards, std::string const &filename="", uint_fast64_t lineNumber=0)
Creates a reward model with the given name, state and transition rewards.
std::vector< storm::prism::TransitionReward > const & getTransitionRewards() const
Retrieves all transition rewards associated with this reward model.
std::string const & getName() const
Retrieves the name of the reward model.
bool empty() const
Checks whether the reward model is empty, i.e.
bool hasStateActionRewards() const
Retrieves whether there are any state-action rewards.
std::vector< storm::prism::StateActionReward > const & getStateActionRewards() const
Retrieves all state-action rewards associated with this reward model.
#define STORM_LOG_ASSERT(cond, message)
std::ostream & operator<<(std::ostream &stream, Assignment const &assignment)
boost::container::flat_set< Key, std::less< Key >, boost::container::new_allocator< Key > > FlatSet
Redefinition of flat_set was needed, because from Boost 1.70 on the default allocator is set to void.