#ifndef STORM_MODELS_SPARSE_DTMC_H_ #define STORM_MODELS_SPARSE_DTMC_H_ #include #include "src/models/sparse/DeterministicModel.h" #include "src/utility/OsDetection.h" #include "src/utility/constants.h" #include "src/adapters/CarlAdapter.h" namespace storm { namespace models { namespace sparse { /*! * This class represents a discrete-time Markov chain. */ template class Dtmc : public DeterministicModel { public: /*! * Constructs a model from the given data. * * @param transitionMatrix The matrix representing the transitions in the model. * @param stateLabeling The labeling of the states. * @param optionalStateRewardVector The reward values associated with the states. * @param optionalTransitionRewardMatrix The reward values associated with the transitions of the model. * @param optionalChoiceLabeling A vector that represents the labels associated with the choices of each state. */ Dtmc(storm::storage::SparseMatrix const& probabilityMatrix, storm::models::sparse::StateLabeling const& stateLabeling, boost::optional> const& optionalStateRewardVector = boost::optional>(), boost::optional> const& optionalTransitionRewardMatrix = boost::optional>(), boost::optional> const& optionalChoiceLabeling = boost::optional>()); /*! * Constructs a model by moving the given data. * * @param transitionMatrix The matrix representing the transitions in the model. * @param stateLabeling The labeling of the states. * @param optionalStateRewardVector The reward values associated with the states. * @param optionalTransitionRewardMatrix The reward values associated with the transitions of the model. * @param optionalChoiceLabeling A vector that represents the labels associated with the choices of each state. */ Dtmc(storm::storage::SparseMatrix&& probabilityMatrix, storm::models::sparse::StateLabeling&& stateLabeling, boost::optional>&& optionalStateRewardVector = boost::optional>(), boost::optional>&& optionalTransitionRewardMatrix = boost::optional>(), boost::optional>&& optionalChoiceLabeling = boost::optional>()); Dtmc(Dtmc const& dtmc) = default; Dtmc& operator=(Dtmc const& dtmc) = default; #ifndef WINDOWS Dtmc(Dtmc&& dtmc) = default; Dtmc& operator=(Dtmc&& dtmc) = default; #endif /*! * Retrieves the sub-DTMC that only contains the given set of states. * * @param states The states of the sub-DTMC. * @return The resulting sub-DTMC. */ Dtmc getSubDtmc(storm::storage::BitVector const& states) const; #ifdef STORM_HAVE_CARL class ConstraintCollector { private: // A set of constraints that says that the DTMC actually has valid probability distributions in all states. std::unordered_set> wellformedConstraintSet; // A set of constraints that makes sure that the underlying graph of the model does not change depending // on the parameter values. std::unordered_set> graphPreservingConstraintSet; // A comparator that is used for storm::utility::ConstantsComparator comparator; public: /*! * Constructs the a constraint collector for the given DTMC. The constraints are built and ready for * retrieval after the construction. * * @param dtmc The DTMC for which to create the constraints. */ ConstraintCollector(storm::models::sparse::Dtmc const& dtmc); /*! * Returns the set of wellformed-ness constraints. * * @return The set of wellformed-ness constraints. */ std::unordered_set> const& getWellformedConstraints() const; /*! * Returns the set of graph-preserving constraints. * * @return The set of graph-preserving constraints. */ std::unordered_set> const& getGraphPreservingConstraints() const; /*! * Constructs the constraints for the given DTMC. * * @param dtmc The DTMC for which to create the constraints. */ void process(storm::models::sparse::Dtmc const& dtmc); /*! * Constructs the constraints for the given DTMC by calling the process method. * * @param dtmc The DTMC for which to create the constraints. */ void operator()(storm::models::sparse::Dtmc const& dtmc); }; #endif private: /*! * Checks the probability matrix for validity. * * @return True iff the probability matrix is valid. */ bool checkValidityOfProbabilityMatrix() const; }; } // namespace sparse } // namespace models } // namespace storm #endif /* STORM_MODELS_SPARSE_DTMC_H_ */