Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
GmmxxEquationSolverSettings.cpp
Go to the documentation of this file.
2
7
11
14
15namespace storm {
16namespace settings {
17namespace modules {
18
19const std::string GmmxxEquationSolverSettings::moduleName = "gmm++";
20const std::string GmmxxEquationSolverSettings::techniqueOptionName = "method";
21const std::string GmmxxEquationSolverSettings::preconditionOptionName = "precond";
22const std::string GmmxxEquationSolverSettings::restartOptionName = "restart";
23const std::string GmmxxEquationSolverSettings::maximalIterationsOptionName = "maxiter";
24const std::string GmmxxEquationSolverSettings::maximalIterationsOptionShortName = "i";
25const std::string GmmxxEquationSolverSettings::precisionOptionName = "precision";
26
28 std::vector<std::string> methods = {"bicgstab", "qmr", "gmres"};
29 this->addOption(storm::settings::OptionBuilder(moduleName, techniqueOptionName, true,
30 "The method to be used for solving linear equation systems with the gmm++ engine.")
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
77storm::solver::GmmxxLinearEquationSolverMethod GmmxxEquationSolverSettings::getLinearEquationSystemMethod() const {
78 std::string linearEquationSystemTechniqueAsString = this->getOption(techniqueOptionName).getArgumentByName("name").getValueAsString();
79 if (linearEquationSystemTechniqueAsString == "bicgstab") {
80 return storm::solver::GmmxxLinearEquationSolverMethod::Bicgstab;
81 } else if (linearEquationSystemTechniqueAsString == "qmr") {
82 return storm::solver::GmmxxLinearEquationSolverMethod::Qmr;
83 } else if (linearEquationSystemTechniqueAsString == "gmres") {
84 return storm::solver::GmmxxLinearEquationSolverMethod::Gmres;
85 }
86 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException,
87 "Unknown solution technique '" << linearEquationSystemTechniqueAsString << "' selected.");
88}
89
91 return this->getOption(preconditionOptionName).getHasOptionBeenSet();
92}
93
94storm::solver::GmmxxLinearEquationSolverPreconditioner GmmxxEquationSolverSettings::getPreconditioningMethod() const {
95 std::string preconditioningMethodAsString = this->getOption(preconditionOptionName).getArgumentByName("name").getValueAsString();
96 if (preconditioningMethodAsString == "ilu") {
97 return storm::solver::GmmxxLinearEquationSolverPreconditioner::Ilu;
98 } else if (preconditioningMethodAsString == "diagonal") {
99 return storm::solver::GmmxxLinearEquationSolverPreconditioner::Diagonal;
100 } else if (preconditioningMethodAsString == "none") {
101 return storm::solver::GmmxxLinearEquationSolverPreconditioner::None;
102 }
103 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException,
104 "Unknown preconditioning technique '" << preconditioningMethodAsString << "' selected.");
105}
106
108 return this->getOption(restartOptionName).getHasOptionBeenSet();
109}
110
114
116 return this->getOption(maximalIterationsOptionName).getHasOptionBeenSet();
117}
118
122
124 return this->getOption(precisionOptionName).getHasOptionBeenSet();
125}
126
128 return this->getOption(precisionOptionName).getArgumentByName("value").getValueAsDouble();
129}
130
132 // This list does not include the precision, because this option is shared with other modules.
134
136 storm::settings::getModule<storm::settings::modules::CoreSettings>().getEquationSolver() == storm::solver::EquationSolverType::Gmmxx || !optionsSet,
137 "gmm++ is not selected as the preferred equation solver, so setting options for gmm++ might have no effect.");
138
139 return true;
140}
141
142} // namespace modules
143} // namespace settings
144} // 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.
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 isMaximalIterationCountSet() const
Retrieves whether the maximal iteration count has been set.
bool isPreconditioningMethodSet() const
Retrieves whether the preconditioning method has been set.
uint_fast64_t getMaximalIterationCount() const
Retrieves the maximal number of iterations to perform until giving up on converging.
bool isLinearEquationSystemMethodSet() const
Retrieves whether the linear equation system method has been set.
double getPrecision() const
Retrieves the precision that is used for detecting convergence.
storm::solver::GmmxxLinearEquationSolverMethod getLinearEquationSystemMethod() const
Retrieves the method that is to be used for solving systems of linear equations.
bool isRestartIterationCountSet() const
Retrieves whether the restart iteration count has been set.
bool check() const override
Checks whether the settings are consistent.
bool isPrecisionSet() const
Retrieves whether the precision has been set.
uint_fast64_t getRestartIterationCount() const
Retrieves the number of iterations after which restarted methods are to be restarted.
storm::solver::GmmxxLinearEquationSolverPreconditioner getPreconditioningMethod() const
Retrieves the method that is to be used for preconditioning solving systems of linear equations.
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
SettingsType const & getModule()
Get module.
LabParser.cpp.
Definition cli.cpp:18