Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
GameSolverSettings.cpp
Go to the documentation of this file.
2
6
9
10namespace storm {
11namespace settings {
12namespace modules {
13
14const std::string GameSolverSettings::moduleName = "game";
15const std::string GameSolverSettings::solvingMethodOptionName = "method";
16const std::string GameSolverSettings::maximalIterationsOptionName = "maxiter";
17const std::string GameSolverSettings::maximalIterationsOptionShortName = "i";
18const std::string GameSolverSettings::precisionOptionName = "precision";
19const std::string GameSolverSettings::absoluteOptionName = "absolute";
20
22 std::vector<std::string> gameSolvingTechniques = {"vi", "value-iteration", "pi", "policy-iteration"};
23 this->addOption(storm::settings::OptionBuilder(moduleName, solvingMethodOptionName, false, "Sets which game solving technique is preferred.")
24 .setIsAdvanced()
25 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of a game solving technique.")
26 .addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(gameSolvingTechniques))
27 .setDefaultValueString("vi")
28 .build())
29 .build());
30
31 this->addOption(storm::settings::OptionBuilder(moduleName, maximalIterationsOptionName, false,
32 "The maximal number of iterations to perform before iterative solving is aborted.")
33 .setShortName(maximalIterationsOptionShortName)
34 .setIsAdvanced()
35 .addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The maximal iteration count.").build())
36 .build());
37
38 this->addOption(storm::settings::OptionBuilder(moduleName, precisionOptionName, false, "The precision used for detecting convergence of iterative methods.")
39 .setIsAdvanced()
40 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision to achieve.")
41 .setDefaultValueDouble(1e-06)
43 .build())
44 .build());
45
46 this->addOption(storm::settings::OptionBuilder(moduleName, absoluteOptionName, false,
47 "Sets whether the relative or the absolute error is considered for detecting convergence.")
48 .setIsAdvanced()
49 .build());
50}
51
52storm::solver::GameMethod GameSolverSettings::getGameSolvingMethod() const {
53 std::string gameSolvingTechnique = this->getOption(solvingMethodOptionName).getArgumentByName("name").getValueAsString();
54 if (gameSolvingTechnique == "value-iteration" || gameSolvingTechnique == "vi") {
55 return storm::solver::GameMethod::ValueIteration;
56 } else if (gameSolvingTechnique == "policy-iteration" || gameSolvingTechnique == "pi") {
57 return storm::solver::GameMethod::PolicyIteration;
58 }
59 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown game solving technique '" << gameSolvingTechnique << "'.");
60}
61
63 return this->getOption(solvingMethodOptionName).getHasOptionBeenSet();
64}
65
67 return !this->getOption(solvingMethodOptionName).getArgumentByName("name").getHasBeenSet() ||
68 this->getOption(solvingMethodOptionName).getArgumentByName("name").wasSetFromDefaultValue();
69}
70
72 return this->getOption(maximalIterationsOptionName).getHasOptionBeenSet();
73}
74
76 return this->getOption(maximalIterationsOptionName).getArgumentByName("count").getValueAsUnsignedInteger();
77}
78
80 return this->getOption(precisionOptionName).getHasOptionBeenSet();
81}
82
84 return this->getOption(precisionOptionName).getArgumentByName("value").getValueAsDouble();
85}
86
88 return this->getOption(absoluteOptionName).getHasOptionBeenSet();
89}
90
95
96} // namespace modules
97} // namespace settings
98} // 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
ConvergenceCriterion getConvergenceCriterion() const
Retrieves the selected convergence criterion.
double getPrecision() const
Retrieves the precision that is used for detecting convergence.
bool isConvergenceCriterionSet() const
Retrieves whether the convergence criterion has been set.
bool isGameSolvingMethodSetFromDefaultValue() const
Retrieves whether the game solving technique has been set from the default value.
uint_fast64_t getMaximalIterationCount() const
Retrieves the maximal number of iterations to perform until giving up on converging.
bool isMaximalIterationCountSet() const
Retrieves whether the maximal iteration count has been set.
storm::solver::GameMethod getGameSolvingMethod() const
Retrieves the selected game solving technique.
bool isGameSolvingMethodSet() const
Retrieves whether a game solving technique has been set.
bool isPrecisionSet() const
Retrieves whether the precision 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_THROW(cond, exception, message)
Definition macros.h:30
LabParser.cpp.
Definition cli.cpp:18