Storm
A Modern Probabilistic Model Checker
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EigenEquationSolverSettings.cpp
Go to the documentation of this file.
2
7
11
14
15namespace storm {
16namespace settings {
17namespace modules {
18
19const std::string EigenEquationSolverSettings::moduleName = "eigen";
20const std::string EigenEquationSolverSettings::techniqueOptionName = "method";
21const std::string EigenEquationSolverSettings::preconditionOptionName = "precond";
22const std::string EigenEquationSolverSettings::maximalIterationsOptionName = "maxiter";
23const std::string EigenEquationSolverSettings::maximalIterationsOptionShortName = "i";
24const std::string EigenEquationSolverSettings::precisionOptionName = "precision";
25const std::string EigenEquationSolverSettings::restartOptionName = "restart";
26
28 std::vector<std::string> methods = {"sparselu", "bicgstab", "dgmres", "gmres"};
29 this->addOption(storm::settings::OptionBuilder(moduleName, techniqueOptionName, true,
30 "The method to be used for solving linear equation systems with the eigen solver.")
31 .setIsAdvanced()
32 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the method to use.")
34 .setDefaultValueString("gmres")
35 .build())
36 .build());
37
38 // Register available preconditioners.
39 std::vector<std::string> preconditioner = {"ilu", "diagonal", "none"};
40 this->addOption(
41 storm::settings::OptionBuilder(moduleName, preconditionOptionName, true, "The preconditioning technique used for solving linear equation systems.")
42 .setIsAdvanced()
43 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the preconditioning method.")
46 .build())
47 .build());
48
49 this->addOption(
50 storm::settings::OptionBuilder(moduleName, restartOptionName, true, "The number of iteration until restarted methods are actually restarted.")
51 .setIsAdvanced()
52 .addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The number of iterations.")
54 .build())
55 .build());
56
57 this->addOption(storm::settings::OptionBuilder(moduleName, maximalIterationsOptionName, false,
58 "The maximal number of iterations to perform before iterative solving is aborted.")
59 .setShortName(maximalIterationsOptionShortName)
60 .setIsAdvanced()
61 .addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The maximal iteration count.").build())
62 .build());
63
64 this->addOption(storm::settings::OptionBuilder(moduleName, precisionOptionName, false, "The precision used for detecting convergence of iterative methods.")
65 .setIsAdvanced()
66 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision to achieve.")
69 .build())
70 .build());
71}
72
74 return this->getOption(techniqueOptionName).getHasOptionBeenSet();
75}
76
78 return !this->getOption(techniqueOptionName).getHasOptionBeenSet() ||
79 this->getOption(techniqueOptionName).getArgumentByName("name").wasSetFromDefaultValue();
80}
81
82storm::solver::EigenLinearEquationSolverMethod EigenEquationSolverSettings::getLinearEquationSystemMethod() const {
83 std::string linearEquationSystemTechniqueAsString = this->getOption(techniqueOptionName).getArgumentByName("name").getValueAsString();
84 if (linearEquationSystemTechniqueAsString == "sparselu") {
85 return storm::solver::EigenLinearEquationSolverMethod::SparseLU;
86 } else if (linearEquationSystemTechniqueAsString == "bicgstab") {
87 return storm::solver::EigenLinearEquationSolverMethod::Bicgstab;
88 } else if (linearEquationSystemTechniqueAsString == "dgmres") {
89 return storm::solver::EigenLinearEquationSolverMethod::DGmres;
90 } else if (linearEquationSystemTechniqueAsString == "gmres") {
91 return storm::solver::EigenLinearEquationSolverMethod::Gmres;
92 }
93 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException,
94 "Unknown solution technique '" << linearEquationSystemTechniqueAsString << "' selected.");
95}
96
98 return this->getOption(preconditionOptionName).getHasOptionBeenSet();
99}
100
101storm::solver::EigenLinearEquationSolverPreconditioner EigenEquationSolverSettings::getPreconditioningMethod() const {
102 std::string PreconditioningMethodAsString = this->getOption(preconditionOptionName).getArgumentByName("name").getValueAsString();
103 if (PreconditioningMethodAsString == "ilu") {
104 return storm::solver::EigenLinearEquationSolverPreconditioner::Ilu;
105 } else if (PreconditioningMethodAsString == "diagonal") {
106 return storm::solver::EigenLinearEquationSolverPreconditioner::Diagonal;
107 } else if (PreconditioningMethodAsString == "none") {
108 return storm::solver::EigenLinearEquationSolverPreconditioner::None;
109 }
110 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException,
111 "Unknown preconditioning technique '" << PreconditioningMethodAsString << "' selected.");
112}
113
115 return this->getOption(restartOptionName).getHasOptionBeenSet();
116}
117
121
123 return this->getOption(maximalIterationsOptionName).getHasOptionBeenSet();
124}
125
129
131 return this->getOption(precisionOptionName).getHasOptionBeenSet();
132}
133
135 return this->getOption(precisionOptionName).getArgumentByName("value").getValueAsDouble();
136}
137
139 // This list does not include the precision, because this option is shared with other modules.
141
143 storm::settings::getModule<storm::settings::modules::CoreSettings>().getEquationSolver() == storm::solver::EquationSolverType::Eigen || !optionsSet,
144 "Eigen is not selected as the preferred equation solver, so setting options for eigen might have no effect.");
145
146 return true;
147}
148
149std::ostream& operator<<(std::ostream& out, EigenEquationSolverSettings::LinearEquationMethod const& method) {
150 switch (method) {
152 out << "bicgstab";
153 break;
155 out << "gmres";
156 break;
158 out << "dgmres";
159 break;
161 out << "sparselu";
162 break;
163 }
164 return out;
165}
166
167} // namespace modules
168} // namespace settings
169} // namespace storm
virtual std::string getValueAsString() const =0
Retrieves the value of this argument as a string.
virtual uint_fast64_t getValueAsUnsignedInteger() const =0
Retrieves the value of this argument as an unsigned integer.
virtual double getValueAsDouble() const =0
Retrieves the value of this argument as a double.
virtual bool wasSetFromDefaultValue() const =0
static ArgumentBuilder createUnsignedIntegerArgument(std::string const &name, std::string const &description)
Creates an unsigned integer argument with the given parameters.
static ArgumentBuilder createDoubleArgument(std::string const &name, std::string const &description)
Creates a double argument with the given parameters.
static ArgumentBuilder createStringArgument(std::string const &name, std::string const &description)
Creates a string argument with the given parameters.
static std::shared_ptr< ArgumentValidator< double > > createDoubleRangeValidatorExcluding(double lowerBound, double upperBound)
static std::shared_ptr< ArgumentValidator< std::string > > createMultipleChoiceValidator(std::vector< std::string > const &choices)
This class provides the interface to create an option...
ArgumentBase const & getArgumentByName(std::string const &argumentName) const
Returns a reference to the argument with the specified long name.
Definition Option.cpp:79
bool getHasOptionBeenSet() const
Retrieves whether the option has been set.
Definition Option.cpp:125
bool isLinearEquationSystemMethodSetFromDefault() const
Retrieves whether the linear equation system method has been set from the default value.
bool isPreconditioningMethodSet() const
Retrieves whether the preconditioning method has been set.
bool check() const override
Checks whether the settings are consistent.
storm::solver::EigenLinearEquationSolverMethod getLinearEquationSystemMethod() const
Retrieves the method that is to be used for solving systems of linear equations.
bool isPrecisionSet() const
Retrieves whether the precision has been set.
bool isLinearEquationSystemMethodSet() const
Retrieves whether the linear equation system method has been set.
uint_fast64_t getRestartIterationCount() const
Retrieves the number of iterations after which restarted methods are to be restarted.
bool isRestartIterationCountSet() const
Retrieves whether the restart iteration count has been set.
uint_fast64_t getMaximalIterationCount() const
Retrieves the maximal number of iterations to perform until giving up on converging.
double getPrecision() const
Retrieves the precision that is used for detecting convergence.
storm::solver::EigenLinearEquationSolverPreconditioner getPreconditioningMethod() const
Retrieves the method that is to be used for preconditioning solving systems of linear equations.
bool isMaximalIterationCountSet() const
Retrieves whether the maximal iteration count has been set.
This is the base class of the settings for a particular module.
void addOption(std::shared_ptr< Option > const &option)
Adds and registers the given option.
Option & getOption(std::string const &longName)
Retrieves the option with the given long name.
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:38
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
std::ostream & operator<<(std::ostream &out, EigenEquationSolverSettings::LinearEquationMethod const &method)
SettingsType const & getModule()
Get module.
LabParser.cpp.
Definition cli.cpp:18