Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
TopologicalLinearEquationSolver.h
Go to the documentation of this file.
1#pragma once
2
4
9
10namespace storm {
11
12class Environment;
13
14namespace solver {
15
16template<typename ValueType>
18 public:
22
23 virtual void setMatrix(storm::storage::SparseMatrix<ValueType> const& A) override;
24 virtual void setMatrix(storm::storage::SparseMatrix<ValueType>&& A) override;
25
27 virtual LinearEquationSolverRequirements getRequirements(Environment const& env) const override;
28
29 virtual void clearCache() const override;
30
31 protected:
32 virtual bool internalSolveEquations(storm::Environment const& env, std::vector<ValueType>& x, std::vector<ValueType> const& b) const override;
33
34 private:
35 virtual uint64_t getMatrixRowCount() const override;
36 virtual uint64_t getMatrixColumnCount() const override;
37
38 storm::Environment getEnvironmentForUnderlyingSolver(storm::Environment const& env, bool adaptPrecision = false) const;
39
40 // Creates an SCC decomposition and sorts the SCCs according to a topological sort.
41 void createSortedSccDecomposition(bool needLongestChainSize) const;
42
43 // Reports what the SCC-wise solve established about the solution: the values themselves if every SCC was
44 // solved exactly, otherwise the precision they were solved with, if every SCC was solved that accurately.
45 void trySetSolutionBounds(Environment const& env, std::vector<ValueType> const& x, bool allSccsExact, bool allSccsPrecise) const;
46
47 // Retrieves whether the SCC solver met the precision the given environment asked of it for the given values it
48 // just produced. Adding up the errors of the SCCs relies on that.
49 bool lastSccMetPrecision(Environment const& sccSolverEnvironment, std::vector<ValueType> const& sccValues) const;
50
51 // Solves the SCC with the given index
52 // ... for the case that the SCC is trivial
53 bool solveTrivialScc(uint64_t const& sccState, std::vector<ValueType>& globalX, std::vector<ValueType> const& globalB) const;
54 // ... for the case that there is just one large SCC
55 bool solveFullyConnectedEquationSystem(storm::Environment const& sccSolverEnvironment, std::vector<ValueType>& x, std::vector<ValueType> const& b) const;
56 // ... for the remaining cases (1 < scc.size() < x.size())
57 bool solveScc(storm::Environment const& sccSolverEnvironment, storm::storage::StronglyConnectedComponent const& scc,
58 storm::storage::BitVector const& sccAsBitVector, std::vector<ValueType>& globalX, std::vector<ValueType> const& globalB,
59 std::optional<storm::storage::BitVector> const& globalRelevantValues, bool& metPrecision) const;
60
61 // If the solver takes posession of the matrix, we store the moved matrix in this member, so it gets deleted
62 // when the solver is destructed.
63 std::unique_ptr<storm::storage::SparseMatrix<ValueType>> localA;
64
65 // A pointer to the original sparse matrix given to this solver. If the solver takes posession of the matrix
66 // the pointer refers to localA.
68
69 // cached auxiliary data
70 mutable std::unique_ptr<storm::storage::StronglyConnectedComponentDecomposition<ValueType>> sortedSccDecomposition;
71 mutable boost::optional<uint64_t> longestSccChainSize;
72 mutable std::unique_ptr<storm::solver::LinearEquationSolver<ValueType>> sccSolver;
73 // Builds the submatrices of all SCCs (reuses its internal lookup table between SCCs)
74 mutable std::unique_ptr<storm::storage::SubmatrixBuilder<ValueType>> sccSubmatrixBuilder;
75};
76
77template<typename ValueType>
79 public:
81
82 virtual std::unique_ptr<storm::solver::LinearEquationSolver<ValueType>> create(Environment const& env) const override;
83
84 virtual std::unique_ptr<LinearEquationSolverFactory<ValueType>> clone() const override;
85};
86} // namespace solver
87} // namespace storm
virtual std::unique_ptr< LinearEquationSolverFactory< ValueType > > clone() const override
Creates a copy of this factory.
virtual std::unique_ptr< storm::solver::LinearEquationSolver< ValueType > > create(Environment const &env) const override
Creates an equation solver with the current settings, but without a matrix.
virtual LinearEquationSolverProblemFormat getEquationProblemFormat(storm::Environment const &env) const override
Retrieves the format in which this solver expects to solve equations.
virtual bool internalSolveEquations(storm::Environment const &env, std::vector< ValueType > &x, std::vector< ValueType > const &b) const override
virtual void setMatrix(storm::storage::SparseMatrix< ValueType > const &A) override
virtual LinearEquationSolverRequirements getRequirements(Environment const &env) const override
Retrieves the requirements of the solver under the current settings.
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
A class that holds a possibly non-square matrix in the compressed row storage format.
This class represents a strongly connected component, i.e., a set of states such that every state can...