Storm 1.13.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
GurobiSettings.cpp
Go to the documentation of this file.
2
11namespace storm {
12namespace settings {
13namespace modules {
14
15const std::string GurobiSettings::moduleName = "gurobi";
16static const std::string methodOption = "method";
17static const std::string integerToleranceOption = "inttol";
18static const std::string threadsOption = "threads";
19static const std::string outputOption = "output";
20static const std::string mipFocusOption = "mipfocus";
21static const std::string concurrentMipThreadsOption = "concurrentmip";
22
24 std::vector<std::string> methods;
25 for (auto const& m : solver::getGurobiSolverMethods()) {
26 methods.push_back(solver::toString(m));
27 }
28
29 this->addOption(OptionBuilder(moduleName, methodOption, true, "The method Gurobi should use.")
30 .setIsAdvanced()
31 .addArgument(ArgumentBuilder::createStringArgument("method", "the name of the method")
32 .setDefaultValueString("auto")
34 .build())
35 .build());
36
37 this->addOption(
38 storm::settings::OptionBuilder(moduleName, threadsOption, true, "The number of threads that may be used by Gurobi.")
39 .setIsAdvanced()
40 .addArgument(
41 storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("count", "The number of threads.").setDefaultValueUnsignedInteger(1).build())
42 .build());
43
44 this->addOption(storm::settings::OptionBuilder(moduleName, outputOption, true, "If set, the Gurobi output will be printed to the command line.")
45 .setIsAdvanced()
46 .build());
47
48 this->addOption(storm::settings::OptionBuilder(moduleName, integerToleranceOption, true, "Sets Gurobi's precision for integer variables.")
49 .setIsAdvanced()
50 .addArgument(storm::settings::ArgumentBuilder::createDoubleArgument("value", "The precision to achieve.")
51 .setDefaultValueDouble(1e-06)
53 .build())
54 .build());
55
56 this->addOption(storm::settings::OptionBuilder(moduleName, mipFocusOption, true, "The high level solution strategy used to solve MILPs.")
57 .setIsAdvanced()
58 .addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("value", "The number of the strategy.")
59 .setDefaultValueUnsignedInteger(0)
61 .build())
62 .build());
63
65 "The number of MIP solvers Gurobi spawns in parallel. Shall not be larger then the number of threads.")
66 .setIsAdvanced()
67 .addArgument(storm::settings::ArgumentBuilder::createUnsignedIntegerArgument("value", "The number of parallel solvers.")
68 .setDefaultValueUnsignedInteger(1)
70 .build())
71 .build());
72}
73
75 return this->getOption(integerToleranceOption).getHasOptionBeenSet();
76}
77
79 return this->getOption(integerToleranceOption).getArgumentByName("value").getValueAsDouble();
80}
81
83 return this->getOption(threadsOption).getHasOptionBeenSet();
84}
85
87 return this->getOption(threadsOption).getArgumentByName("count").getValueAsUnsignedInteger();
88}
89
91 auto method = solver::gurobiSolverMethodFromString(this->getOption(methodOption).getArgumentByName("method").getValueAsString());
92 if (method.has_value()) {
93 return method.value();
94 }
95 STORM_LOG_ASSERT(false, "Unknown method name should not get through validator");
97}
98
100 return this->getOption(outputOption).getHasOptionBeenSet();
101}
102
104 return this->getOption(mipFocusOption).getArgumentByName("value").getValueAsUnsignedInteger();
105}
106
108 return this->getOption(concurrentMipThreadsOption).getArgumentByName("value").getValueAsUnsignedInteger();
109}
110
113 STORM_LOG_WARN_COND(storm::settings::getModule<storm::settings::modules::CoreSettings>().getLpSolver() == storm::solver::LpSolverType::Gurobi,
114 "Gurobi is not selected as the preferred LP solver, so setting options for Gurobi might have no effect.");
115 }
117 "Requested more concurrent MILP solvers then the available threads for Gurobi.");
118 return true;
119}
120
121} // namespace modules
122} // namespace settings
123} // namespace storm
virtual uint_fast64_t getValueAsUnsignedInteger() const =0
Retrieves the value of this argument as an unsigned integer.
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 createStringArgument(std::string const &name, std::string const &description)
Creates a string argument with the given parameters.
static std::shared_ptr< ArgumentValidator< uint64_t > > createUnsignedRangeValidatorIncluding(uint64_t lowerBound, uint64_t upperBound)
static std::shared_ptr< ArgumentValidator< double > > createDoubleRangeValidatorExcluding(double lowerBound, double upperBound)
static std::shared_ptr< ArgumentValidator< uint64_t > > createUnsignedGreaterEqualValidator(uint64_t lowerBound)
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
solver::GurobiSolverMethod getMethod() const
Retrieves the solver method.
bool isOutputSet() const
Retrieves whether the output option was set.
uint64_t getNumberOfThreads() const
Retrieves the maximal number of threads Gurobi is allowed to use.
bool check() const override
Checks whether the settings are consistent.
GurobiSettings()
Creates a new set of Gurobi settings.
bool isNumberOfThreadsSet() const
Retrieves whether the number of threads has been set.
uint64_t getNumberOfConcurrentMipThreads() const
Retrieves the number of MIP solvers, Gurobi spawns in parallel.
uint64_t getMIPFocus() const
Retrieves the selected high-level solution strategy for MILPs.
double getIntegerTolerance() const
Retrieves the integer tolerance to be used.
bool isIntegerToleranceSet() const
Retrieves whether the integer tolerance has been set.
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_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_WARN_COND(cond, message)
Definition macros.h:38
static const std::string outputOption
static const std::string mipFocusOption
static const std::string threadsOption
static const std::string methodOption
static const std::string integerToleranceOption
static const std::string concurrentMipThreadsOption
SettingsType const & getModule()
Get module.
std::string toString(GurobiSolverMethod const &method)
Yields a string representation of the GurobiSolverMethod.
std::optional< GurobiSolverMethod > gurobiSolverMethodFromString(std::string const &method)
std::vector< GurobiSolverMethod > getGurobiSolverMethods()