#ifndef STORM_STORAGE_PRISM_MENU_GAMES_ABSTRACTCOMMAND_H_ #define STORM_STORAGE_PRISM_MENU_GAMES_ABSTRACTCOMMAND_H_ #include #include #include #include #include "src/storage/prism/menu_games/VariablePartition.h" #include "src/storage/dd/DdType.h" #include "src/storage/expressions/Expression.h" #include "src/solver/SmtSolver.h" #include "src/utility/solver.h" namespace storm { namespace prism { // Forward-declare concrete command and assignment classes. class Command; class Assignment; namespace menu_games { template class AbstractionDdInformation; class AbstractionExpressionInformation; template class AbstractCommand { public: /*! * Constructs an abstract command from the given command and the initial predicates. * * @param command The concrete command for which to build the abstraction. * @param expressionInformation The expression-related information including the manager and the predicates. * @param ddInformation The DD-related information including the manager. * @param smtSolverFactory A factory that is to be used for creating new SMT solvers. */ AbstractCommand(storm::prism::Command const& command, AbstractionExpressionInformation const& expressionInformation, AbstractionDdInformation const& ddInformation, storm::utility::solver::SmtSolverFactory const& smtSolverFactory); /*! * Refines the abstract command with the given predicates. * * @param predicates The new predicates. */ void refine(std::vector const& predicates); /*! * Computes the abstraction of the command wrt. to the current set of predicates. * * @return The abstraction of the command in the form of a BDD together with the number of DD variables * used to encode the choices of player 2. */ std::pair, uint_fast64_t> getAbstractBdd(); private: /*! * Determines the relevant predicates for source as well as successor states wrt. to the given assignments * (that, for example, form an update). * * @param assignments The assignments that are to be considered. * @return A pair whose first component represents the relevant source predicates and whose second * component represents the relevant successor state predicates. */ std::pair, std::set> computeRelevantPredicates(std::vector const& assignments) const; /*! * Determines the relevant predicates for source as well as successor states. * * @return A pair whose first component represents the relevant source predicates and whose second * component represents the relevant successor state predicates. */ std::pair, std::vector>> computeRelevantPredicates() const; /*! * Checks whether the relevant predicates changed. * * @param newRelevantPredicates The new relevant predicates. */ bool relevantPredicatesChanged(std::pair, std::vector>> const& newRelevantPredicates) const; /*! * Declares variables for the predicates that were added. * * @param oldRelevantPredicates The old relevant predicates (and the corresponding variables). * @return Pairs of variable and predicate (indices) for the new relevant predicates. */ std::vector> declareNewVariables(std::vector> const& oldRelevantPredicates, std::set const& newRelevantPredicates); /*! * Takes the new relevant predicates and creates the appropriate variables and assertions for the ones * that are currently missing. * * @param newRelevantPredicates The new relevant predicates. */ void addMissingPredicates(std::pair, std::vector>> const& newRelevantPredicates); /*! * Translates the given model to a source state DD. * * @param model The model to translate. * @return The source state encoded as a DD. */ storm::dd::Bdd getSourceStateBdd(storm::solver::SmtSolver::ModelReference const& model) const; /*! * Translates the given model to a distribution over successor states. * * @param model The model to translate. * @return The source state encoded as a DD. */ storm::dd::Bdd getDistributionBdd(storm::solver::SmtSolver::ModelReference const& model) const; /*! * Recomputes the cached BDD. This needs to be triggered if any relevant predicates change. */ void recomputeCachedBdd(); /*! * Computes the missing source state identities. * * @return A BDD that represents the source state identities for predicates that are irrelevant for the * source states. */ storm::dd::Bdd computeMissingSourceStateIdentities() const; // An SMT responsible for this abstract command. std::unique_ptr smtSolver; // The expression-related information. AbstractionExpressionInformation const& expressionInformation; // The DD-related information. AbstractionDdInformation const& ddInformation; // The concrete command this abstract command refers to. std::reference_wrapper command; // The partition of variables and expressions. VariablePartition variablePartition; // The currently relevant source/successor predicates and the corresponding variables. std::pair>, std::vector>>> relevantPredicatesAndVariables; // The most recent result of a call to computeDd. If nothing has changed regarding the relevant // predicates, this result may be reused. std::pair, uint_fast64_t> cachedDd; // All relevant decision variables over which to perform AllSat. std::vector decisionVariables; }; } } } #endif /* STORM_STORAGE_PRISM_MENU_GAMES_ABSTRACTCOMMAND_H_ */