21template<
typename ValueType>
26template<
typename ValueType>
28 return this->internalSolveEquations(env, x, b);
31template<
typename ValueType>
36template<
typename ValueType>
38 if (cachingEnabled && !value) {
42 cachingEnabled = value;
45template<
typename ValueType>
47 return cachingEnabled;
50template<
typename ValueType>
52 cachedRowVector.reset();
55template<
typename ValueType>
58 std::unique_ptr<LinearEquationSolver<ValueType>> solver = this->create(env);
59 solver->setMatrix(matrix);
63template<
typename ValueType>
66 std::unique_ptr<LinearEquationSolver<ValueType>> solver = this->create(env);
67 solver->setMatrix(std::move(matrix));
71template<
typename ValueType>
73 return this->create(env)->getEquationProblemFormat(env);
76template<
typename ValueType>
78 return this->create(env)->getRequirements(env);
81template<
typename ValueType>
91 if (type != EquationSolverType::Eigen && type != EquationSolverType::Topological && type != EquationSolverType::Acyclic &&
93 STORM_LOG_INFO(
"Selecting '" +
toString(EquationSolverType::Eigen) +
"' as the linear equation solver since the previously selected one ("
94 <<
toString(type) <<
") does not support exact computations.");
95 type = EquationSolverType::Eigen;
99 case EquationSolverType::Native:
100 return std::make_unique<NativeLinearEquationSolver<storm::RationalNumber>>();
101 case EquationSolverType::Eigen:
102 return std::make_unique<EigenLinearEquationSolver<storm::RationalNumber>>();
103 case EquationSolverType::Elimination:
104 return std::make_unique<EliminationLinearEquationSolver<storm::RationalNumber>>();
105 case EquationSolverType::Topological:
106 return std::make_unique<TopologicalLinearEquationSolver<storm::RationalNumber>>();
107 case EquationSolverType::Acyclic:
108 return std::make_unique<AcyclicLinearEquationSolver<storm::RationalNumber>>();
110 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
121 if (type == EquationSolverType::Gmmxx || type == EquationSolverType::Native) {
123 STORM_LOG_INFO(
"Selecting '" +
toString(EquationSolverType::Eigen) +
"' as the linear equation solver since the previously selected one ("
124 <<
toString(type) <<
") does not support parametric computations.");
127 STORM_LOG_WARN(
"The selected linear equation solver (" <<
toString(type) <<
") does not support parametric computations. Falling back to "
128 <<
toString(EquationSolverType::Eigen) <<
".");
130 type = EquationSolverType::Eigen;
134 case EquationSolverType::Eigen:
135 return std::make_unique<EigenLinearEquationSolver<storm::RationalFunction>>();
136 case EquationSolverType::Elimination:
137 return std::make_unique<EliminationLinearEquationSolver<storm::RationalFunction>>();
138 case EquationSolverType::Topological:
139 return std::make_unique<TopologicalLinearEquationSolver<storm::RationalFunction>>();
140 case EquationSolverType::Acyclic:
141 return std::make_unique<AcyclicLinearEquationSolver<storm::RationalFunction>>();
143 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
148template<
typename ValueType>
152 if constexpr (std::is_same_v<ValueType, storm::Interval>) {
153 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We have not implemented interval-based linear equation solvers");
157 if (env.
solver().
isForceExact() && type != EquationSolverType::Native && type != EquationSolverType::Eigen && type != EquationSolverType::Elimination &&
158 type != EquationSolverType::Topological && type != EquationSolverType::Acyclic) {
160 type = EquationSolverType::Eigen;
163 "' as the linear equation solver to guarantee exact results. If you want to override this, please explicitly specify a different solver.");
165 STORM_LOG_WARN(
"The selected solver does not yield exact results.");
167 }
else if (env.
solver().
isForceSoundness() && type != EquationSolverType::Native && type != EquationSolverType::Eigen &&
168 type != EquationSolverType::Elimination && type != EquationSolverType::Topological && type != EquationSolverType::Acyclic) {
170 type = EquationSolverType::Native;
173 "' as the linear equation solver to guarantee sound results. If you want to override this, please explicitly specify a different solver.");
175 STORM_LOG_WARN(
"The selected solver does not yield sound results.");
180 case EquationSolverType::Gmmxx:
181 return std::make_unique<GmmxxLinearEquationSolver<ValueType>>();
182 case EquationSolverType::Native:
183 return std::make_unique<NativeLinearEquationSolver<ValueType>>();
184 case EquationSolverType::Eigen:
185 return std::make_unique<EigenLinearEquationSolver<ValueType>>();
186 case EquationSolverType::Elimination:
187 return std::make_unique<EliminationLinearEquationSolver<ValueType>>();
188 case EquationSolverType::Topological:
189 return std::make_unique<TopologicalLinearEquationSolver<ValueType>>();
190 case EquationSolverType::Acyclic:
191 return std::make_unique<AcyclicLinearEquationSolver<ValueType>>();
193 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
198template<
typename ValueType>
200 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.