#pragma once #include #include "storm/solver/Multiplier.h" #include "storm/solver/LinearEquationSolver.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 AcyclicLinearEquationSolver : public LinearEquationSolver { public: AcyclicLinearEquationSolver(); AcyclicLinearEquationSolver(storm::storage::SparseMatrix const& A); AcyclicLinearEquationSolver(storm::storage::SparseMatrix&& A); virtual void setMatrix(storm::storage::SparseMatrix const& A) override; virtual void setMatrix(storm::storage::SparseMatrix&& A) override; virtual ~AcyclicLinearEquationSolver() { } virtual void clearCache() const override; virtual LinearEquationSolverProblemFormat getEquationProblemFormat(storm::Environment const& env) const override; virtual LinearEquationSolverRequirements getRequirements(Environment const& env) const override; protected: virtual bool internalSolveEquations(storm::Environment const& env, std::vector& x, std::vector const& b) const override; private: virtual uint64_t getMatrixRowCount() const override; virtual uint64_t getMatrixColumnCount() const override; // If the solver takes posession of the matrix, we store the moved matrix in this member, so it gets deleted // when the solver is destructed. std::unique_ptr> localA; // A pointer to the original sparse matrix given to this solver. If the solver takes posession of the matrix // the pointer refers to orderedMatrix. storm::storage::SparseMatrix const* A; // 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> rowOrdering; // 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; }; } }