#pragma once #include "storm/solver/StandardMinMaxLinearEquationSolver.h" namespace storm { class Environment; namespace solver { /*! * This solver can be used on equation systems that are known to be acyclic. * It is optimized for solving many instances of the equation system with the same underlying matrix. */ template class AcyclicMinMaxLinearEquationSolver : public StandardMinMaxLinearEquationSolver { public: AcyclicMinMaxLinearEquationSolver(); AcyclicMinMaxLinearEquationSolver(storm::storage::SparseMatrix const& A); AcyclicMinMaxLinearEquationSolver(storm::storage::SparseMatrix&& A); virtual ~AcyclicMinMaxLinearEquationSolver() { } virtual void clearCache() const override; virtual MinMaxLinearEquationSolverRequirements getRequirements(Environment const& env, boost::optional const& direction = boost::none, bool const& hasInitialScheduler = false) const override ; protected: virtual bool internalSolveEquations(storm::Environment const& env, OptimizationDirection d, std::vector& x, std::vector const& b) const override; private: // cached multiplier either with original matrix or ordered matrix mutable std::unique_ptr> multiplier; // cached matrix for the multiplier (only if different from original matrix) mutable boost::optional> orderedMatrix; // cached row group ordering (only if not identity) mutable boost::optional> rowGroupOrdering; // A.rowGroupCount() entries // can be used if the entries in 'b' need to be reordered mutable boost::optional> auxiliaryRowVector; // A.rowCount() entries // contains factors applied to scale the entries of the 'b' vector mutable std::vector> bFactors; }; } }