#ifndef STORM_MODELCHECKER_MULTIOBJECTIVE_PCAA_SPARSEMAPCAAWEIGHTVECTORCHECKER_H_ #define STORM_MODELCHECKER_MULTIOBJECTIVE_PCAA_SPARSEMAPCAAWEIGHTVECTORCHECKER_H_ #include #include #include "storm/modelchecker/multiobjective/pcaa/StandardPcaaWeightVectorChecker.h" #include "storm/solver/LinearEquationSolver.h" #include "storm/solver/MinMaxLinearEquationSolver.h" #include "storm/utility/NumberTraits.h" namespace storm { namespace modelchecker { namespace multiobjective { /*! * Helper Class that takes preprocessed Pcaa data and a weight vector and ... * - computes the maximal expected reward w.r.t. the weighted sum of the rewards of the individual objectives * - extracts the scheduler that induces this maximum * - computes for each objective the value induced by this scheduler */ template class StandardMaPcaaWeightVectorChecker : public StandardPcaaWeightVectorChecker { public: typedef typename SparseMaModelType::ValueType ValueType; StandardMaPcaaWeightVectorChecker(SparseMultiObjectivePreprocessorResult const& preprocessorResult); virtual ~StandardMaPcaaWeightVectorChecker() = default; protected: virtual void initializeModelTypeSpecificData(SparseMaModelType const& model) override; private: /* * Stores (digitized) time bounds in descending order */ typedef std::map> TimeBoundMap; /* * Stores the ingredients of a sub model */ struct SubModel { storm::storage::BitVector states; // The states that are part of this sub model storm::storage::BitVector choices; // The choices that are part of this sub model storm::storage::SparseMatrix toMS; // Transitions to Markovian states storm::storage::SparseMatrix toPS; // Transitions to probabilistic states std::vector weightedRewardVector; std::vector> objectiveRewardVectors; std::vector weightedSolutionVector; std::vector> objectiveSolutionVectors; std::vector auxChoiceValues; //stores auxiliary values for every choice uint_fast64_t getNumberOfStates() const { return toMS.getRowGroupCount(); }; uint_fast64_t getNumberOfChoices() const { return toMS.getRowCount(); }; }; /* * Stores the data that is relevant to invoke the minMaxSolver and retrieve the result. */ struct MinMaxSolverData { std::unique_ptr> solver; std::vector b; }; struct LinEqSolverData { std::unique_ptr env; std::unique_ptr> factory; std::unique_ptr> solver; std::vector b; }; /*! * * @param weightVector the weight vector of the current check * @param weightedRewardVector the weighted rewards considering the unbounded objectives. Will be invalidated after calling this. */ virtual void boundedPhase(Environment const& env, std::vector const& weightVector, std::vector& weightedRewardVector) override; /*! * Retrieves the data for a submodel of the data->preprocessedModel * @param createMS if true, the submodel containing the Markovian states is created. * if false, the submodel containing the probabilistic states is created. */ SubModel createSubModel(bool createMS, std::vector const& weightedRewardVector) const; /*! * Retrieves the delta used for digitization */ template ::SupportsExponential, int>::type = 0> VT getDigitizationConstant(std::vector const& weightVector) const; template ::SupportsExponential, int>::type = 0> VT getDigitizationConstant(std::vector const& weightVector) const; /*! * Digitizes the given matrix and vectors w.r.t. the given digitization constant and the given rate vector. */ template ::SupportsExponential, int>::type = 0> void digitize(SubModel& subModel, VT const& digitizationConstant) const; template ::SupportsExponential, int>::type = 0> void digitize(SubModel& subModel, VT const& digitizationConstant) const; /* * Fills the given map with the digitized time bounds. Also sets the offsetsToUnderApproximation / offsetsToOverApproximation values * according to the digitization error */ template ::SupportsExponential, int>::type = 0> void digitizeTimeBounds(TimeBoundMap& upperTimeBounds, VT const& digitizationConstant); template ::SupportsExponential, int>::type = 0> void digitizeTimeBounds(TimeBoundMap& upperTimeBounds, VT const& digitizationConstant); /*! * Initializes the data for the MinMax solver */ std::unique_ptr initMinMaxSolver(Environment const& env, SubModel const& PS, std::vector const& weightVector) const; /*! * Initializes the data for the LinEq solver */ template ::SupportsExponential, int>::type = 0> std::unique_ptr initLinEqSolver(Environment const& env, SubModel const& PS) const; template ::SupportsExponential, int>::type = 0> std::unique_ptr initLinEqSolver(Environment const& env, SubModel const& PS) const; /* * Updates the reward vectors within the split model, * the reward vector of the reduced PStoPS model, and * objectives that are considered at the current time epoch. */ void updateDataToCurrentEpoch(SubModel& MS, SubModel& PS, MinMaxSolverData& minMax, storm::storage::BitVector& consideredObjectives, uint_fast64_t const& currentEpoch, std::vector const& weightVector, TimeBoundMap::iterator& upperTimeBoundIt, TimeBoundMap const& upperTimeBounds); /* * Performs a step for the probabilistic states, that is * * Compute an optimal scheduler for the weighted reward sum * * Compute the values for the individual objectives w.r.t. that scheduler * * The resulting values represent the rewards at probabilistic states that are obtained at the current time epoch. */ void performPSStep(Environment const& env, SubModel& PS, SubModel const& MS, MinMaxSolverData& minMax, LinEqSolverData& linEq, std::vector& optimalChoicesAtCurrentEpoch, storm::storage::BitVector const& consideredObjectives, std::vector const& weightVector) const; /* * Performs a step for the Markovian states, that is * * Compute values for the weighted reward sum as well as for the individual objectives * * The resulting values represent the rewards at Markovian states that are obtained after one (digitized) time unit has passed. */ void performMSStep(Environment const& env, SubModel& MS, SubModel const& PS, storm::storage::BitVector const& consideredObjectives, std::vector const& weightVector) const; // Data regarding the given Markov automaton storm::storage::BitVector markovianStates; std::vector exitRates; }; } } } #endif /* STORM_MODELCHECKER_MULTIOBJECTIVE_PCAA_SPARSEMAPCAAWEIGHTVECTORCHECKER_H_ */