#pragma once #include "storm/storage/SparseMatrix.h" #include "storm/solver/LinearEquationSolver.h" #include "storm/solver/MinMaxLinearEquationSolver.h" #include "storm/solver/Multiplier.h" namespace storm { class Environment; namespace storage { template class Scheduler; } namespace modelchecker { namespace helper { namespace internal { template class GameViHelper { public: GameViHelper(storm::storage::SparseMatrix const& transitionMatrix, storm::storage::BitVector statesOfCoalition); void prepareSolversAndMultipliers(const Environment& env); /*! * Perform value iteration until convergence */ void performValueIteration(Environment const& env, std::vector& x, std::vector b, storm::solver::OptimizationDirection const dir); /*! * Perform value iteration until upper bound */ void performValueIterationUpperBound(Environment const& env, std::vector& x, storm::solver::OptimizationDirection const dir, uint64_t upperBound, std::vector& constrainedChoiceValues); /*! * Fills the result vector to the original size with zeros for all states except the relevantStates */ void fillResultVector(std::vector& result, storm::storage::BitVector relevantStates); /*! * Fills the result vector to the original size with ones for being psiStates, zeros for being not phiStates */ void fillResultVector(std::vector& result, storm::storage::BitVector relevantStates, storm::storage::BitVector psiStates); /*! * Fills the choice values vector to the original size with zeros for ~psiState choices. */ void fillChoiceValuesVector(std::vector& choiceValues, storm::storage::BitVector psiStates, std::vector::index_type> rowGroupIndices); /*! * Sets whether an optimal scheduler shall be constructed during the computation */ void setProduceScheduler(bool value); /*! * @return whether an optimal scheduler shall be constructed during the computation */ bool isProduceSchedulerSet() const; storm::storage::Scheduler extractScheduler() const; void getChoiceValues(Environment const& env, std::vector const& x, std::vector& choiceValues); private: /*! * Performs one iteration step for value iteration */ void performIterationStep(Environment const& env, storm::solver::OptimizationDirection const dir, std::vector* choices = nullptr); /*! * Performs one iteration step for value iteration with upper bound */ void performIterationStepUpperBound(Environment const& env, storm::solver::OptimizationDirection const dir, std::vector* choices = nullptr); /*! * Checks whether the curently computed value achieves the desired precision */ bool checkConvergence(ValueType precision) const; std::vector& xNew(); std::vector const& xNew() const; std::vector& xOld(); std::vector const& xOld() const; bool _x1IsCurrent; /*! * @pre before calling this, a computation call should have been performed during which scheduler production was enabled. * @return the produced scheduler of the most recent call. */ std::vector const& getProducedOptimalChoices() const; /*! * @pre before calling this, a computation call should have been performed during which scheduler production was enabled. * @return the produced scheduler of the most recent call. */ std::vector& getProducedOptimalChoices(); storm::storage::SparseMatrix _transitionMatrix; storm::storage::BitVector _statesOfCoalition; std::vector _x, _x1, _x2, _b; std::unique_ptr> _multiplier; bool _produceScheduler = false; boost::optional> _producedOptimalChoices; }; } } } }