#pragma once #include "storm/generator/NextStateGenerator.h" #include "storm/utility/ConstantsComparator.h" #include "storm-dft/storage/dft/DFT.h" namespace storm { namespace generator { /*! * Next state generator for DFTs. */ template class DftNextStateGenerator { // TODO: inherit from NextStateGenerator using DFTStatePointer = std::shared_ptr>; using DFTElementPointer = std::shared_ptr>; using DFTGatePointer = std::shared_ptr>; using DFTRestrictionPointer = std::shared_ptr>; public: typedef std::function StateToIdCallback; DftNextStateGenerator(storm::storage::DFT const& dft, storm::storage::DFTStateGenerationInfo const& stateGenerationInfo); bool isDeterministicModel() const; std::vector getInitialStates(StateToIdCallback const& stateToIdCallback); void load(storm::storage::BitVector const& state); void load(DFTStatePointer const& state); /*! * Expand and explore current state. * @param stateToIdCallback Callback function which adds new state and returns the corresponding id. * @return StateBehavior containing successor choices and distributions. */ StateBehavior expand(StateToIdCallback const& stateToIdCallback); /*! * Create unique failed state. * * @param stateToIdCallback Callback for state. The callback should just return the id and not use the state. * * @return Behavior of state. */ StateBehavior createMergeFailedState(StateToIdCallback const& stateToIdCallback); /** * Propagate the failures in a given state if the given BE fails * * @param newState starting state of the propagation * @param nextBE BE whose failure is propagated */ void propagateFailure(DFTStatePointer newState, std::shared_ptr const> &nextBE, storm::storage::DFTStateSpaceGenerationQueues &queues); /** * Propagate the failsafe state in a given state if the given BE fails * * @param newState starting state of the propagation * @param nextBE BE whose failure is propagated */ void propagateFailsafe(DFTStatePointer newState, std::shared_ptr const> &nextBE, storm::storage::DFTStateSpaceGenerationQueues &queues); private: /*! * Explore current state and generate all successor states. * @param stateToIdCallback Callback function which adds new state and returns the corresponding id. * @param exploreDependencies Flag indicating whether failures due to dependencies or due to BEs should be explored. * @param takeFirstDependency If true, instead of exploring all possible orders of dependency failures, a fixed order is explored where always the first dependency is considered. * @return StateBehavior containing successor choices and distributions. */ StateBehavior exploreState(StateToIdCallback const& stateToIdCallback, bool exploreDependencies, bool takeFirstDependency); // The dft used for the generation of next states. storm::storage::DFT const& mDft; // General information for the state generation. storm::storage::DFTStateGenerationInfo const& mStateGenerationInfo; // Current state DFTStatePointer state; // Flag indicating whether all failed states should be merged into one unique failed state. bool uniqueFailedState; // Flag indicating whether the model is deterministic. bool deterministicModel = false; // Flag indicating whether only the first dependency (instead of all) should be explored. bool mTakeFirstDependency = false; }; } }