Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
CoreSettings.cpp
Go to the documentation of this file.
2
10
12
16
17namespace storm {
18namespace settings {
19namespace modules {
20
21const std::string CoreSettings::moduleName = "core";
22const std::string CoreSettings::eqSolverOptionName = "eqsolver";
23const std::string CoreSettings::lpSolverOptionName = "lpsolver";
24const std::string CoreSettings::smtSolverOptionName = "smtsolver";
25const std::string CoreSettings::statisticsOptionName = "statistics";
26const std::string CoreSettings::statisticsOptionShortName = "stats";
27const std::string CoreSettings::engineOptionName = "engine";
28const std::string CoreSettings::engineOptionShortName = "e";
29const std::string CoreSettings::ddLibraryOptionName = "ddlib";
30
32 // TODO: We currently never set Gurobi as a default LP solver as
33 // its availability is depending on the license, which may be confusing.
34 // We track this item in #issue 680.
35#if defined STORM_HAVE_GLPK
36 return "glpk";
37#elif defined STORM_HAVE_SOPLEX
38 return "soplex";
39#else
40 return "z3";
41#endif
42}
43
44CoreSettings::CoreSettings() : ModuleSettings(moduleName), engine(storm::utility::Engine::Sparse) {
45 std::vector<std::string> engines;
46 for (auto e : storm::utility::getEngines()) {
47 engines.push_back(storm::utility::toString(e));
48 }
49 engines.push_back("portfolio"); // for backwards compatibility
50
51 this->addOption(storm::settings::OptionBuilder(moduleName, engineOptionName, false, "Sets which engine is used for model building and model checking.")
52 .setShortName(engineOptionShortName)
53 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the engine to use.")
55 .setDefaultValueString("sparse")
56 .build())
57 .build());
58
59 std::vector<std::string> linearEquationSolver = {"gmm++", "native", "eigen", "elimination", "topological", "acyclic"};
60 this->addOption(
61 storm::settings::OptionBuilder(moduleName, eqSolverOptionName, false, "Sets which solver is preferred for solving systems of linear equations.")
62 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the solver to prefer.")
63 .addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(linearEquationSolver))
64 .setDefaultValueString("topological")
65 .build())
66 .build());
67
68 // Initialize options for DD libraries
69 std::vector<std::string> ddLibraries;
70 std::string ddDefault = "";
71#ifdef STORM_HAVE_CUDD
72 ddLibraries.push_back("cudd");
73 ddDefault = "cudd";
74#endif
75#ifdef STORM_HAVE_SYLVAN
76 ddLibraries.push_back("sylvan");
77 ddDefault = "sylvan"; // Overwrite previous default and give Sylvan priority
78#endif
79 if (!ddLibraries.empty()) {
80 this->addOption(
81 storm::settings::OptionBuilder(moduleName, ddLibraryOptionName, false, "Sets which library is preferred for decision-diagram operations.")
82 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the library to prefer.")
83 .addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(ddLibraries))
84 .setDefaultValueString(ddDefault)
85 .build())
86 .build());
87 }
88
89 std::vector<std::string> lpSolvers = {"gurobi", "glpk", "z3", "soplex"};
90 this->addOption(storm::settings::OptionBuilder(moduleName, lpSolverOptionName, false, "Sets which LP solver is preferred.")
91 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of an LP solver.")
93 .setDefaultValueString(getDefaultLpSolverAsString())
94 .build())
95 .build());
96
97 std::vector<std::string> smtSolvers = {"z3", "mathsat"};
98 this->addOption(storm::settings::OptionBuilder(moduleName, smtSolverOptionName, false, "Sets which SMT solver is preferred.")
99 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of an SMT solver.")
100 .addValidatorString(ArgumentValidatorFactory::createMultipleChoiceValidator(smtSolvers))
101 .setDefaultValueString("z3")
102 .build())
103 .build());
104 this->addOption(storm::settings::OptionBuilder(moduleName, statisticsOptionName, false, "Sets whether to display statistics if available.")
105 .setShortName(statisticsOptionShortName)
106 .build());
107}
108
109storm::solver::EquationSolverType CoreSettings::getEquationSolver() const {
110 std::string equationSolverName = this->getOption(eqSolverOptionName).getArgumentByName("name").getValueAsString();
111 if (equationSolverName == "gmm++") {
112 return storm::solver::EquationSolverType::Gmmxx;
113 } else if (equationSolverName == "native") {
114 return storm::solver::EquationSolverType::Native;
115 } else if (equationSolverName == "eigen") {
116 return storm::solver::EquationSolverType::Eigen;
117 } else if (equationSolverName == "elimination") {
118 return storm::solver::EquationSolverType::Elimination;
119 } else if (equationSolverName == "topological") {
120 return storm::solver::EquationSolverType::Topological;
121 } else if (equationSolverName == "acyclic") {
122 return storm::solver::EquationSolverType::Acyclic;
123 }
124 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown equation solver '" << equationSolverName << "'.");
125}
126
128 return this->getOption(eqSolverOptionName).getHasOptionBeenSet();
129}
130
132 return !this->getOption(eqSolverOptionName).getHasOptionBeenSet() || this->getOption(eqSolverOptionName).getArgumentByName("name").wasSetFromDefaultValue();
133}
134
135storm::solver::LpSolverType CoreSettings::getLpSolver() const {
136 std::string lpSolverName = this->getOption(lpSolverOptionName).getArgumentByName("name").getValueAsString();
137 if (lpSolverName == "gurobi") {
138 return storm::solver::LpSolverType::Gurobi;
139 } else if (lpSolverName == "glpk") {
140 return storm::solver::LpSolverType::Glpk;
141 } else if (lpSolverName == "z3") {
142 return storm::solver::LpSolverType::Z3;
143 } else if (lpSolverName == "soplex") {
144 return storm::solver::LpSolverType::Soplex;
145 }
146 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown LP solver '" << lpSolverName << "'.");
147}
148
150 return !this->getOption(lpSolverOptionName).getHasOptionBeenSet() || this->getOption(lpSolverOptionName).getArgumentByName("name").wasSetFromDefaultValue();
151}
152
153storm::solver::SmtSolverType CoreSettings::getSmtSolver() const {
154 std::string smtSolverName = this->getOption(smtSolverOptionName).getArgumentByName("name").getValueAsString();
155 if (smtSolverName == "z3") {
156 return storm::solver::SmtSolverType::Z3;
157 } else if (smtSolverName == "mathsat") {
158 return storm::solver::SmtSolverType::Mathsat;
159 }
160 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown SMT solver '" << smtSolverName << "'.");
161}
162
164 std::string ddLibraryAsString = this->getOption(ddLibraryOptionName).getArgumentByName("name").getValueAsString();
165 if (ddLibraryAsString == "sylvan") {
167 } else {
169 }
170}
171
173 return !this->getOption(ddLibraryOptionName).getArgumentByName("name").getHasBeenSet() ||
174 this->getOption(ddLibraryOptionName).getArgumentByName("name").wasSetFromDefaultValue();
175}
176
178 return this->getOption(statisticsOptionName).getHasOptionBeenSet();
179}
180
182 return engine;
183}
184
186 this->engine = newEngine;
187}
188
190 // Finalize engine.
191 std::string engineStr = this->getOption(engineOptionName).getArgumentByName("name").getValueAsString();
192 engine = storm::utility::engineFromString(engineStr);
193 STORM_LOG_THROW(engine != storm::utility::Engine::Unknown, storm::exceptions::IllegalArgumentValueException, "Unknown engine '" << engineStr << "'.");
194}
195
197 return true;
198}
199
200} // namespace modules
201} // namespace settings
202} // namespace storm
virtual std::string getValueAsString() const =0
Retrieves the value of this argument as a string.
virtual bool getHasBeenSet() const
Retrieves whether the argument has been set.
virtual bool wasSetFromDefaultValue() const =0
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)
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::solver::LpSolverType getLpSolver() const
Retrieves the selected LP solver.
storm::dd::DdType getDdLibraryType() const
Retrieves the selected library for DD-related operations.
bool isShowStatisticsSet() const
Retrieves whether statistics are to be shown.
storm::solver::EquationSolverType getEquationSolver() const
Retrieves the selected equation solver.
bool isEquationSolverSetFromDefaultValue() const
Retrieves whether the equation solver has been set from its default value.
bool isEquationSolverSet() const
Retrieves whether a equation solver has been set.
CoreSettings()
Creates a new set of core settings.
bool isLpSolverSetFromDefaultValue() const
Retrieves whether the lp solver has been set from its default value.
void finalize() override
Prepares the modules for further usage, should be called at the end of the initialization,...
void setEngine(storm::utility::Engine const &engine)
Sets the engine for further usage.
bool check() const override
Checks whether the settings are consistent.
storm::solver::SmtSolverType getSmtSolver() const
Retrieves the selected SMT solver.
bool isDdLibraryTypeSetFromDefaultValue() const
Retrieves whether the selected DD library is set from its default value.
static const std::string moduleName
storm::utility::Engine getEngine() const
Retrieves the selected engine.
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
std::string getDefaultLpSolverAsString()
Engine
An enumeration of all engines.
Definition Engine.h:31
std::string toString(Engine const &engine)
Returns a string representation of the given engine.
Definition Engine.cpp:37
std::vector< Engine > getEngines()
Returns a list of all available engines (excluding Unknown)
Definition Engine.cpp:29
Engine engineFromString(std::string const &engineStr)
Parses the string representation of an engine and returns the corresponding engine.
Definition Engine.cpp:66