20template<
typename ValueType>
25template<
typename ValueType>
27 return this->internalSolveEquations(env, x, b);
30template<
typename ValueType>
35template<
typename ValueType>
37 if (cachingEnabled && !value) {
41 cachingEnabled = value;
44template<
typename ValueType>
46 return cachingEnabled;
49template<
typename ValueType>
51 cachedRowVector.reset();
54template<
typename ValueType>
57 std::unique_ptr<LinearEquationSolver<ValueType>> solver = this->create(env);
58 solver->setMatrix(matrix);
62template<
typename ValueType>
65 std::unique_ptr<LinearEquationSolver<ValueType>> solver = this->create(env);
66 solver->setMatrix(std::move(matrix));
70template<
typename ValueType>
72 return this->create(env)->getEquationProblemFormat(env);
75template<
typename ValueType>
77 return this->create(env)->getRequirements(env);
80template<
typename ValueType>
90 if (type != EquationSolverType::Eigen && type != EquationSolverType::Topological && type != EquationSolverType::Acyclic &&
92 STORM_LOG_INFO(
"Selecting '" +
toString(EquationSolverType::Eigen) +
"' as the linear equation solver since the previously selected one ("
93 <<
toString(type) <<
") does not support exact computations.");
94 type = EquationSolverType::Eigen;
98 case EquationSolverType::Native:
99 return std::make_unique<NativeLinearEquationSolver<storm::RationalNumber>>();
100 case EquationSolverType::Eigen:
101 return std::make_unique<EigenLinearEquationSolver<storm::RationalNumber>>();
102 case EquationSolverType::Elimination:
103 return std::make_unique<EliminationLinearEquationSolver<storm::RationalNumber>>();
104 case EquationSolverType::Topological:
105 return std::make_unique<TopologicalLinearEquationSolver<storm::RationalNumber>>();
106 case EquationSolverType::Acyclic:
107 return std::make_unique<AcyclicLinearEquationSolver<storm::RationalNumber>>();
109 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
120 if (type == EquationSolverType::Gmmxx || type == EquationSolverType::Native) {
122 STORM_LOG_INFO(
"Selecting '" +
toString(EquationSolverType::Eigen) +
"' as the linear equation solver since the previously selected one ("
123 <<
toString(type) <<
") does not support parametric computations.");
126 STORM_LOG_WARN(
"The selected linear equation solver (" <<
toString(type) <<
") does not support parametric computations. Falling back to "
127 <<
toString(EquationSolverType::Eigen) <<
".");
129 type = EquationSolverType::Eigen;
133 case EquationSolverType::Eigen:
134 return std::make_unique<EigenLinearEquationSolver<storm::RationalFunction>>();
135 case EquationSolverType::Elimination:
136 return std::make_unique<EliminationLinearEquationSolver<storm::RationalFunction>>();
137 case EquationSolverType::Topological:
138 return std::make_unique<TopologicalLinearEquationSolver<storm::RationalFunction>>();
139 case EquationSolverType::Acyclic:
140 return std::make_unique<AcyclicLinearEquationSolver<storm::RationalFunction>>();
142 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
147template<
typename ValueType>
151 if constexpr (std::is_same_v<ValueType, storm::Interval>) {
152 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We have not implemented interval-based linear equation solvers");
156 if (env.
solver().
isForceExact() && type != EquationSolverType::Native && type != EquationSolverType::Eigen && type != EquationSolverType::Elimination &&
157 type != EquationSolverType::Topological && type != EquationSolverType::Acyclic) {
159 type = EquationSolverType::Eigen;
162 "' as the linear equation solver to guarantee exact results. If you want to override this, please explicitly specify a different solver.");
164 STORM_LOG_WARN(
"The selected solver does not yield exact results.");
166 }
else if (env.
solver().
isForceSoundness() && type != EquationSolverType::Native && type != EquationSolverType::Eigen &&
167 type != EquationSolverType::Elimination && type != EquationSolverType::Topological && type != EquationSolverType::Acyclic) {
169 type = EquationSolverType::Native;
172 "' as the linear equation solver to guarantee sound results. If you want to override this, please explicitly specify a different solver.");
174 STORM_LOG_WARN(
"The selected solver does not yield sound results.");
179 case EquationSolverType::Gmmxx:
180 return std::make_unique<GmmxxLinearEquationSolver<ValueType>>();
181 case EquationSolverType::Native:
182 return std::make_unique<NativeLinearEquationSolver<ValueType>>();
183 case EquationSolverType::Eigen:
184 return std::make_unique<EigenLinearEquationSolver<ValueType>>();
185 case EquationSolverType::Elimination:
186 return std::make_unique<EliminationLinearEquationSolver<ValueType>>();
187 case EquationSolverType::Topological:
188 return std::make_unique<TopologicalLinearEquationSolver<ValueType>>();
189 case EquationSolverType::Acyclic:
190 return std::make_unique<AcyclicLinearEquationSolver<ValueType>>();
192 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
197template<
typename ValueType>
199 return std::make_unique<GeneralLinearEquationSolverFactory<ValueType>>(*this);
SolverEnvironment & solver()
storm::solver::EquationSolverType const & getLinearEquationSolverType() const
bool isLinearEquationSolverTypeSetFromDefaultValue() const
bool isForceExact() const
bool isForceSoundness() 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 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.