Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
LongRunAverageSolverSettings.cpp
Go to the documentation of this file.
2
6
9
10namespace storm {
11namespace settings {
12namespace modules {
13
14const std::string LongRunAverageSolverSettings::moduleName = "lra";
15const std::string LongRunAverageSolverSettings::detLraMethodOptionName = "detmethod";
16const std::string LongRunAverageSolverSettings::nondetLraMethodOptionName = "nondetmethod";
17const std::string LongRunAverageSolverSettings::maximalIterationsOptionName = "maxiter";
18const std::string LongRunAverageSolverSettings::maximalIterationsOptionShortName = "i";
19const std::string LongRunAverageSolverSettings::precisionOptionName = "precision";
20const std::string LongRunAverageSolverSettings::absoluteOptionName = "absolute";
21const std::string LongRunAverageSolverSettings::aperiodicFactorOptionName = "aperiodicfactor";
22
24 std::vector<std::string> detLraMethods = {"gb", "gain-bias-equations", "distr", "lra-distribution-equations", "vi", "value-iteration"};
25 this->addOption(storm::settings::OptionBuilder(moduleName, detLraMethodOptionName, true,
26 "Sets which method is preferred for computing long run averages on deterministic models.")
27 .setIsAdvanced()
28 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of a long run average computation method.")
31 .build())
32 .build());
33
34 std::vector<std::string> nondetLraMethods = {"vi", "value-iteration", "linear-programming", "lp"};
35 this->addOption(storm::settings::OptionBuilder(moduleName, nondetLraMethodOptionName, true,
36 "Sets which method is preferred for computing long run averages on models with nondeterminism.")
37 .setIsAdvanced()
38 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of a long run average computation method.")
41 .build())
42 .build());
43
44 this->addOption(storm::settings::OptionBuilder(moduleName, maximalIterationsOptionName, false,
45 "The maximal number of iterations to perform before iterative solving is aborted.")
46 .setShortName(maximalIterationsOptionShortName)
47 .setIsAdvanced()
48 .addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The maximal iteration count.").build())
49 .build());
50
51 this->addOption(storm::settings::OptionBuilder(moduleName, precisionOptionName, false, "The precision used for detecting convergence of iterative methods.")
52 .setIsAdvanced()
53 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision to achieve.")
56 .build())
57 .build());
58
59 this->addOption(storm::settings::OptionBuilder(moduleName, absoluteOptionName, false,
60 "Sets whether the relative or the absolute error is considered for detecting convergence.")
61 .setIsAdvanced()
62 .build());
63
64 this->addOption(storm::settings::OptionBuilder(moduleName, aperiodicFactorOptionName, true,
65 "If required by the selected method (e.g. vi), this factor controls how the system is made aperiodic")
66 .setIsAdvanced()
67 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The factor.")
70 .build())
71 .build());
72}
73
74storm::solver::LraMethod LongRunAverageSolverSettings::getDetLraMethod() const {
75 std::string lraMethodString = this->getOption(detLraMethodOptionName).getArgumentByName("name").getValueAsString();
76 if (lraMethodString == "gain-bias-equations" || lraMethodString == "gb") {
77 return storm::solver::LraMethod::GainBiasEquations;
78 }
79 if (lraMethodString == "lra-distribution-equations" || lraMethodString == "distr") {
80 return storm::solver::LraMethod::LraDistributionEquations;
81 }
82 if (lraMethodString == "value-iteration" || lraMethodString == "vi") {
83 return storm::solver::LraMethod::ValueIteration;
84 }
85 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException,
86 "Unknown lra solving technique for deterministic models:'" << lraMethodString << "'.");
87}
88
90 return !this->getOption(detLraMethodOptionName).getArgumentByName("name").getHasBeenSet() ||
91 this->getOption(detLraMethodOptionName).getArgumentByName("name").wasSetFromDefaultValue();
92}
93
94storm::solver::LraMethod LongRunAverageSolverSettings::getNondetLraMethod() const {
95 std::string lraMethodString = this->getOption(nondetLraMethodOptionName).getArgumentByName("name").getValueAsString();
96 if (lraMethodString == "value-iteration" || lraMethodString == "vi") {
97 return storm::solver::LraMethod::ValueIteration;
98 } else if (lraMethodString == "linear-programming" || lraMethodString == "lp") {
99 return storm::solver::LraMethod::LinearProgramming;
100 }
101 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException,
102 "Unknown lra solving technique for nondeterministic models:'" << lraMethodString << "'.");
103}
104
106 return !this->getOption(nondetLraMethodOptionName).getArgumentByName("name").getHasBeenSet() ||
107 this->getOption(nondetLraMethodOptionName).getArgumentByName("name").wasSetFromDefaultValue();
108}
109
111 return this->getOption(maximalIterationsOptionName).getHasOptionBeenSet();
112}
113
117
119 return this->getOption(precisionOptionName).getHasOptionBeenSet();
120}
121
123 return this->getOption(precisionOptionName).getArgumentByName("value").getValueAsDouble();
124}
125
127 return this->getOption(absoluteOptionName).getHasOptionBeenSet();
128}
129
131 return this->getOption(aperiodicFactorOptionName).getArgumentByName("value").getValueAsDouble();
132}
133
134} // namespace modules
135} // namespace settings
136} // 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 bool getHasBeenSet() const
Retrieves whether the argument has been set.
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 isPrecisionSet() const
Retrieves whether the precision has been set.
storm::solver::LraMethod getDetLraMethod() const
Retrieves the selected long run average method for deterministic models.
double getAperiodicFactor() const
Retrieves a factor that describes how the system is made aperiodic (if necessary by the method)
bool isDetLraMethodSetFromDefaultValue() const
Retrieves whether the LraMethod for deterministic models was set from a default value.
bool isMaximalIterationCountSet() const
Retrieves whether a maximal iteration count for iterative methods was 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::LraMethod getNondetLraMethod() const
Retrieves the selected long run average method for nondeterministic models.
bool isNondetLraMethodSetFromDefaultValue() const
Retrieves whether the LraMethod for nondeterministic models was set from a default value.
bool isRelativePrecision() const
Retrieves whether the convergence criterion has been set to relative.
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_THROW(cond, exception, message)
Definition macros.h:30
SettingsType const & getModule()
Get module.
LabParser.cpp.
Definition cli.cpp:18