Storm 1.10.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
LinearEquationSolver.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <memory>
5#include <vector>
6
13
14namespace storm {
15
16class Environment;
17
18namespace solver {
19
23template<class ValueType>
25 public:
27
29 // Intentionally left empty.
30 }
31
34
46 bool solveEquations(Environment const& env, std::vector<ValueType>& x, std::vector<ValueType> const& b) const;
47
53
59
64 void setCachingEnabled(bool value) const;
65
69 bool isCachingEnabled() const;
70
71 /*
72 * Clears the currently cached data that has been stored during previous calls of the solver.
73 */
74 virtual void clearCache() const;
75
76 protected:
77 virtual bool internalSolveEquations(Environment const& env, std::vector<ValueType>& x, std::vector<ValueType> const& b) const = 0;
78
79 // auxiliary storage. If set, this vector has getMatrixRowCount() entries.
80 mutable std::unique_ptr<std::vector<ValueType>> cachedRowVector;
81
82 private:
86 virtual uint64_t getMatrixRowCount() const = 0;
87
91 virtual uint64_t getMatrixColumnCount() const = 0;
92
94 mutable bool cachingEnabled;
95};
96
97enum class EquationSolverType;
98
99template<typename ValueType>
101 public:
102 virtual ~LinearEquationSolverFactory() = default;
103
110 std::unique_ptr<LinearEquationSolver<ValueType>> create(Environment const& env, storm::storage::SparseMatrix<ValueType> const& matrix) const;
111
119 std::unique_ptr<LinearEquationSolver<ValueType>> create(Environment const& env, storm::storage::SparseMatrix<ValueType>&& matrix) const;
120
124 virtual std::unique_ptr<LinearEquationSolver<ValueType>> create(Environment const& env) const = 0;
125
129 virtual std::unique_ptr<LinearEquationSolverFactory<ValueType>> clone() const = 0;
130
135
141};
142
143template<typename ValueType>
145 public:
147
149
150 virtual std::unique_ptr<LinearEquationSolver<ValueType>> create(Environment const& env) const override;
151
152 virtual std::unique_ptr<LinearEquationSolverFactory<ValueType>> clone() const override;
153};
154
155} // namespace solver
156} // namespace storm
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