25template<
typename ValueType>
30template<
typename ValueType>
32 return this->internalSolveEquations(env, x, b);
35template<
typename ValueType>
40template<
typename ValueType>
42 if (cachingEnabled && !value) {
46 cachingEnabled = value;
49template<
typename ValueType>
51 return cachingEnabled;
54template<
typename ValueType>
56 cachedRowVector.reset();
59template<
typename ValueType>
62 std::unique_ptr<LinearEquationSolver<ValueType>> solver = this->create(env);
63 solver->setMatrix(matrix);
67template<
typename ValueType>
70 std::unique_ptr<LinearEquationSolver<ValueType>> solver = this->create(env);
71 solver->setMatrix(std::move(matrix));
75template<
typename ValueType>
77 return this->create(env)->getEquationProblemFormat(env);
80template<
typename ValueType>
82 return this->create(env)->getRequirements(env);
85template<
typename ValueType>
95 if (type != EquationSolverType::Eigen && type != EquationSolverType::Topological && type != EquationSolverType::Acyclic &&
97 STORM_LOG_INFO(
"Selecting '" +
toString(EquationSolverType::Eigen) +
"' as the linear equation solver since the previously selected one ("
98 <<
toString(type) <<
") does not support exact computations.");
99 type = EquationSolverType::Eigen;
103 case EquationSolverType::Native:
104 return std::make_unique<NativeLinearEquationSolver<storm::RationalNumber>>();
105 case EquationSolverType::Eigen:
106 return std::make_unique<EigenLinearEquationSolver<storm::RationalNumber>>();
107 case EquationSolverType::Elimination:
108 return std::make_unique<EliminationLinearEquationSolver<storm::RationalNumber>>();
109 case EquationSolverType::Topological:
110 return std::make_unique<TopologicalLinearEquationSolver<storm::RationalNumber>>();
111 case EquationSolverType::Acyclic:
112 return std::make_unique<AcyclicLinearEquationSolver<storm::RationalNumber>>();
114 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
125 if (type == EquationSolverType::Gmmxx || type == EquationSolverType::Native) {
127 STORM_LOG_INFO(
"Selecting '" +
toString(EquationSolverType::Eigen) +
"' as the linear equation solver since the previously selected one ("
128 <<
toString(type) <<
") does not support parametric computations.");
131 STORM_LOG_WARN(
"The selected linear equation solver (" <<
toString(type) <<
") does not support parametric computations. Falling back to "
132 <<
toString(EquationSolverType::Eigen) <<
".");
134 type = EquationSolverType::Eigen;
138 case EquationSolverType::Eigen:
139 return std::make_unique<EigenLinearEquationSolver<storm::RationalFunction>>();
140 case EquationSolverType::Elimination:
141 return std::make_unique<EliminationLinearEquationSolver<storm::RationalFunction>>();
142 case EquationSolverType::Topological:
143 return std::make_unique<TopologicalLinearEquationSolver<storm::RationalFunction>>();
144 case EquationSolverType::Acyclic:
145 return std::make_unique<AcyclicLinearEquationSolver<storm::RationalFunction>>();
147 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
152template<
typename ValueType>
156 if constexpr (std::is_same_v<ValueType, storm::Interval>) {
157 STORM_LOG_THROW(
false, storm::exceptions::NotImplementedException,
"We have not implemented interval-based linear equation solvers");
161 if (env.
solver().
isForceExact() && type != EquationSolverType::Native && type != EquationSolverType::Eigen && type != EquationSolverType::Elimination &&
162 type != EquationSolverType::Topological && type != EquationSolverType::Acyclic) {
164 type = EquationSolverType::Eigen;
167 "' as the linear equation solver to guarantee exact results. If you want to override this, please explicitly specify a different solver.");
169 STORM_LOG_WARN(
"The selected solver does not yield exact results.");
171 }
else if (env.
solver().
isForceSoundness() && type != EquationSolverType::Native && type != EquationSolverType::Eigen &&
172 type != EquationSolverType::Elimination && type != EquationSolverType::Topological && type != EquationSolverType::Acyclic) {
174 type = EquationSolverType::Native;
177 "' as the linear equation solver to guarantee sound results. If you want to override this, please explicitly specify a different solver.");
179 STORM_LOG_WARN(
"The selected solver does not yield sound results.");
184 case EquationSolverType::Gmmxx:
185 return std::make_unique<GmmxxLinearEquationSolver<ValueType>>();
186 case EquationSolverType::Native:
187 return std::make_unique<NativeLinearEquationSolver<ValueType>>();
188 case EquationSolverType::Eigen:
189 return std::make_unique<EigenLinearEquationSolver<ValueType>>();
190 case EquationSolverType::Elimination:
191 return std::make_unique<EliminationLinearEquationSolver<ValueType>>();
192 case EquationSolverType::Topological:
193 return std::make_unique<TopologicalLinearEquationSolver<ValueType>>();
194 case EquationSolverType::Acyclic:
195 return std::make_unique<AcyclicLinearEquationSolver<ValueType>>();
197 STORM_LOG_THROW(
false, storm::exceptions::InvalidEnvironmentException,
"Unknown solver type.");
202template<
typename ValueType>
204 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.