Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
TopologicalEquationSolverSettings.cpp
Go to the documentation of this file.
2
4
11
13
17
18namespace storm {
19namespace settings {
20namespace modules {
21
22const std::string TopologicalEquationSolverSettings::moduleName = "topological";
23const std::string TopologicalEquationSolverSettings::underlyingEquationSolverOptionName = "eqsolver";
24const std::string TopologicalEquationSolverSettings::underlyingMinMaxMethodOptionName = "minmax";
25const std::string TopologicalEquationSolverSettings::extendRelevantValuesOptionName = "relevant-values";
26
27#ifdef STORM_HAVE_GMM
28const std::string defaultEqSolverString = "gmm++";
29#else
30const std::string defaultEqSolverString = "eigen";
31#endif
32
34 std::vector<std::string> linearEquationSolver = {"gmm++", "native", "eigen", "elimination"};
35 this->addOption(storm::settings::OptionBuilder(moduleName, underlyingEquationSolverOptionName, true,
36 "Sets which solver is considered for solving the underlying equation systems.")
37 .setIsAdvanced()
38 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the used solver.")
39 .addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(linearEquationSolver))
40 .setDefaultValueString(defaultEqSolverString)
41 .build())
42 .build());
43 std::vector<std::string> minMaxSolvingTechniques = {"vi", "value-iteration",
44 "pi", "policy-iteration",
45 "lp", "linear-programming",
46 "rs", "ratsearch",
47 "ii", "interval-iteration",
48 "svi", "sound-value-iteration",
49 "ovi", "optimistic-value-iteration",
50 "gvi", "guessing-value-iteration",
51 "vi-to-pi", "vi-to-lp"};
52 this->addOption(storm::settings::OptionBuilder(moduleName, underlyingMinMaxMethodOptionName, true,
53 "Sets which minmax method is considered for solving the underlying minmax equation systems.")
54 .setIsAdvanced()
55 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the used min max method.")
56 .addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(minMaxSolvingTechniques))
57 .setDefaultValueString("value-iteration")
58 .build())
59 .build());
60
61 this->addOption(
62 storm::settings::OptionBuilder(moduleName, extendRelevantValuesOptionName, true, "Sets whether relevant values are set to the underlying solver.")
63 .setIsAdvanced()
64 .build());
65}
66
68 return this->getOption(underlyingEquationSolverOptionName).getHasOptionBeenSet();
69}
70
72 return !this->getOption(underlyingEquationSolverOptionName).getHasOptionBeenSet() ||
73 this->getOption(underlyingEquationSolverOptionName).getArgumentByName("name").wasSetFromDefaultValue();
74}
75
77 std::string equationSolverName = this->getOption(underlyingEquationSolverOptionName).getArgumentByName("name").getValueAsString();
78 if (equationSolverName == "gmm++") {
79 return storm::solver::EquationSolverType::Gmmxx;
80 } else if (equationSolverName == "native") {
81 return storm::solver::EquationSolverType::Native;
82 } else if (equationSolverName == "eigen") {
83 return storm::solver::EquationSolverType::Eigen;
84 } else if (equationSolverName == "elimination") {
85 return storm::solver::EquationSolverType::Elimination;
86 }
87 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown underlying equation solver '" << equationSolverName << "'.");
88}
89
91 return this->getOption(underlyingMinMaxMethodOptionName).getHasOptionBeenSet();
92}
93
95 return !this->getOption(underlyingMinMaxMethodOptionName).getHasOptionBeenSet() ||
96 this->getOption(underlyingMinMaxMethodOptionName).getArgumentByName("name").wasSetFromDefaultValue();
97}
98
100 std::string minMaxEquationSolvingTechnique = this->getOption(underlyingMinMaxMethodOptionName).getArgumentByName("name").getValueAsString();
101 if (minMaxEquationSolvingTechnique == "value-iteration" || minMaxEquationSolvingTechnique == "vi") {
102 return storm::solver::MinMaxMethod::ValueIteration;
103 } else if (minMaxEquationSolvingTechnique == "policy-iteration" || minMaxEquationSolvingTechnique == "pi") {
104 return storm::solver::MinMaxMethod::PolicyIteration;
105 } else if (minMaxEquationSolvingTechnique == "linear-programming" || minMaxEquationSolvingTechnique == "lp") {
106 return storm::solver::MinMaxMethod::LinearProgramming;
107 } else if (minMaxEquationSolvingTechnique == "ratsearch" || minMaxEquationSolvingTechnique == "rs") {
108 return storm::solver::MinMaxMethod::RationalSearch;
109 } else if (minMaxEquationSolvingTechnique == "interval-iteration" || minMaxEquationSolvingTechnique == "ii") {
110 return storm::solver::MinMaxMethod::IntervalIteration;
111 } else if (minMaxEquationSolvingTechnique == "sound-value-iteration" || minMaxEquationSolvingTechnique == "svi") {
112 return storm::solver::MinMaxMethod::SoundValueIteration;
113 } else if (minMaxEquationSolvingTechnique == "optimistic-value-iteration" || minMaxEquationSolvingTechnique == "ovi") {
114 return storm::solver::MinMaxMethod::OptimisticValueIteration;
115 } else if (minMaxEquationSolvingTechnique == "guessing-value-iteration" || minMaxEquationSolvingTechnique == "gvi") {
116 return storm::solver::MinMaxMethod::GuessingValueIteration;
117 } else if (minMaxEquationSolvingTechnique == "vi-to-pi") {
118 return storm::solver::MinMaxMethod::ViToPi;
119 } else if (minMaxEquationSolvingTechnique == "vi-to-lp") {
120 return storm::solver::MinMaxMethod::ViToLp;
121 }
122
123 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown underlying equation solver '" << minMaxEquationSolvingTechnique << "'.");
124}
125
127 return this->getOption(extendRelevantValuesOptionName).getHasOptionBeenSet();
128}
129
131 if (this->isUnderlyingEquationSolverTypeSet() && getUnderlyingEquationSolverType() == storm::solver::EquationSolverType::Topological) {
132 STORM_LOG_WARN("Underlying solver type of the topological solver can not be the topological solver.");
133 return false;
134 }
135 if (this->isUnderlyingMinMaxMethodSet() && getUnderlyingMinMaxMethod() == storm::solver::MinMaxMethod::Topological) {
136 STORM_LOG_WARN("Underlying minmax method of the topological solver can not be topological.");
137 return false;
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 bool wasSetFromDefaultValue() const =0
static ArgumentBuilder createStringArgument(std::string const &name, std::string const &description)
Creates a string argument with the given parameters.
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
ModuleSettings(std::string const &moduleName)
Constructs a new settings object.
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.
bool check() const override
Checks whether the settings are consistent.
bool isUnderlyingMinMaxMethodSet() const
Retrieves whether the underlying equation solver type has been set.
bool isUnderlyingMinMaxMethodSetFromDefaultValue() const
Retrieves whether the underlying minmax method is set from its default value.
TopologicalEquationSolverSettings()
Creates a new set of native equation solver settings.
bool isUnderlyingEquationSolverTypeSetFromDefaultValue() const
Retrieves whether the underlying equation solver type is set from its default value.
bool isExtendRelevantValues() const
If true, the relevant states of each SCC are computed and passed to the underlying equation solver.
storm::solver::EquationSolverType getUnderlyingEquationSolverType() const
Retrieves the method that is to be used for solving systems of linear equations.
storm::solver::MinMaxMethod getUnderlyingMinMaxMethod() const
Retrieves the method that is to be used for solving systems of linear equations.
bool isUnderlyingEquationSolverTypeSet() const
Retrieves whether the underlying equation solver type has been set.
#define STORM_LOG_WARN(message)
Definition logging.h:28
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:28