#ifndef STORM_MODELS_SYMBOLIC_STANDARDREWARDMODEL_H_ #define STORM_MODELS_SYMBOLIC_STANDARDREWARDMODEL_H_ #include #include #include "storm/storage/dd/DdType.h" namespace storm { namespace dd { template class Add; template class Bdd; } namespace expressions { class Variable; } namespace models { namespace symbolic { template class StandardRewardModel { public: /*! * Builds a reward model by copying with the given reward structures. * * @param stateRewardVector The state reward vector. * @param stateActionRewardVector The vector of state-action rewards. * @param transitionRewardMatrix The matrix of transition rewards. */ explicit StandardRewardModel(boost::optional> const& stateRewardVector, boost::optional> const& stateActionRewardVector, boost::optional> const& transitionRewardMatrix); /*! * Retrieves whether the reward model is empty. * * @return True iff the reward model is empty. */ bool empty() const; /*! * Retrieves whether the reward model has state rewards. * * @return True iff the reward model has state rewards. */ bool hasStateRewards() const; /*! * Retrieves whether the reward model only has state rewards (and hence no other rewards). * * @return True iff the reward model only has state rewards. */ bool hasOnlyStateRewards() const; /*! * Retrieves the state rewards of the reward model. Note that it is illegal to call this function if the * reward model does not have state rewards. * * @return The state reward vector. */ storm::dd::Add const& getStateRewardVector() const; /*! * Retrieves the state rewards of the reward model. Note that it is illegal to call this function if the * reward model does not have state rewards. * * @return The state reward vector. */ storm::dd::Add& getStateRewardVector(); /*! * Retrieves an optional value that contains the state reward vector if there is one. * * @return The state reward vector if there is one. */ boost::optional> const& getOptionalStateRewardVector() const; /*! * Retrieves whether the reward model has state-action rewards. * * @return True iff the reward model has state-action rewards. */ bool hasStateActionRewards() const; /*! * Retrieves the state-action rewards of the reward model. Note that it is illegal to call this function * if the reward model does not have state-action rewards. * * @return The state-action reward vector. */ storm::dd::Add const& getStateActionRewardVector() const; /*! * Retrieves the state-action rewards of the reward model. Note that it is illegal to call this function * if the reward model does not have state-action rewards. * * @return The state-action reward vector. */ storm::dd::Add& getStateActionRewardVector(); /*! * Retrieves an optional value that contains the state-action reward vector if there is one. * * @return The state-action reward vector if there is one. */ boost::optional> const& getOptionalStateActionRewardVector() const; /*! * Retrieves whether the reward model has transition rewards. * * @return True iff the reward model has transition rewards. */ bool hasTransitionRewards() const; /*! * Retrieves the transition rewards of the reward model. Note that it is illegal to call this function * if the reward model does not have transition rewards. * * @return The transition reward matrix. */ storm::dd::Add const& getTransitionRewardMatrix() const; /*! * Retrieves the transition rewards of the reward model. Note that it is illegal to call this function * if the reward model does not have transition rewards. * * @return The transition reward matrix. */ storm::dd::Add& getTransitionRewardMatrix(); /*! * Retrieves an optional value that contains the transition reward matrix if there is one. * * @return The transition reward matrix if there is one. */ boost::optional> const& getOptionalTransitionRewardMatrix() const; /*! * Creates a vector representing the complete reward vector based on the state-, state-action- and * transition-based rewards in the reward model. * * @param transitionMatrix The matrix that is used to weight the values of the transition reward matrix. * @param columnVariables The column variables of the model. * @return The full state-action reward vector. */ storm::dd::Add getTotalRewardVector(storm::dd::Add const& transitionMatrix, std::set const& columnVariables) const; /*! * Creates a vector representing the complete reward vector based on the state-, state-action- and * transition-based rewards in the reward model. The state- and state-action rewards are filtered with * the given filter DD. * * @param filterAdd The DD used for filtering the rewards. * @param transitionMatrix The matrix that is used to weight the values of the transition reward matrix. * @param columnVariables The column variables of the model. * @return The full state-action reward vector. */ storm::dd::Add getTotalRewardVector(storm::dd::Add const& filterAdd, storm::dd::Add const& transitionMatrix, std::set const& columnVariables) const; /*! * Creates a vector representing the complete reward vector based on the state-, state-action- and * transition-based rewards in the reward model. * * @param transitionMatrix The matrix that is used to weight the values of the transition reward matrix. * @param columnVariables The column variables of the model. * @param weights The weights used to scale the transition rewards and/or state-action rewards. * @param scaleTransAndActions If true both transition rewards and state-action rewards are scaled by the * weights. Otherwise, only the state-action rewards are scaled. * @return The full state-action reward vector. */ storm::dd::Add getTotalRewardVector(storm::dd::Add const& transitionMatrix, std::set const& columnVariables, storm::dd::Add const& weights, bool scaleTransAndActions) const; /*! * Multiplies all components of the reward model with the given DD. * * @param filter The filter with which to multiply */ StandardRewardModel& operator*=(storm::dd::Add const& filter); /*! * Divides the state reward vector of the reward model by the given divisor. * * @param divisor The vector to divide by. * @return The resulting reward model. */ StandardRewardModel divideStateRewardVector(storm::dd::Add const& divisor) const; private: // The state reward vector. boost::optional> optionalStateRewardVector; // A vector of state-action-based rewards. boost::optional> optionalStateActionRewardVector; // A matrix of transition rewards. boost::optional> optionalTransitionRewardMatrix; }; } } } #endif /* STORM_MODELS_SYMBOLIC_STANDARDREWARDMODEL_H_ */