20#include "absl/strings/str_cat.h"
29constexpr absl::string_view kLimitsTime =
"limits/time";
30constexpr absl::string_view kParallelMaxNThreads =
"parallel/maxnthreads";
31constexpr absl::string_view kDisplayVerbLevel =
"display/verblevel";
32constexpr absl::string_view kRandomSeedParam =
"randomization/randomseedshift";
33constexpr absl::string_view kCatchCtrlCParam =
"misc/catchctrlc";
38 (*
parameters->mutable_real_params())[std::string(kLimitsTime)] =
41 parameters->mutable_real_params()->erase(std::string(kLimitsTime));
46 if (
parameters.real_params().contains(std::string(kLimitsTime))) {
47 const double scip_limit =
48 parameters.real_params().at(std::string(kLimitsTime));
49 if (scip_limit >= 1e20) {
50 return absl::InfiniteDuration();
51 }
else if (scip_limit <= 0.0) {
52 return absl::ZeroDuration();
54 return absl::Seconds(scip_limit);
57 return absl::InfiniteDuration();
61 return parameters.real_params().contains(std::string(kLimitsTime));
65 CHECK_GE(num_threads, 1);
66 (*
parameters->mutable_int_params())[std::string(kParallelMaxNThreads)] =
71 if (
parameters.int_params().contains(std::string(kParallelMaxNThreads))) {
72 return parameters.int_params().at(std::string(kParallelMaxNThreads));
78 return parameters.int_params().contains(std::string(kParallelMaxNThreads));
82 CHECK_GE(log_level, 0);
83 CHECK_LE(log_level, 5);
84 (*
parameters->mutable_int_params())[std::string(kDisplayVerbLevel)] =
89 return parameters.int_params().contains(std::string(kDisplayVerbLevel))
90 ?
parameters.int_params().at(std::string(kDisplayVerbLevel))
94 return parameters.int_params().contains(std::string(kDisplayVerbLevel));
99 parameters->mutable_int_params()->erase(std::string(kDisplayVerbLevel));
101 (*
parameters->mutable_int_params())[std::string(kDisplayVerbLevel)] = 0;
105 return !
parameters.int_params().contains(std::string(kDisplayVerbLevel)) ||
106 (
parameters.int_params().at(std::string(kDisplayVerbLevel)) > 0);
114 random_seed = std::max(0, random_seed);
115 (*
parameters->mutable_int_params())[std::string(kRandomSeedParam)] =
121 return parameters.int_params().at(std::string(kRandomSeedParam));
127 return parameters.int_params().contains(std::string(kRandomSeedParam));
132 (*
parameters->mutable_bool_params())[std::string(kCatchCtrlCParam)] =
138 return parameters.bool_params().at(std::string(kCatchCtrlCParam));
144 return parameters.bool_params().contains(std::string(kCatchCtrlCParam));
152 const std::vector<std::string> scip_separators = {
153 "cgmip",
"clique",
"closecuts",
"flowcover",
"cmir",
154 "aggregation",
"convexproj",
"disjunctive",
"eccuts",
"gauge",
155 "gomory",
"impliedbounds",
"intobj",
"mcf",
"oddcycle",
156 "rapidlearning",
"strongcg",
"zerohalf"};
157 for (
const std::string& separator : scip_separators) {
158 const std::string separator_parameter =
159 absl::StrCat(
"separating/", separator,
"/freq");
160 (*
parameters->mutable_int_params())[separator_parameter] = -1;
In SWIG mode, we don't want anything besides these top-level includes.
void GScipSetOutputEnabled(GScipParameters *parameters, bool output_enabled)
Sets the log level to 4 if enabled, 0 if disabled (see above).
void GScipSetRandomSeed(GScipParameters *parameters, int random_seed)
bool GScipCatchCtrlCSet(const GScipParameters ¶meters)
Returns true when the misc/catchctrlc property is set.
void GScipSetCatchCtrlC(const bool catch_ctrl_c, GScipParameters *const parameters)
Sets the misc/catchctrlc property.
bool GScipTimeLimitSet(const GScipParameters ¶meters)
bool GScipOutputEnabled(const GScipParameters ¶meters)
Checks if the log level is equal to zero.
bool GScipLogLevelSet(const GScipParameters ¶meters)
bool GScipRandomSeedSet(const GScipParameters ¶meters)
bool GScipMaxNumThreadsSet(const GScipParameters ¶meters)
bool GScipOutputEnabledSet(const GScipParameters ¶meters)
void DisableAllCutsExceptUserDefined(GScipParameters *parameters)
Turns off all SCIP separators.
int GScipRandomSeed(const GScipParameters ¶meters)
Returns -1 if unset.
int GScipMaxNumThreads(const GScipParameters ¶meters)
Returns 1 if the number of threads it not specified.
bool GScipCatchCtrlC(const GScipParameters ¶meters)
void GScipSetLogLevel(GScipParameters *parameters, int log_level)
absl::Duration GScipTimeLimit(const GScipParameters ¶meters)
void GScipSetMaxNumThreads(int num_threads, GScipParameters *parameters)
CHECK fails if num_threads < 1.
void GScipSetTimeLimit(absl::Duration time_limit, GScipParameters *parameters)
int GScipLogLevel(const GScipParameters ¶meters)