Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
CoreSettings.cpp
Go to the documentation of this file.
2
10
13
17
18namespace storm {
19namespace settings {
20namespace modules {
21
22const std::string CoreSettings::moduleName = "core";
23const std::string CoreSettings::eqSolverOptionName = "eqsolver";
24const std::string CoreSettings::lpSolverOptionName = "lpsolver";
25const std::string CoreSettings::smtSolverOptionName = "smtsolver";
26const std::string CoreSettings::statisticsOptionName = "statistics";
27const std::string CoreSettings::statisticsOptionShortName = "stats";
28const std::string CoreSettings::engineOptionName = "engine";
29const std::string CoreSettings::engineOptionShortName = "e";
30const std::string CoreSettings::ddLibraryOptionName = "ddlib";
31const std::string CoreSettings::intelTbbOptionName = "enable-tbb";
32const std::string CoreSettings::intelTbbOptionShortName = "tbb";
33
34CoreSettings::CoreSettings() : ModuleSettings(moduleName), engine(storm::utility::Engine::Sparse) {
35 std::vector<std::string> engines;
36 for (auto e : storm::utility::getEngines()) {
38 }
39 engines.push_back("portfolio"); // for backwards compatibility
40
41 this->addOption(storm::settings::OptionBuilder(moduleName, engineOptionName, false, "Sets which engine is used for model building and model checking.")
42 .setShortName(engineOptionShortName)
43 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the engine to use.")
45 .setDefaultValueString("sparse")
46 .build())
47 .build());
48
49 std::vector<std::string> linearEquationSolver = {"gmm++", "native", "eigen", "elimination", "topological", "acyclic"};
50 this->addOption(
51 storm::settings::OptionBuilder(moduleName, eqSolverOptionName, false, "Sets which solver is preferred for solving systems of linear equations.")
52 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the solver to prefer.")
54 .setDefaultValueString("topological")
55 .build())
56 .build());
57
58 std::vector<std::string> ddLibraries = {"cudd", "sylvan"};
59 this->addOption(storm::settings::OptionBuilder(moduleName, ddLibraryOptionName, false, "Sets which library is preferred for decision-diagram operations.")
60 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of the library to prefer.")
62 .setDefaultValueString("sylvan")
63 .build())
64 .build());
65
66 std::vector<std::string> lpSolvers = {"gurobi", "glpk", "z3", "soplex"};
67 this->addOption(storm::settings::OptionBuilder(moduleName, lpSolverOptionName, false, "Sets which LP solver is preferred.")
68 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of an LP solver.")
71 .build())
72 .build());
73
74 std::vector<std::string> smtSolvers = {"z3", "mathsat"};
75 this->addOption(storm::settings::OptionBuilder(moduleName, smtSolverOptionName, false, "Sets which SMT solver is preferred.")
76 .addArgument(storm::settings::ArgumentBuilder::createStringArgument("name", "The name of an SMT solver.")
79 .build())
80 .build());
81 this->addOption(storm::settings::OptionBuilder(moduleName, statisticsOptionName, false, "Sets whether to display statistics if available.")
82 .setShortName(statisticsOptionShortName)
83 .build());
84
85 this->addOption(
86 storm::settings::OptionBuilder(moduleName, intelTbbOptionName, false, "Sets whether to use Intel TBB (if Storm was built with support for TBB).")
87 .setShortName(intelTbbOptionShortName)
88 .build());
89}
90
91storm::solver::EquationSolverType CoreSettings::getEquationSolver() const {
92 std::string equationSolverName = this->getOption(eqSolverOptionName).getArgumentByName("name").getValueAsString();
93 if (equationSolverName == "gmm++") {
94 return storm::solver::EquationSolverType::Gmmxx;
95 } else if (equationSolverName == "native") {
96 return storm::solver::EquationSolverType::Native;
97 } else if (equationSolverName == "eigen") {
98 return storm::solver::EquationSolverType::Eigen;
99 } else if (equationSolverName == "elimination") {
100 return storm::solver::EquationSolverType::Elimination;
101 } else if (equationSolverName == "topological") {
102 return storm::solver::EquationSolverType::Topological;
103 } else if (equationSolverName == "acyclic") {
104 return storm::solver::EquationSolverType::Acyclic;
105 }
106 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown equation solver '" << equationSolverName << "'.");
107}
108
110 return this->getOption(eqSolverOptionName).getHasOptionBeenSet();
111}
112
114 return !this->getOption(eqSolverOptionName).getHasOptionBeenSet() || this->getOption(eqSolverOptionName).getArgumentByName("name").wasSetFromDefaultValue();
115}
116
117storm::solver::LpSolverType CoreSettings::getLpSolver() const {
118 std::string lpSolverName = this->getOption(lpSolverOptionName).getArgumentByName("name").getValueAsString();
119 if (lpSolverName == "gurobi") {
120 return storm::solver::LpSolverType::Gurobi;
121 } else if (lpSolverName == "glpk") {
122 return storm::solver::LpSolverType::Glpk;
123 } else if (lpSolverName == "z3") {
124 return storm::solver::LpSolverType::Z3;
125 } else if (lpSolverName == "soplex") {
126 return storm::solver::LpSolverType::Soplex;
127 }
128 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown LP solver '" << lpSolverName << "'.");
129}
130
132 return !this->getOption(lpSolverOptionName).getHasOptionBeenSet() || this->getOption(lpSolverOptionName).getArgumentByName("name").wasSetFromDefaultValue();
133}
134
135storm::solver::SmtSolverType CoreSettings::getSmtSolver() const {
136 std::string smtSolverName = this->getOption(smtSolverOptionName).getArgumentByName("name").getValueAsString();
137 if (smtSolverName == "z3") {
138 return storm::solver::SmtSolverType::Z3;
139 } else if (smtSolverName == "mathsat") {
140 return storm::solver::SmtSolverType::Mathsat;
141 }
142 STORM_LOG_THROW(false, storm::exceptions::IllegalArgumentValueException, "Unknown SMT solver '" << smtSolverName << "'.");
143}
144
146 std::string ddLibraryAsString = this->getOption(ddLibraryOptionName).getArgumentByName("name").getValueAsString();
147 if (ddLibraryAsString == "sylvan") {
149 } else {
151 }
152}
153
155 return !this->getOption(ddLibraryOptionName).getArgumentByName("name").getHasBeenSet() ||
156 this->getOption(ddLibraryOptionName).getArgumentByName("name").wasSetFromDefaultValue();
157}
158
160 return this->getOption(statisticsOptionName).getHasOptionBeenSet();
161}
162
164 return this->getOption(intelTbbOptionName).getHasOptionBeenSet();
165}
166
168 return engine;
169}
170
174
176 // Finalize engine.
177 std::string engineStr = this->getOption(engineOptionName).getArgumentByName("name").getValueAsString();
179 STORM_LOG_THROW(engine != storm::utility::Engine::Unknown, storm::exceptions::IllegalArgumentValueException, "Unknown engine '" << engineStr << "'.");
180}
181
183#ifdef STORM_HAVE_INTELTBB
184 return true;
185#else
186 STORM_LOG_WARN_COND(!isUseIntelTbbSet(), "Enabling TBB is not supported in this version of Storm as it was not built with support for it.");
187 return true;
188#endif
189}
190
191} // namespace modules
192} // namespace settings
193} // 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 isUseIntelTbbSet() const
Retrieves whether the option to use Intel TBB is set.
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_WARN_COND(cond, message)
Definition macros.h:38
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
SettingsType const & getModule()
Get module.
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:41
std::vector< Engine > getEngines()
Returns a list of all available engines (excluding Unknown)
Definition Engine.cpp:33
Engine engineFromString(std::string const &engineStr)
Parses the string representation of an engine and returns the corresponding engine.
Definition Engine.cpp:70
LabParser.cpp.
Definition cli.cpp:18