Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
LinearEquationSolver.h
Go to the documentation of this file.
1#ifndef STORM_SOLVER_LINEAREQUATIONSOLVER_H_
2#define STORM_SOLVER_LINEAREQUATIONSOLVER_H_
3
4#include <memory>
5#include <vector>
6
12
14
16
17namespace storm {
18
19class Environment;
20
21namespace solver {
22
26template<class ValueType>
28 public:
30
32 // Intentionally left empty.
33 }
34
37
49 bool solveEquations(Environment const& env, std::vector<ValueType>& x, std::vector<ValueType> const& b) const;
50
56
62
67 void setCachingEnabled(bool value) const;
68
72 bool isCachingEnabled() const;
73
74 /*
75 * Clears the currently cached data that has been stored during previous calls of the solver.
76 */
77 virtual void clearCache() const;
78
79 protected:
80 virtual bool internalSolveEquations(Environment const& env, std::vector<ValueType>& x, std::vector<ValueType> const& b) const = 0;
81
82 // auxiliary storage. If set, this vector has getMatrixRowCount() entries.
83 mutable std::unique_ptr<std::vector<ValueType>> cachedRowVector;
84
85 private:
89 virtual uint64_t getMatrixRowCount() const = 0;
90
94 virtual uint64_t getMatrixColumnCount() const = 0;
95
97 mutable bool cachingEnabled;
98
101};
102
103enum class EquationSolverType;
104
105template<typename ValueType>
107 public:
108 virtual ~LinearEquationSolverFactory() = default;
109
116 std::unique_ptr<LinearEquationSolver<ValueType>> create(Environment const& env, storm::storage::SparseMatrix<ValueType> const& matrix) const;
117
125 std::unique_ptr<LinearEquationSolver<ValueType>> create(Environment const& env, storm::storage::SparseMatrix<ValueType>&& matrix) const;
126
130 virtual std::unique_ptr<LinearEquationSolver<ValueType>> create(Environment const& env) const = 0;
131
135 virtual std::unique_ptr<LinearEquationSolverFactory<ValueType>> clone() const = 0;
136
141
147};
148
149template<typename ValueType>
151 public:
153
155
156 virtual std::unique_ptr<LinearEquationSolver<ValueType>> create(Environment const& env) const override;
157
158 virtual std::unique_ptr<LinearEquationSolverFactory<ValueType>> clone() const override;
159};
160
161} // namespace solver
162} // namespace storm
163
164#endif /* STORM_SOLVER_LINEAREQUATIONSOLVER_H_ */
virtual std::unique_ptr< LinearEquationSolver< ValueType > > create(Environment const &env) const override
Creates an equation solver with the current settings, but without a matrix.
virtual std::unique_ptr< LinearEquationSolverFactory< ValueType > > clone() const override
Creates a copy of this factory.
std::unique_ptr< LinearEquationSolver< ValueType > > create(Environment const &env, storm::storage::SparseMatrix< ValueType > const &matrix) const
Creates a new linear equation solver instance with the given matrix.
LinearEquationSolverRequirements getRequirements(Environment const &env) const
Retrieves the requirements of the solver if it was created with the current settings.
virtual std::unique_ptr< LinearEquationSolverFactory< ValueType > > clone() const =0
Creates a copy of this factory.
virtual std::unique_ptr< LinearEquationSolver< ValueType > > create(Environment const &env) const =0
Creates an equation solver with the current settings, but without a matrix.
virtual LinearEquationSolverProblemFormat getEquationProblemFormat(Environment const &env) const
Retrieves the problem format that the solver expects if it was created with the current settings.
An interface that represents an abstract linear equation solver.
virtual void setMatrix(storm::storage::SparseMatrix< ValueType > const &A)=0
virtual void setMatrix(storm::storage::SparseMatrix< ValueType > &&A)=0
void setCachingEnabled(bool value) const
Sets whether some of the generated data during solver calls should be cached.
bool solveEquations(Environment const &env, std::vector< ValueType > &x, std::vector< ValueType > const &b) const
If the solver expects the equation system format, it solves Ax = b.
bool isCachingEnabled() const
Retrieves whether some of the generated data during solver calls should be cached.
virtual LinearEquationSolverProblemFormat getEquationProblemFormat(Environment const &env) const =0
Retrieves the format in which this solver expects to solve equations.
virtual bool internalSolveEquations(Environment const &env, std::vector< ValueType > &x, std::vector< ValueType > const &b) const =0
std::unique_ptr< std::vector< ValueType > > cachedRowVector
virtual LinearEquationSolverRequirements getRequirements(Environment const &env) const
Retrieves the requirements of the solver under the current settings.
A class that holds a possibly non-square matrix in the compressed row storage format.
LabParser.cpp.
Definition cli.cpp:18