#ifndef EXPLICITDFTMODELBUILDER_H #define EXPLICITDFTMODELBUILDER_H #include #include #include #include #include #include #include #include #include #include #include namespace storm { namespace builder { template class ExplicitDFTModelBuilder { using DFTElementPointer = std::shared_ptr>; using DFTElementCPointer = std::shared_ptr const>; using DFTGatePointer = std::shared_ptr>; using DFTStatePointer = std::shared_ptr>; using DFTRestrictionPointer = std::shared_ptr>; // A structure holding the individual components of a model. struct ModelComponents { ModelComponents(); // The transition matrix. storm::storage::SparseMatrix transitionMatrix; // The state labeling. storm::models::sparse::StateLabeling stateLabeling; // The Markovian states. storm::storage::BitVector markovianStates; // The exit rates. std::vector exitRates; // A vector that stores a labeling for each choice. boost::optional>> choiceLabeling; }; const size_t INITIAL_BUCKETSIZE = 20000; const uint_fast64_t OFFSET_PSEUDO_STATE = UINT_FAST64_MAX / 2; storm::storage::DFT const& mDft; std::shared_ptr mStateGenerationInfo; storm::storage::BitVectorHashMap mStates; std::vector> mPseudoStatesMapping; // vector of (id to concrete state, bitvector) size_t newIndex = 0; bool mergeFailedStates = true; bool enableDC = true; size_t failedIndex = 0; size_t initialStateIndex = 0; public: struct LabelOptions { bool buildFailLabel = true; bool buildFailSafeLabel = false; std::set beLabels = {}; }; ExplicitDFTModelBuilder(storm::storage::DFT const& dft, storm::storage::DFTIndependentSymmetries const& symmetries, bool enableDC); std::shared_ptr> buildModel(LabelOptions const& labelOpts); private: std::pair exploreStates(DFTStatePointer const& state, size_t& rowOffset, storm::storage::SparseMatrixBuilder& transitionMatrixBuilder, std::vector& markovianStates, std::vector& exitRates); /*! * Adds a state to the explored states and handles pseudo states. * * @param state The state to add. * @return Id of added state. */ uint_fast64_t addState(DFTStatePointer const& state); /*! * Check if state needs an exploration and remember pseudo states for later creation. * * @param state State which might need exploration. * @return Pair of flag indicating whether the state needs exploration now and the state id if the state already * exists. */ std::pair checkForExploration(DFTStatePointer const& state); }; } } #endif /* EXPLICITDFTMODELBUILDER_H */