Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
DerivativeSettings.cpp
Go to the documentation of this file.
2
9
12
13namespace storm {
14namespace settings {
15namespace modules {
16
17const std::string DerivativeSettings::moduleName = "derivative";
18const std::string DerivativeSettings::feasibleInstantiationSearch = "gradient-descent";
19const std::string DerivativeSettings::learningRate = "learning-rate";
20const std::string DerivativeSettings::miniBatchSize = "batch-size";
21const std::string DerivativeSettings::adamParams = "adam-params";
22const std::string DerivativeSettings::averageDecay = "average-decay";
23const std::string DerivativeSettings::squaredAverageDecay = "squared-average-decay";
24const std::string DerivativeSettings::terminationEpsilon = "termination-epsilon";
25const std::string DerivativeSettings::printJson = "print-json";
26const std::string DerivativeSettings::gradientDescentMethod = "descent-method";
27const std::string DerivativeSettings::omitInconsequentialParams = "omit-inconsequential-params";
28const std::string DerivativeSettings::constraintMethod = "constraint-method";
29
31 this->addOption(storm::settings::OptionBuilder(moduleName, feasibleInstantiationSearch, false,
32 "Search for a feasible instantiation (restart with new instantiation while not feasible)")
33 .build());
34 this->addOption(storm::settings::OptionBuilder(moduleName, learningRate, false, "Sets the learning rate of gradient descent")
35 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument(learningRate, "The learning rate of the gradient descent")
36 .setDefaultValueDouble(0.1)
37 .build())
38 .build());
39 this->addOption(
40 storm::settings::OptionBuilder(moduleName, miniBatchSize, false, "Sets the size of the minibatch")
41 .setIsAdvanced()
42 .addArgument(storm::settings::ArgumentBuilder::createIntegerArgument(miniBatchSize, "The size of the minibatch").setDefaultValueInteger(32).build())
43 .build());
44 this->addOption(storm::settings::OptionBuilder(moduleName, gradientDescentMethod, false, "Sets the gradient descent method")
45 .setIsAdvanced()
47 gradientDescentMethod,
48 "Gradient Descent method (adam, radam, rmsprop, plain, plain-sign, momentum, momentum-sign, nesterov, nesterov-sign)")
49 .setDefaultValueString("adam")
50 .build())
51 .build());
52 this->addOption(
54 moduleName, adamParams, false,
55 "Sets hyperparameters of the Gradient Descent algorithms, especially (R)ADAM's. If you're using RMSProp, averageDecay is RMSProp's decay.")
56 .setIsAdvanced()
57 .addArgument(
58 storm::settings::ArgumentBuilder::createDoubleArgument(averageDecay, "Decay of decaying step average").setDefaultValueDouble(0.9).build())
59 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument(squaredAverageDecay, "Decay of squared decaying step average")
60 .setDefaultValueDouble(0.999)
61 .build())
62 .build());
63 this->addOption(storm::settings::OptionBuilder(moduleName, printJson, false, "Print the run as json after finishing (slow!)").setIsAdvanced().build());
64 this->addOption(
65 storm::settings::OptionBuilder(moduleName, terminationEpsilon, false,
66 "The change in value that constitutes as a \"tiny change\", after a few of which the gradient descent will terminate")
67 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument(terminationEpsilon, "The epsilon").setDefaultValueDouble(1e-6).build())
68 .build());
69 this->addOption(
70 storm::settings::OptionBuilder(moduleName, omitInconsequentialParams, false,
71 "Parameters that are removed in minimization because they have no effect on the rational function are normally set to "
72 "0.5 in the final instantiation. If this flag is set, they will be omitted from the final instantiation entirely.")
73 .setIsAdvanced()
74 .build());
75 this->addOption(storm::settings::OptionBuilder(moduleName, constraintMethod, false, "Constraint Method")
76 .setIsAdvanced()
77 .addArgument(storm::settings::ArgumentBuilder::createStringArgument(constraintMethod, "Method for dealing with constraints")
78 .setDefaultValueString("project-gradient")
79 .build())
80 .build());
81}
82
84 return this->getOption(feasibleInstantiationSearch).getHasOptionBeenSet();
85}
86
88 return this->getOption(learningRate).getArgumentByName(learningRate).getValueAsDouble();
89}
91 return this->getOption(miniBatchSize).getArgumentByName(miniBatchSize).getValueAsInteger();
92}
94 return this->getOption(adamParams).getArgumentByName(averageDecay).getValueAsDouble();
95}
97 return this->getOption(adamParams).getArgumentByName(squaredAverageDecay).getValueAsDouble();
98}
99
101 return this->getOption(printJson).getHasOptionBeenSet();
102}
103
105 return this->getOption(terminationEpsilon).getArgumentByName(terminationEpsilon).getValueAsDouble();
106}
107
108boost::optional<derivative::GradientDescentMethod> DerivativeSettings::getGradientDescentMethod() const {
109 return methodFromString(this->getOption(gradientDescentMethod).getArgumentByName(gradientDescentMethod).getValueAsString());
110}
111
113 return this->getOption(gradientDescentMethod).getArgumentByName(gradientDescentMethod).getValueAsString();
114}
115
117 return this->getOption(omitInconsequentialParams).getHasOptionBeenSet();
118}
119
120boost::optional<derivative::GradientDescentConstraintMethod> DerivativeSettings::getConstraintMethod() const {
121 return constraintMethodFromString(this->getOption(constraintMethod).getArgumentByName(constraintMethod).getValueAsString());
122}
123
125 return this->getOption(constraintMethod).getArgumentByName(constraintMethod).getValueAsString();
126}
127
128boost::optional<derivative::GradientDescentMethod> DerivativeSettings::methodFromString(const std::string &str) const {
130 if (str == "adam") {
132 } else if (str == "radam") {
134 } else if (str == "rmsprop") {
136 } else if (str == "plain") {
138 } else if (str == "plain-sign") {
140 } else if (str == "momentum") {
142 } else if (str == "momentum-sign") {
144 } else if (str == "nesterov") {
146 } else if (str == "nesterov-sign") {
148 } else {
149 return boost::none;
150 }
151 return method;
152}
153
154boost::optional<derivative::GradientDescentConstraintMethod> DerivativeSettings::constraintMethodFromString(const std::string &str) const {
156 if (str == "project-gradient") {
158 } else if (str == "project") {
160 } else if (str == "penalty-quadratic") {
162 } else if (str == "barrier-logarithmic") {
164 } else if (str == "barrier-infinity") {
166 } else if (str == "logistic-sigmoid") {
168 } else {
169 return boost::none;
170 }
171 return method;
172}
173
174} // namespace modules
175} // namespace settings
176} // namespace storm
virtual std::string getValueAsString() const =0
Retrieves the value of this argument as a string.
virtual int_fast64_t getValueAsInteger() const =0
Retrieves the value of this argument as an integer.
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 createIntegerArgument(std::string const &name, std::string const &description)
Creates an integer argument with the given parameters.
static ArgumentBuilder createStringArgument(std::string const &name, std::string const &description)
Creates a string argument with the given parameters.
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
double getSquaredAverageDecay() const
Retrieves the decay of the squared decaying step average of the ADAM algorithm.
std::string getGradientDescentMethodAsString() const
Retrieves the gradient descent method as a string.
uint_fast64_t getMiniBatchSize() const
Retrieves the mini batch size of the gradient descent.
boost::optional< derivative::GradientDescentMethod > getGradientDescentMethod() const
Retrieves the gradient descent method.
DerivativeSettings()
Creates a new set of monotonicity checking settings.
double getAverageDecay() const
Retrieves the decay of the decaying step average of the ADAM algorithm.
bool areInconsequentialParametersOmitted() const
Are inconsequential parameters omitted?
boost::optional< derivative::GradientDescentConstraintMethod > getConstraintMethod() const
Retrieves the gradient descent method constraint method.
bool isFeasibleInstantiationSearchSet() const
Retrieves whether a feasible instance should be found by Gradient Descent.
double getTerminationEpsilon() const
Retrieves the termination epsilon.
double getLearningRate() const
Retrieves the learning rate for the gradient descent.
bool isPrintJsonSet() const
Retrieves whether the GradientDescentInstantiationSearcher should print the run as json after finishi...
std::string getConstraintMethodAsString() const
Retrieves the gradient descent method constraint method as a string.
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.
GradientDescentMethod
GradientDescentMethod is the method of Gradient Descent the GradientDescentInstantiationSearcher shal...
GradientDescentConstraintMethod
GradientDescentConstraintMethod is the method for mitigating constraints that the GradientDescentInst...