Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MultiObjectiveSettings.cpp
Go to the documentation of this file.
2
8
9namespace storm {
10namespace settings {
11namespace modules {
12
13const std::string MultiObjectiveSettings::moduleName = "multiobjective";
14const std::string MultiObjectiveSettings::methodOptionName = "method";
15const std::string MultiObjectiveSettings::exportPlotOptionName = "exportplot";
16const std::string MultiObjectiveSettings::precisionOptionName = "precision";
17const std::string MultiObjectiveSettings::weightedSumApproximationTradeoffOptionName = "approxtradeoff";
18const std::string MultiObjectiveSettings::maxStepsOptionName = "maxsteps";
19const std::string MultiObjectiveSettings::schedulerRestrictionOptionName = "purescheds";
20const std::string MultiObjectiveSettings::printResultsOptionName = "printres";
21const std::string MultiObjectiveSettings::encodingOptionName = "encoding";
22const std::string MultiObjectiveSettings::lexicographicOptionName = "lex";
23
25 std::vector<std::string> methods = {"pcaa", "constraintbased"};
26 this->addOption(storm::settings::OptionBuilder(moduleName, methodOptionName, true, "The method to be used for multi objective model checking.")
27 .setIsAdvanced()
28 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the method to use.")
30 .setDefaultValueString("pcaa")
31 .build())
32 .build());
33 this->addOption(storm::settings::OptionBuilder(moduleName, exportPlotOptionName, true, "Saves data for plotting of pareto curves and achievable values.")
34 .setIsAdvanced()
36 "directory", "A path to an existing directory in which the results will be saved.")
37 .build())
38 .build());
39 std::vector<std::string> precTypes = {"abs", "reldiff"};
40 this->addOption(
41 storm::settings::OptionBuilder(moduleName, precisionOptionName, true, "The precision used for the approximation of numerical- and pareto queries.")
42 .setIsAdvanced()
43 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision.")
44 .setDefaultValueDouble(1e-04)
46 .build())
47 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("type", "The type of precision.")
48 .setDefaultValueString("abs")
49 .makeOptional()
51 .build())
52 .build());
53 this->addOption(
54 storm::settings::OptionBuilder(moduleName, weightedSumApproximationTradeoffOptionName, true,
55 "Sets the fraction of the approximation error that is allowed during weighted sum optimization in pcaa method.")
56 .setIsAdvanced()
57 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("gamma", "the tradeoff factor.")
59 .build())
60 .build());
61 this->addOption(storm::settings::OptionBuilder(moduleName, maxStepsOptionName, true,
62 "Aborts the computation after the given number of refinement steps (= computed pareto optimal points).")
63 .setIsAdvanced()
65 "value", "the threshold for the number of refinement steps to be performed.")
66 .build())
67 .build());
68 std::vector<std::string> memoryPatterns = {"positional", "goalmemory", "arbitrary", "counter"};
69 this->addOption(
70 storm::settings::OptionBuilder(moduleName, schedulerRestrictionOptionName, false,
71 "Restricts the class of considered schedulers to non-randomized schedulers with the provided memory pattern.")
72 .setIsAdvanced()
73 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("memorypattern", "The pattern of the memory.")
74 .setDefaultValueString("positional")
76 .makeOptional()
77 .build())
79 "The Number of memory states (only if supported by the pattern).")
80 .setDefaultValueUnsignedInteger(0)
81 .makeOptional()
82 .build())
83 .build());
84 this->addOption(
85 storm::settings::OptionBuilder(moduleName, printResultsOptionName, true, "Prints intermediate results of the computation to standard output.")
86 .setIsAdvanced()
87 .build());
88 this->addOption(storm::settings::OptionBuilder(moduleName, encodingOptionName, true, "The preferred for encoding for constraint-based methods.")
89 .setIsAdvanced()
90 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("style", "The main type of encoding.")
91 .setDefaultValueString("auto")
92 .addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator({"auto", "classic", "flow"}))
93 .build())
94 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("constraints", "type of constraints.")
95 .setDefaultValueString("bigm")
96 .addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator({"bigm", "indicator"}))
97 .makeOptional()
98 .build())
99 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("bscc", "bscc encoding.")
100 .setDefaultValueString("flow")
101 .addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator({"flow", "order"}))
102 .makeOptional()
103 .build())
104 .addArgument(storm::settings::ArgumentBuilder::createBooleanArgument("redundant", "enable redundant bscc constraints.")
105 .setDefaultValueBoolean(false)
106 .makeOptional()
107 .build())
108 .build());
109
110 this->addOption(storm::settings::OptionBuilder(moduleName, lexicographicOptionName, false,
111 "(Deprecated) If set, lexicographic model checking instead of normal multi objective is performed.")
112 .build());
113}
114
115storm::modelchecker::multiobjective::MultiObjectiveMethod MultiObjectiveSettings::getMultiObjectiveMethod() const {
116 std::string methodAsString = this->getOption(methodOptionName).getArgumentByName("name").getValueAsString();
117 if (methodAsString == "pcaa") {
118 return storm::modelchecker::multiobjective::MultiObjectiveMethod::Pcaa;
119 } else {
120 STORM_LOG_ASSERT(methodAsString == "constraintbased", "Unexpected method name for multi objective model checking method.");
121 return storm::modelchecker::multiobjective::MultiObjectiveMethod::ConstraintBased;
122 }
123}
124
126 return this->getOption(exportPlotOptionName).getHasOptionBeenSet();
127}
128
130 std::string result = this->getOption(exportPlotOptionName).getArgumentByName("directory").getValueAsString();
131 if (result.back() != '/') {
132 result.push_back('/');
133 }
134 return result;
135}
136
138 return this->getOption(precisionOptionName).getArgumentByName("value").getValueAsDouble();
139}
140
142 return this->getOption(precisionOptionName).getArgumentByName("type").getValueAsString() == "reldiff";
143}
144
146 return this->getOption(precisionOptionName).getArgumentByName("type").getValueAsString() == "abs";
147}
148
150 return this->getOption(weightedSumApproximationTradeoffOptionName).getHasOptionBeenSet();
151}
152
154 return this->getOption(weightedSumApproximationTradeoffOptionName).getArgumentByName("gamma").getValueAsDouble();
155}
156
158 return this->getOption(maxStepsOptionName).getHasOptionBeenSet();
159}
160
162 return this->getOption(maxStepsOptionName).getArgumentByName("value").getValueAsUnsignedInteger();
163}
164
166 return this->getOption(schedulerRestrictionOptionName).getHasOptionBeenSet();
167}
168
171 result.setIsDeterministic(true);
172
173 std::string pattern = this->getOption(schedulerRestrictionOptionName).getArgumentByName("memorypattern").getValueAsString();
174 uint64_t states = this->getOption(schedulerRestrictionOptionName).getArgumentByName("memorystates").getValueAsUnsignedInteger();
175 if (pattern == "positional") {
176 result.setPositional();
177 STORM_LOG_THROW(states <= 1, storm::exceptions::IllegalArgumentException,
178 "The number of memory states should not be provided for the given memory pattern.");
179 } else if (pattern == "goalmemory") {
181 STORM_LOG_THROW(states == 0, storm::exceptions::IllegalArgumentException,
182 "The number of memory states should not be provided for the given memory pattern.");
183 } else if (pattern == "arbitrary") {
184 STORM_LOG_THROW(states > 0, storm::exceptions::IllegalArgumentException,
185 "Invalid number of memory states for provided pattern. Please specify a positive number.");
187 result.setMemoryStates(states);
188 } else if (pattern == "counter") {
189 STORM_LOG_THROW(states > 0, storm::exceptions::IllegalArgumentException,
190 "Invalid number of memory states for provided pattern. Please specify a positive number.");
192 result.setMemoryStates(states);
193 } else {
194 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentException, "Invalid memory pattern: " + pattern + ".");
195 }
196 return result;
197}
198
200 return this->getOption(printResultsOptionName).getHasOptionBeenSet();
201}
202
204 return this->getOption(encodingOptionName).getArgumentByName("style").getValueAsString() == "classic";
205}
206
208 return this->getOption(encodingOptionName).getArgumentByName("style").getValueAsString() == "flow";
209}
210
212 return this->getOption(encodingOptionName).getArgumentByName("style").getValueAsString() == "auto";
213}
214
216 return this->getOption(encodingOptionName).getArgumentByName("bscc").getValueAsString() == "flow";
217}
218
220 return this->getOption(encodingOptionName).getArgumentByName("bscc").getValueAsString() == "order";
221}
222
224 return this->getOption(encodingOptionName).getArgumentByName("constraints").getValueAsString() == "bigm";
225}
226
228 return this->getOption(encodingOptionName).getArgumentByName("constraints").getValueAsString() == "indicator";
229}
230
232 return this->getOption(encodingOptionName).getArgumentByName("redundant").getValueAsBoolean();
233}
234
236 return this->getOption(lexicographicOptionName).getHasOptionBeenSet();
237}
238
241 "Option '--" << moduleName << ":" << lexicographicOptionName << "' is deprecated. Use a `multilex(..)` formula instead.");
242}
243
245 std::shared_ptr<storm::settings::ArgumentValidator<std::string>> validator = ArgumentValidatorFactory::createWritableFileValidator();
246
247 if (isExportPlotSet()) {
248 if (!(validator->isValid(getExportPlotDirectory() + "boundaries.csv") && validator->isValid(getExportPlotDirectory() + "overapproximation.csv") &&
249 validator->isValid(getExportPlotDirectory() + "underapproximation.csv") && validator->isValid(getExportPlotDirectory() + "paretopoints.csv"))) {
250 return false;
251 }
252 }
253
256 }
257
258 return true;
259}
260
261} // namespace modules
262} // namespace settings
263} // 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 getValueAsBoolean() const =0
Retrieves the value of this argument as a boolean.
virtual double getValueAsDouble() const =0
Retrieves the value of this argument as a double.
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 createBooleanArgument(std::string const &name, std::string const &description)
Creates a boolean 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< double > > createDoubleGreaterEqualValidator(double lowerBound)
static std::shared_ptr< ArgumentValidator< std::string > > createMultipleChoiceValidator(std::vector< std::string > const &choices)
static std::shared_ptr< ArgumentValidator< std::string > > createWritableFileValidator()
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
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.
bool isClassicEncodingSet() const
Retrieves whether the classic encoding for constraint-based methods is to be preferred.
storm::modelchecker::multiobjective::MultiObjectiveMethod getMultiObjectiveMethod() const
Returns the preferred method for multi objective model checking.
bool isPrintResultsSet() const
Retrieves whether output of intermediate results is enabled.
double getWeightedSumApproximationTradeoff() const
Retrieve approximation tradeoff between accuracy of weighted sum optimization vs.
bool isAutoEncodingSet() const
Retrieves whether the encoding for constraint-based methods should be picked automatically.
storm::storage::SchedulerClass getSchedulerRestriction() const
Retrieves the scheduler restriction if it has been set.
bool isRedundantBsccConstraintsSet() const
Retrieves whether redundant BSCC constraints are to be added.
bool getPrecisionAbsolute() const
Retrieves whether the desired precision is considered to be absolute.
bool isBsccDetectionViaFlowConstraintsSet() const
Retrieves whether the encoding for constraint-based methods should use flow constraints for BSCC dete...
bool isMaxStepsSet() const
Retrieves whether or not a threshold for the number of performed refinement steps is given.
bool isWeightedSumApproximationTradeoffSet() const
Retrieves whether the fraction of approximation error was set explicitly.
bool getPrecisionRelativeToDiff() const
Retrieves whether the desired precision is considered to be relative to the difference between highes...
std::string getExportPlotDirectory() const
The path to a directory in which the plot data should be stored.
virtual bool check() const override
Checks whether the settings are consistent.
MultiObjectiveSettings()
Creates a new set of multi-objective model checking settings.
bool hasSchedulerRestriction() const
Retrieves whether a scheduler restriction has been set.
uint_fast64_t getMaxSteps() const
Retrieves The maximum number of refinement steps that should be performed (if given).
bool isFlowEncodingSet() const
Retrieves whether the flow encoding for constraint-based methods is to be preferred.
bool isBsccDetectionViaOrderConstraintsSet() const
Retrieves whether the encoding for constraint-based methods should use order constraints for BSCC det...
virtual void finalize() override
Prepares the modules for further usage, should be called at the end of the initialization,...
bool isLexicographicModelCheckingSet() const
Retrieves whether lexicographic model checking has been set.
double getPrecision() const
Retrieves the desired precision for quantitative- and pareto queries.
bool isIndicatorConstraintsSet() const
Retrieves whether the encoding for constraint-based methods should use indicator constraints.
bool isBigMConstraintsSet() const
Retrieves whether the encoding for constraint-based methods should use BigM constraints.
bool isExportPlotSet() const
Retrieves whether the data for plotting should be exported.
SchedulerClass & setMemoryStates(uint64_t value)
SchedulerClass & setMemoryPattern(MemoryPattern const &pattern)
SchedulerClass & setIsDeterministic(bool value=true)
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:38
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
std::vector< std::string > memoryPatterns