Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
FeasibilitySettings.cpp
Go to the documentation of this file.
2
5
10
12
13const std::string FeasibilitySettings::moduleName = "feasibility";
14const std::string methodOptionName = "method";
15const std::string directionOptionName = "direction";
16const std::string guaranteeOptionName = "guarantee";
17
19 std::vector<std::string> methodChoice = {"gd", "pla"};
20 this->addOption(OptionBuilder(moduleName, methodOptionName, true, "Which method to use")
21 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("method", "The method")
23 .build())
24 .build());
25 std::vector<std::string> directions = {"min", "max"};
26 this->addOption(OptionBuilder(moduleName, directionOptionName, false, "Which direction do the parameters optimize")
27 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("direction", "The optimization direction")
29 .build())
30 .build());
31 std::vector<std::string> precisiontype = {"rel", "abs"};
32 this->addOption(OptionBuilder(moduleName, guaranteeOptionName, false, "Specifies the guarantee that must be provided. If not set, no guarantee is given.")
33 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("precision", "The desired precision")
36 .build())
37 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("precisiontype", "The desired precision type.")
39 .makeOptional()
41 .build())
42 .build());
43}
44
46 auto str = this->getOption(methodOptionName).getArgumentByName("method").getValueAsString();
47 if (str == "gd") {
49 } else {
50 STORM_LOG_ASSERT(str == "pla", "Only remaining option is PLA");
52 }
53}
54
56 return this->getOption(directionOptionName).getHasOptionBeenSet();
57}
58
60 auto str = this->getOption(directionOptionName).getArgumentByName("direction").getValueAsString();
61 if (str == "min") {
62 return storm::solver::OptimizationDirection::Minimize;
63 } else {
64 STORM_LOG_ASSERT(str == "max", "If not min, then max.");
65 return storm::solver::OptimizationDirection::Maximize;
66 }
67}
68
70 return this->getOption(guaranteeOptionName).getHasOptionBeenSet();
71};
72
75 if (!generalSettings.isPrecisionSet() && generalSettings.isSoundSet()) {
76 double prec = this->getOption(guaranteeOptionName).getArgumentByName("precision").getValueAsDouble() / 10;
77 generalSettings.setPrecision(std::to_string(prec));
78 STORM_LOG_WARN("Reset precision for solver to " << prec << " this is sufficient for guarantee value precision of " << (prec) * 10 << '\n');
79 }
80 return this->getOption(guaranteeOptionName).getArgumentByName("precision").getValueAsDouble();
81}
82
84 auto str = this->getOption(guaranteeOptionName).getArgumentByName("precisiontype").getValueAsString();
85 if (str == "abs") {
86 return true;
87 } else {
88 STORM_LOG_ASSERT(str == "rel", "If not abs, then rel.");
89 return false;
90 }
91}
92
93} // namespace storm::settings::modules
virtual std::string getValueAsString() const =0
Retrieves the value of this argument as a string.
virtual double getValueAsDouble() const =0
Retrieves the value of this argument as a double.
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< std::string > > createMultipleChoiceValidator(std::vector< std::string > const &choices)
static std::shared_ptr< ArgumentValidator< double > > createDoubleRangeValidatorIncluding(double lowerBound, double upperBound)
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
storm::pars::FeasibilityMethod getFeasibilityMethod() const
Get the feasibility method to be used.
double getOptimalValueGuarantee() const
Retrieves the precision for the extremal value.
bool isParameterDirectionSet() const
Retrieves whether an extremal value is to be computed.
bool hasOptimalValueGuaranteeBeenSet() const
Retrieves whether an optimal value guarantee has been provided.
storm::solver::OptimizationDirection getParameterDirection() const
Retrieves whether to minimize or maximize over parameters.
bool isAbsolutePrecisionSet() const
Should the guarantee for the optimal value be absolute or 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_WARN(message)
Definition logging.h:30
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
const std::string directionOptionName
const std::string guaranteeOptionName
SettingsType const & getModule()
Get module.