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