Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
TopologicalLinearEquationSolver.h
Go to the documentation of this file.
1#pragma once
2
4
8
9namespace storm {
10
11class Environment;
12
13namespace solver {
14
15template<typename ValueType>
17 public:
21
22 virtual void setMatrix(storm::storage::SparseMatrix<ValueType> const& A) override;
23 virtual void setMatrix(storm::storage::SparseMatrix<ValueType>&& A) override;
24
26 virtual LinearEquationSolverRequirements getRequirements(Environment const& env) const override;
27
28 virtual void clearCache() const override;
29
30 protected:
31 virtual bool internalSolveEquations(storm::Environment const& env, std::vector<ValueType>& x, std::vector<ValueType> const& b) const override;
32
33 private:
34 virtual uint64_t getMatrixRowCount() const override;
35 virtual uint64_t getMatrixColumnCount() const override;
36
37 storm::Environment getEnvironmentForUnderlyingSolver(storm::Environment const& env, bool adaptPrecision = false) const;
38
39 // Creates an SCC decomposition and sorts the SCCs according to a topological sort.
40 void createSortedSccDecomposition(bool needLongestChainSize) const;
41
42 // Solves the SCC with the given index
43 // ... for the case that the SCC is trivial
44 bool solveTrivialScc(uint64_t const& sccState, std::vector<ValueType>& globalX, std::vector<ValueType> const& globalB) const;
45 // ... for the case that there is just one large SCC
46 bool solveFullyConnectedEquationSystem(storm::Environment const& sccSolverEnvironment, std::vector<ValueType>& x, std::vector<ValueType> const& b) const;
47 // ... for the remaining cases (1 < scc.size() < x.size())
48 bool solveScc(storm::Environment const& sccSolverEnvironment, storm::storage::BitVector const& scc, std::vector<ValueType>& globalX,
49 std::vector<ValueType> const& globalB, std::optional<storm::storage::BitVector> const& globalRelevantValues) const;
50
51 // If the solver takes posession of the matrix, we store the moved matrix in this member, so it gets deleted
52 // when the solver is destructed.
53 std::unique_ptr<storm::storage::SparseMatrix<ValueType>> localA;
54
55 // A pointer to the original sparse matrix given to this solver. If the solver takes posession of the matrix
56 // the pointer refers to localA.
58
59 // cached auxiliary data
60 mutable std::unique_ptr<storm::storage::StronglyConnectedComponentDecomposition<ValueType>> sortedSccDecomposition;
61 mutable boost::optional<uint64_t> longestSccChainSize;
62 mutable std::unique_ptr<storm::solver::LinearEquationSolver<ValueType>> sccSolver;
63};
64
65template<typename ValueType>
67 public:
69
70 virtual std::unique_ptr<storm::solver::LinearEquationSolver<ValueType>> create(Environment const& env) const override;
71
72 virtual std::unique_ptr<LinearEquationSolverFactory<ValueType>> clone() const override;
73};
74} // namespace solver
75} // namespace storm
An interface that represents an abstract linear equation solver.
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:18
A class that holds a possibly non-square matrix in the compressed row storage format.
LabParser.cpp.
Definition cli.cpp:18