19#include "absl/cleanup/cleanup.h"
20#include "absl/log/check.h"
21#include "absl/status/status.h"
22#include "absl/status/statusor.h"
23#include "absl/strings/string_view.h"
26#include "ortools/math_opt/solvers/gurobi.pb.h"
31 GRBenv* primary_env =
nullptr;
35 absl::Cleanup primary_env_cleanup = [primary_env] {
38 const auto handle_failure =
39 [primary_env](
const int err_code,
40 const absl::string_view operation_name) -> absl::Status {
42 return absl::OkStatus();
48 <<
"failed to create Gurobi primary environment with ISV key, "
49 << operation_name <<
" returned the error (" << err_code
55 int original_output_flag;
58 &original_output_flag),
59 "getting original GRB_INT_PAR_OUTPUTFLAG value"));
62 "turning off GRB_INT_PAR_OUTPUTFLAG"));
65 "setting GURO_PAR_ISVNAME"));
69 "setting GURO_PAR_ISVAPPNAME"));
72 handle_failure(
GRBsetintparam(primary_env,
"GURO_PAR_ISVEXPIRATION",
74 "setting GURO_PAR_ISVEXPIRATION"));
78 "setting GURO_PAR_ISVKEY"));
83 "resetting GRB_INT_PAR_OUTPUTFLAG"));
86 std::move(primary_env_cleanup).Cancel();
#define RETURN_IF_ERROR(expr)
#define GRB_INT_PAR_OUTPUTFLAG
An object oriented wrapper for quadratic constraints in ModelStorage.
absl::StatusOr< GRBenv * > NewPrimaryEnvFromISVKey(const GurobiIsvKey &isv_key)
std::function< void(GRBenv *env)> GRBfreeenv
std::function< int(GRBenv *env, const char *paramname, int value)> GRBsetintparam
std::function< int(GRBenv *env, const char *paramname, const char *value)> GRBsetstrparam
std::function< int(GRBenv **envP)> GRBemptyenv
std::function< const char *(GRBenv *env)> GRBgeterrormsg
std::function< int(GRBenv *env, const char *paramname, int *valueP)> GRBgetintparam
std::function< int(GRBenv *env)> GRBstartenv
StatusBuilder InvalidArgumentErrorBuilder()
std::string application_name
int32_t expiration
Zero means no expiration.