#ifndef STORM_GENERATOR_NEXTSTATEGENERATOR_H_ #define STORM_GENERATOR_NEXTSTATEGENERATOR_H_ #include #include #include #include "storm/storage/expressions/Expression.h" #include "storm/storage/BitVectorHashMap.h" #include "storm/storage/expressions/ExpressionEvaluator.h" #include "storm/storage/sparse/ChoiceOrigins.h" #include "storm/builder/BuilderOptions.h" #include "storm/builder/RewardModelInformation.h" #include "storm/generator/VariableInformation.h" #include "storm/generator/CompressedState.h" #include "storm/generator/StateBehavior.h" #include "storm/utility/ConstantsComparator.h" namespace storm { namespace generator { typedef storm::builder::BuilderOptions NextStateGeneratorOptions; enum class ModelType { DTMC, CTMC, MDP, MA }; template class NextStateGenerator { public: typedef std::function StateToIdCallback; NextStateGenerator(storm::expressions::ExpressionManager const& expressionManager, VariableInformation const& variableInformation, NextStateGeneratorOptions const& options); /*! * Creates a new next state generator. This version of the constructor default-constructs the variable information. * Hence, the subclass is responsible for suitably initializing it in its constructor. */ NextStateGenerator(storm::expressions::ExpressionManager const& expressionManager, NextStateGeneratorOptions const& options); uint64_t getStateSize() const; virtual ModelType getModelType() const = 0; virtual bool isDeterministicModel() const = 0; virtual bool isDiscreteTimeModel() const = 0; virtual std::vector getInitialStates(StateToIdCallback const& stateToIdCallback) = 0; void load(CompressedState const& state); virtual StateBehavior expand(StateToIdCallback const& stateToIdCallback) = 0; bool satisfies(storm::expressions::Expression const& expression) const; virtual std::size_t getNumberOfRewardModels() const = 0; virtual storm::builder::RewardModelInformation getRewardModelInformation(uint64_t const& index) const = 0; storm::expressions::SimpleValuation toValuation(CompressedState const& state) const; virtual storm::models::sparse::StateLabeling label(storm::storage::BitVectorHashMap const& states, std::vector const& initialStateIndices = {}, std::vector const& deadlockStateIndices = {}) = 0; NextStateGeneratorOptions const& getOptions() const; virtual std::shared_ptr generateChoiceOrigins(std::vector& dataForChoiceOrigins) const; protected: /*! * Creates the state labeling for the given states using the provided labels and expressions. */ storm::models::sparse::StateLabeling label(storm::storage::BitVectorHashMap const& states, std::vector const& initialStateIndices, std::vector const& deadlockStateIndices, std::vector> labelsAndExpressions); void postprocess(StateBehavior& result); /// The options to be used for next-state generation. NextStateGeneratorOptions options; /// The expression manager used for evaluating expressions. std::shared_ptr expressionManager; /// The expressions that define terminal states. std::vector> terminalStates; /// Information about how the variables are packed. VariableInformation variableInformation; /// An evaluator used to evaluate expressions. std::unique_ptr> evaluator; /// The currently loaded state. CompressedState const* state; /// A comparator used to compare constants. storm::utility::ConstantsComparator comparator; }; } } #endif /* STORM_GENERATOR_NEXTSTATEGENERATOR_H_ */