#ifndef STORM_MODELS_ABSTRACTDETERMINISTICMODEL_H_ #define STORM_MODELS_ABSTRACTDETERMINISTICMODEL_H_ #include "AbstractModel.h" #include #include namespace storm { namespace models { /*! * @brief Base class for all deterministic model classes. * * This is base class defines a common interface for all deterministic models. */ template class AbstractDeterministicModel: public AbstractModel { public: /*! Constructs an abstract determinstic model from the given parameters. * All values are copied. * @param transitionMatrix The matrix representing the transitions in the model. * @param stateLabeling The labeling that assigns a set of atomic * propositions to each state. * @param stateRewardVector The reward values associated with the states. * @param transitionRewardMatrix The reward values associated with the transitions of the model. */ AbstractDeterministicModel(storm::storage::SparseMatrix const& transitionMatrix, storm::models::AtomicPropositionsLabeling const& stateLabeling, boost::optional> const& optionalStateRewardVector, boost::optional> const& optionalTransitionRewardMatrix, boost::optional>> const& optionalChoiceLabeling) : AbstractModel(transitionMatrix, stateLabeling, optionalStateRewardVector, optionalTransitionRewardMatrix, optionalChoiceLabeling) { } /*! Constructs an abstract determinstic model from the given parameters. * Moves all references. * @param transitionMatrix The matrix representing the transitions in the model. * @param stateLabeling The labeling that assigns a set of atomic * propositions to each state. * @param stateRewardVector The reward values associated with the states. * @param transitionRewardMatrix The reward values associated with the transitions of the model. */ AbstractDeterministicModel(storm::storage::SparseMatrix&& transitionMatrix, storm::models::AtomicPropositionsLabeling&& stateLabeling, boost::optional>&& optionalStateRewardVector, boost::optional>&& optionalTransitionRewardMatrix, boost::optional>>&& optionalChoiceLabeling) // The std::move call must be repeated here because otherwise this calls the copy constructor of the Base Class : AbstractModel(std::move(transitionMatrix), std::move(stateLabeling), std::move(optionalStateRewardVector), std::move(optionalTransitionRewardMatrix), std::move(optionalChoiceLabeling)) { // Intentionally left empty. } /*! * Destructor. */ virtual ~AbstractDeterministicModel() { // Intentionally left empty. } /*! * Copy Constructor. */ AbstractDeterministicModel(AbstractDeterministicModel const& other) : AbstractModel(other) { // Intentionally left empty. } /*! * Move Constructor. */ AbstractDeterministicModel(AbstractDeterministicModel && other) : AbstractModel(std::move(other)) { // Intentionally left empty. } virtual typename storm::storage::SparseMatrix::Rows getRows(uint_fast64_t state) const override { return this->transitionMatrix.getRows(state, state); } virtual typename storm::storage::SparseMatrix::ConstRowIterator rowIteratorBegin(uint_fast64_t state) const override { return this->transitionMatrix.begin(state); } virtual typename storm::storage::SparseMatrix::ConstRowIterator rowIteratorEnd(uint_fast64_t state) const override { return this->transitionMatrix.end(state); } /*! * Calculates a hash over all values contained in this Model. * @return size_t A Hash Value */ virtual std::size_t getHash() const override { return AbstractModel::getHash(); } virtual void writeDotToStream(std::ostream& outStream, bool includeLabeling = true, storm::storage::BitVector const* subsystem = nullptr, std::vector const* firstValue = nullptr, std::vector const* secondValue = nullptr, std::vector const* stateColoring = nullptr, std::vector const* colors = nullptr, std::vector* scheduler = nullptr, bool finalizeOutput = true) const override { AbstractModel::writeDotToStream(outStream, includeLabeling, subsystem, firstValue, secondValue, stateColoring, colors, scheduler, false); // Simply iterate over all transitions and draw the arrows with probability information attached. auto rowIt = this->transitionMatrix.begin(); for (uint_fast64_t i = 0; i < this->transitionMatrix.getRowCount(); ++i, ++rowIt) { for (auto transitionIt = rowIt.begin(), transitionIte = rowIt.end(); transitionIt != transitionIte; ++transitionIt) { if (transitionIt.value() != storm::utility::constGetZero()) { if (subsystem == nullptr || subsystem->get(transitionIt.column())) { outStream << "\t" << i << " -> " << transitionIt.column() << " [ label= \"" << transitionIt.value() << "\" ];" << std::endl; } } } } if (finalizeOutput) { outStream << "}" << std::endl; } } /*! * Assigns this model a new set of choiceLabels, giving each state a label with the stateId * @return void */ virtual void setStateIdBasedChoiceLabeling() override { std::vector> newChoiceLabeling; size_t stateCount = this->getNumberOfStates(); newChoiceLabeling.resize(stateCount); for (size_t state = 0; state < stateCount; ++state) { newChoiceLabeling.at(state).push_back(state); } this->choiceLabeling.reset(newChoiceLabeling); } }; } // namespace models } // namespace storm #endif /* STORM_MODELS_ABSTRACTDETERMINISTICMODEL_H_ */