20template<
typename ValueType>
25template<
typename ValueType>
36template<
typename ValueType>
41template<
typename ValueType>
43 if (cachingEnabled && !value) {
47 cachingEnabled = value;
50template<
typename ValueType>
52 return cachingEnabled;
55template<
typename ValueType>
60template<
typename ValueType>
63 std::unique_ptr<LinearEquationSolver<ValueType>>
solver = this->
create(env);
68template<
typename ValueType>
71 std::unique_ptr<LinearEquationSolver<ValueType>>
solver = this->
create(env);
72 solver->setMatrix(std::move(matrix));
76template<
typename ValueType>
78 return this->
create(env)->getEquationProblemFormat(env);
81template<
typename ValueType>
83 return this->
create(env)->getRequirements(env);
86template<
typename ValueType>
96 if (type != EquationSolverType::Eigen && type != EquationSolverType::Topological && type != EquationSolverType::Acyclic &&
98 STORM_LOG_INFO(
"Selecting '" +
toString(EquationSolverType::Eigen) +
"' as the linear equation solver since the previously selected one ("
99 <<
toString(type) <<
") does not support exact computations.");
100 type = EquationSolverType::Eigen;
103 std::unique_ptr<LinearEquationSolver<storm::RationalNumber>> result;
105 case EquationSolverType::Native:
106 result = std::make_unique<NativeLinearEquationSolver<storm::RationalNumber>>();
108 case EquationSolverType::Eigen:
109 result = std::make_unique<EigenLinearEquationSolver<storm::RationalNumber>>();
111 case EquationSolverType::Elimination:
112 result = std::make_unique<EliminationLinearEquationSolver<storm::RationalNumber>>();
114 case EquationSolverType::Topological:
115 result = std::make_unique<TopologicalLinearEquationSolver<storm::RationalNumber>>();
117 case EquationSolverType::Acyclic:
118 result = std::make_unique<AcyclicLinearEquationSolver<storm::RationalNumber>>();
121 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
134 if (type == EquationSolverType::Gmmxx || type == EquationSolverType::Native) {
136 STORM_LOG_INFO(
"Selecting '" +
toString(EquationSolverType::Eigen) +
"' as the linear equation solver since the previously selected one ("
137 <<
toString(type) <<
") does not support parametric computations.");
140 STORM_LOG_WARN(
"The selected linear equation solver (" <<
toString(type) <<
") does not support parametric computations. Falling back to "
141 <<
toString(EquationSolverType::Eigen) <<
".");
143 type = EquationSolverType::Eigen;
146 std::unique_ptr<LinearEquationSolver<storm::RationalFunction>> result;
148 case EquationSolverType::Eigen:
149 result = std::make_unique<EigenLinearEquationSolver<storm::RationalFunction>>();
151 case EquationSolverType::Elimination:
152 result = std::make_unique<EliminationLinearEquationSolver<storm::RationalFunction>>();
154 case EquationSolverType::Topological:
155 result = std::make_unique<TopologicalLinearEquationSolver<storm::RationalFunction>>();
157 case EquationSolverType::Acyclic:
158 result = std::make_unique<AcyclicLinearEquationSolver<storm::RationalFunction>>();
161 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
168template<
typename ValueType>
173 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We have not implemented interval-based linear equation solvers.");
177 if (env.
solver().
isForceExact() && type != EquationSolverType::Native && type != EquationSolverType::Eigen && type != EquationSolverType::Elimination &&
178 type != EquationSolverType::Topological && type != EquationSolverType::Acyclic) {
180 type = EquationSolverType::Eigen;
183 "' as the linear equation solver to guarantee exact results. If you want to override this, please explicitly specify a different solver.");
185 STORM_LOG_WARN(
"The selected solver does not yield exact results.");
187 }
else if (env.
solver().
isForceSoundness() && type != EquationSolverType::Native && type != EquationSolverType::Eigen &&
188 type != EquationSolverType::Elimination && type != EquationSolverType::Topological && type != EquationSolverType::Acyclic) {
190 type = EquationSolverType::Native;
193 "' as the linear equation solver to guarantee sound results. If you want to override this, please explicitly specify a different solver.");
195 STORM_LOG_WARN(
"The selected solver does not yield sound results.");
199 std::unique_ptr<LinearEquationSolver<ValueType>> result;
201 case EquationSolverType::Gmmxx:
202 result = std::make_unique<GmmxxLinearEquationSolver<ValueType>>();
204 case EquationSolverType::Native:
205 result = std::make_unique<NativeLinearEquationSolver<ValueType>>();
207 case EquationSolverType::Eigen:
208 result = std::make_unique<EigenLinearEquationSolver<ValueType>>();
210 case EquationSolverType::Elimination:
211 result = std::make_unique<EliminationLinearEquationSolver<ValueType>>();
213 case EquationSolverType::Topological:
214 result = std::make_unique<TopologicalLinearEquationSolver<ValueType>>();
216 case EquationSolverType::Acyclic:
217 result = std::make_unique<AcyclicLinearEquationSolver<ValueType>>();
220 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
227template<
typename ValueType>
229 return std::make_unique<GeneralLinearEquationSolverFactory<ValueType>>(*this);
SolverEnvironment & solver()
storm::solver::EquationSolverType const & getLinearEquationSolverType() const
bool isLinearEquationSolverTypeSetFromDefaultValue() const
uint64_t getShowProgressDelay() const
bool isForceExact() const
bool isForceSoundness() const
bool isVerboseSet() const
void clearSolutionBounds() const
void finalizeSolutionBounds(std::vector< ValueType > const &x) const
virtual std::unique_ptr< LinearEquationSolver< ValueType > > create(Environment const &env) const override
Creates an equation solver with the current settings, but without a matrix.
GeneralLinearEquationSolverFactory()
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 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.
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.
virtual void clearCache() const
bool isCachingEnabled() const
Retrieves whether some of the generated data during solver calls should be cached.
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.
#define STORM_LOG_INFO(message)
#define STORM_LOG_WARN(message)
#define STORM_LOG_THROW(cond, exception, message)
LinearEquationSolverProblemFormat
std::string toString(GurobiSolverMethod const &method)
Yields a string representation of the GurobiSolverMethod.
constexpr bool IsIntervalType
Helper to check if a type is an interval.