OR-Tools  9.3
g_gurobi.h
Go to the documentation of this file.
1// Copyright 2010-2021 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14// Google C++ bindings for Gurobi C API.
15//
16// Attempts to be as close to the Gurobi C API as possible, with the following
17// differences:
18// * Use destructors to automatically clean up the environment and model.
19// * Use absl::Status to propagate errors instead of int gurobi error codes.
20// * Use absl::StatusOr instead of output arguments.
21// * Use absl::Span<T> instead of T* and size for array args.
22// * Use std::string instead of null terminated char* for string values (note
23// that attribute names are still char*).
24// * When setting array data, accept const data (absl::Span<const T>).
25// * Callbacks are passed as an argument to optimize and then are cleared.
26// * Callbacks propagate errors with status.
27// * There is no distinction between a GRBmodel and the GRBenv created for a
28// model, they are jointly captured by the newly defined Gurobi object.
29// * Parameters are set on the Gurobi class rather than on a GRBenv. We do not
30// provide an API fo setting parameters on the master environment, only on
31// the child environment created by GRBnewmodel (for details see
32// https://www.gurobi.com/documentation/9.1/refman/c_newmodel.html ).
33#ifndef OR_TOOLS_MATH_OPT_SOLVERS_GUROBI_G_GUROBI_H_
34#define OR_TOOLS_MATH_OPT_SOLVERS_GUROBI_G_GUROBI_H_
35
36#include <cstdint>
37#include <functional>
38#include <memory>
39#include <string>
40
41#include "absl/status/status.h"
42#include "absl/status/statusor.h"
43#include "absl/types/span.h"
46
48
49// An ISV key for the Gurobi solver, an alternative to using a license file.
50//
51// See http://www.gurobi.com/products/licensing-pricing/isv-program.
53 std::string name;
54 std::string application_name;
55 int32_t expiration = 0;
56 std::string key;
57};
58
59// Functor to use as deleter for std::unique_ptr that stores a master GRBenv,
60// used by GRBenvUniquePtr. Most users will not use this directly.
62 void operator()(GRBenv* const env) const;
63};
64
65// Unique pointer to a GRBenv. It destroys the environment on destruction
66// calling GRBfreeenv. Most users will not use this directly.
67using GRBenvUniquePtr = std::unique_ptr<GRBenv, GurobiFreeEnv>;
68
69// Returns a new master Gurobi environment, using the ISV key if provided, or a
70// regular license otherwise. Gurobi::New() creates an environment automatically
71// if not provided, so most users will not use this directly.
72absl::StatusOr<GRBenvUniquePtr> GurobiNewMasterEnv(
73 const std::optional<GurobiIsvKey>& isv_key = std::nullopt);
74
75// Models and solves optimization problems with Gurobi.
76//
77// This is a thin wrapper on the Gurobi C API, holding a GRBmodel,
78// associated GRBenv that GRBnewmodel creates, and optionally the master
79// environment to clean up on deletion.
80//
81// Throughout, we refer to the child GRBenv created by GRBnewmodel as the
82// "model environment" while the GRBenv that was used to create the model as
83// the "master environment", for details see:
84// https://www.gurobi.com/documentation/9.1/refman/c_newmodel.html
85//
87// Attributes
89//
90// Most properties of a Gurobi optimization model are set and read with
91// attributes, using the attribute names defined in the Gurobi C API. There are
92// scalar attributes returning a single value of the following types:
93// * int, e.g. GRB_INT_ATTR_MODELSENSE
94// * double, e.g. GRB_DBL_ATTR_OBJVAL
95// * string, e.g. GRB_STR_ATTR_MODELNAME
96// and array attributes returning a list of values of the following types:
97// * int array, e.g. GRB_INT_ATTR_BRANCHPRIORITY
98// * double array, e.g. GRB_DBL_ATTR_LB
99// * char array, e.g. GRB_CHAR_ATTR_VTYPE
100//
101// You set a scalar attribute with the methods SetXXXAttr, e.g.
102// std::unique_ptr<Gurobi> gurobi = Gurobi::New().value();
103// absl::Status s = gurobi->SetIntAttr(GRB_INT_ATTR_MODELSENSE, 1);
104// Note that not all attributes can be set; consult the Gurobi attribute docs.
105//
106// Attributes can also be read. However, attributes can be unavailable depending
107// on the context, e.g. the solution objective value is not available before
108// solving. You can determine when an attribute is available either from the
109// Gurobi documentation or by directly testing:
110// std::unique_ptr<Gurobi> gurobi = Gurobi::New().value();
111// bool is_avail = gurobi->IsAttrAvailable(GRB_DBL_ATTR_OBJVAL);
112// To read an attribute:
113// std::unique_ptr<Gurobi> gurobi = Gurobi::New().value();
114// absl::StatusOr<double> obj = gurobi->GetDoubleAttr(GRB_DBL_ATTR_OBJVAL);
115// (The method *should* succeed when IsAttrAvailable() is true and you have
116// specified the type of attribute correctly.)
117//
118// Array attributes are similar, but the API differs slightly. E.g. to set the
119// first three variable lower bounds to 1.0:
120// std::unique_ptr<Gurobi> gurobi = Gurobi::New().value();
121// absl::Status s = gurobi->SetDoubleAttrArray(GRB_DBL_ATTR_LB, {1, 1, 1});
122// You can also set specific indices, see SetDoubleAttrList. To read, use:
123// Gurobi* gurobi = ...;
124// int num_vars = ...;
125// absl::StatusOr<std::vector<double>> lbs =
126// gurobi->GetDoubleAttrArray(GRB_DBL_ATTR_LB, num_vars);
127// An overload to write the result into an absl::Span is also provided.
128//
129// WARNING: as with the Gurobi C API, attributes cannot be read immediately
130// after they have been set. You need to call UpdateModel() (which is called by
131// Optimize()) before reading the model back. E.g.
132// std::unique_ptr<Gurobi> gurobi = Gurobi::New().value();
133// CHECK_OK(gurobi->AddVars({1, 1}, {0, 0}, {1, 1},
134// {GRB_INTEGER, GRB_INTEGER}, {"x", "y"}));
135// int num_vars = gurobi->GetIntAttr(GRB_INT_ATTR_NUMVARS).value(); // Is 0.
136// CHECK_OK(gurobi->UpdateModel());
137// num_vars = gurobi->GetIntAttr(GRB_INT_ATTR_NUMVARS).value(); // Is now 2.
138// Calls to UpdateModel() are expensive and should be minimized.
139//
141// Parameters
143//
144// Parameters are associated directly with Gurobi rather than a GRBenv as in the
145// C API. Parameters have three types: int, double and string. You can get and
146// set them by their C API names, e.g.
147// std::unique_ptr<Gurobi> gurobi = Gurobi::New().value();
148// gurobi->SetIntParam(GRB_INT_PAR_LOGTOCONSOLE, 1);
149// gurobi->GetIntParam(GRB_INT_PAR_LOGTOCONSOLE); // Returns 1.
150// Unlike attributes, values can be read immediately, no call to UpdateModel()
151// is required.
152class Gurobi {
153 public:
154 // A sparse matrix in compressed sparse column (CSC) format. E.g.
155 // [[2, 0, 4],
156 // [8, 6, 0]]
157 // Would be {.begins={0, 2, 3}, .inds={0, 1, 1, 0}, .vals={2, 8, 6, 4}}
158 struct SparseMat {
159 // Has size equal to the number of columns, the index in inds where this
160 // column begins.
161 std::vector<int> begins;
162
163 // Has size equal to the number of nonzeros in the matrix, the row for this
164 // entry.
165 std::vector<int> inds;
166
167 // Has size equal to the number of nonzeros in the matrix, the value for
168 // this entry.
169 std::vector<double> vals;
170 };
171
172 // The argument of Gurobi callbacks, allows you to read callback specific
173 // data and send information back to the solver.
175 public:
176 // For internal use only.
177 CallbackContext(Gurobi* gurobi, void* cb_data, int where);
178
179 // The current event of the callback, see Callback Codes in Gurobi docs.
180 int where() const { return where_; }
181 Gurobi* gurobi() const { return gurobi_; }
182
183 // Calls GRBcbget() on "what" with result type int, see Callback Codes in
184 // Gurobi docs for values of "what".
185 absl::StatusOr<int> CbGetInt(int what) const;
186
187 // Calls GRBcbget() on "what" with result type double, see Callback Codes in
188 // Gurobi docs for values of "what".
189 absl::StatusOr<double> CbGetDouble(int what) const;
190
191 // Calls GRBcbget() on "what" with result type double*, see Callback Codes
192 // in Gurobi docs for values of "what".
193 //
194 // The user is responsible for ensuring that result is large enough to hold
195 // the result.
196 absl::Status CbGetDoubleArray(int what, absl::Span<double> result) const;
197
198 // Calls GRBcbget() where what=MSG_STRING (call only at where=MESSAGE).
199 absl::StatusOr<std::string> CbGetMessage() const;
200
201 // Calls GRBcbcut().
202 absl::Status CbCut(absl::Span<const int> cutind,
203 absl::Span<const double> cutval, char cutsense,
204 double cutrhs) const;
205
206 // Calls GRBcblazy().
207 absl::Status CbLazy(absl::Span<const int> lazyind,
208 absl::Span<const double> lazyval, char lazysense,
209 double lazyrhs) const;
210
211 // Calls GRBcbsolution().
212 absl::StatusOr<double> CbSolution(absl::Span<const double> solution) const;
213
214 private:
215 Gurobi* const gurobi_;
216 void* const cb_data_;
217 const int where_;
218 };
219
220 // Invoked regularly by Gurobi while solving if provided as an argument to
221 // Gurobi::Optimize(). If the user returns a status error in the callback:
222 // * Termination of the solve is requested.
223 // * The error is propagated to the return value of Gurobi::Optimize().
224 // * The callback will not be invoked again.
225 using Callback = std::function<absl::Status(const CallbackContext&)>;
226
227 // Creates a new Gurobi, taking ownership of master_env if provided (if no
228 // environment is given, a new one is created internally from the license
229 // file).
230 static absl::StatusOr<std::unique_ptr<Gurobi>> New(
231 GRBenvUniquePtr master_env = nullptr);
232
233 // Creates a new Gurobi using an existing GRBenv, where master_env cannot be
234 // nullptr. Unlike Gurobi::New(), the returned Gurobi will not clean up the
235 // master environment on destruction.
236 //
237 // A GurobiEnv can be shared between models with the following restrictions:
238 // - Environments are not thread-safe (so use one thread or mutual exclusion
239 // for Gurobi::New()).
240 // - The master environment must outlive each Gurobi instance.
241 // - Every "master" environment counts as a "use" of a Gurobi License.
242 // Depending on your license type, you may need to share to run concurrent
243 // solves in the same process.
244 static absl::StatusOr<std::unique_ptr<Gurobi>> NewWithSharedMasterEnv(
245 GRBenv* master_env);
246
247 ~Gurobi();
248
250 // Model Building
252
253 // Calls GRBaddvars() to add variables to the model.
254 //
255 // Requirements:
256 // * lb, ub and vtype must have size equal to the number of new variables.
257 // * obj should either:
258 // - have size equal to the number of new variables,
259 // - be empty (all new variables have objective coefficient 0).
260 // * names should either:
261 // - have size equal to the number of new variables,
262 // - be empty (all new variables have name "").
263 absl::Status AddVars(absl::Span<const double> obj,
264 absl::Span<const double> lb, absl::Span<const double> ub,
265 absl::Span<const char> vtype,
266 absl::Span<const std::string> names);
267
268 // Calls GRBaddvars() to add variables and linear constraint columns to the
269 // model.
270 //
271 // The new linear constraint matrix columns are given in CSC format (see
272 // SparseMat above for an example).
273 //
274 // Requirements:
275 // * lb, ub and vtype must have size equal to the number of new variables.
276 // * obj should either:
277 // - have size equal to the number of new variables,
278 // - be empty (all new variables have objective coefficient 0).
279 // * names should either:
280 // - have size equal to the number of new variables,
281 // - be empty (all new variables have name "").
282 // * vbegin should have size equal to the number of new variables.
283 // * vind and vsize should have size equal to the number of new nonzeros in
284 // the linear constraint matrix.
285 // Note: vbegin, vind and vval can all be empty if you do not want to modify
286 // the constraint matrix, this is equivalent to the simpler overload above.
287 absl::Status AddVars(absl::Span<const int> vbegin, absl::Span<const int> vind,
288 absl::Span<const double> vval,
289 absl::Span<const double> obj,
290 absl::Span<const double> lb, absl::Span<const double> ub,
291 absl::Span<const char> vtype,
292 absl::Span<const std::string> names);
293
294 // Calls GRBdelvars().
295 absl::Status DelVars(absl::Span<const int> ind);
296
297 // Calls GRBaddconstrs().
298 //
299 // Requirements:
300 // * sense and rhs must have size equal to the number of new constraints.
301 // * names should either:
302 // - have size equal to the number of new constraints,
303 // - be empty (all new constraints have name "").
304 absl::Status AddConstrs(absl::Span<const char> sense,
305 absl::Span<const double> rhs,
306 absl::Span<const std::string> names);
307
308 // Calls GRBdelconstrs().
309 absl::Status DelConstrs(absl::Span<const int> ind);
310
311 // Calls GRBchgcoeffs().
312 //
313 // Requirements:
314 // * cind, vind, and val have size equal to the number of changed constraint
315 // matrix entries.
316 absl::Status ChgCoeffs(absl::Span<const int> cind, absl::Span<const int> vind,
317 absl::Span<const double> val);
318
319 // Calls GRBaddqpterms().
320 //
321 // Requirements:
322 // * qrow, qcol, and qval have size equal to the number of new quadratic
323 // objective terms.
324 absl::Status AddQpTerms(absl::Span<const int> qrow,
325 absl::Span<const int> qcol,
326 absl::Span<const double> qval);
327
328 // Calls GRBdelq().
329 //
330 // Deletes all quadratic objective coefficients.
331 absl::Status DelQ();
332
334 // Linear constraint matrix queries.
336
337 // Calls GRBgetvars().
338 //
339 // The number of nonzeros in the constraint matrix for the num_vars columns
340 // starting with first_var.
341 //
342 // Warning: will not reflect pending modifications, call UpdateModel() or
343 // Optimize() first.
344 absl::StatusOr<int> GetNnz(int first_var, int num_vars);
345
346 // Calls GRBgetvars().
347 //
348 // Write the nonzeros of the constraint matrix for the num_vars columns
349 // starting with first_var out in CSC format to (vbegin, vind, vval).
350 //
351 // The user is responsible for ensuring that the output Spans are exactly
352 // the correct size. See the other GetVars() overload for a simpler version.
353 //
354 // Warning: will not reflect pending modifications, call UpdateModel() or
355 // Optimize() first.
356 absl::Status GetVars(absl::Span<int> vbegin, absl::Span<int> vind,
357 absl::Span<double> vval, int first_var, int num_vars);
358
359 // Calls GRBgetvars().
360 //
361 // Returns the nonzeros of the constraint matrix for the num_vars columns
362 // starting with first_var out in CSC format.
363 //
364 // Warning: will not reflect pending modifications, call UpdateModel() or
365 // Optimize() first.
366 absl::StatusOr<SparseMat> GetVars(int first_var, int num_vars);
367
369 // Solving
371
372 // Calls GRBupdatemodel().
373 absl::Status UpdateModel();
374
375 // Calls GRBoptimize().
376 //
377 // The callback, if specified, is set before solving and cleared after.
378 absl::Status Optimize(Callback cb = nullptr);
379
380 // Calls GRBterminate().
381 void Terminate();
382
384 // Attributes
386
387 bool IsAttrAvailable(const char* name) const;
388
389 absl::StatusOr<int> GetIntAttr(const char* name) const;
390 absl::Status SetIntAttr(const char* attr_name, int value);
391
392 absl::StatusOr<double> GetDoubleAttr(const char* name) const;
393 absl::Status SetDoubleAttr(const char* attr_name, double value);
394
395 absl::StatusOr<std::string> GetStringAttr(const char* name) const;
396 absl::Status SetStringAttr(const char* attr_name, const std::string& value);
397
398 absl::Status GetIntAttrArray(const char* name,
399 absl::Span<int> attr_out) const;
400 absl::StatusOr<std::vector<int>> GetIntAttrArray(const char* name,
401 int len) const;
402 absl::Status SetIntAttrArray(const char* name,
403 absl::Span<const int> new_values);
404 absl::Status SetIntAttrList(const char* name, absl::Span<const int> ind,
405 absl::Span<const int> new_values);
406
407 absl::Status GetDoubleAttrArray(const char* name,
408 absl::Span<double> attr_out) const;
409 absl::StatusOr<std::vector<double>> GetDoubleAttrArray(const char* name,
410 int len) const;
411 absl::Status SetDoubleAttrArray(const char* name,
412 absl::Span<const double> new_values);
413 absl::Status SetDoubleAttrList(const char* name, absl::Span<const int> ind,
414 absl::Span<const double> new_values);
415
416 absl::Status GetCharAttrArray(const char* name,
417 absl::Span<char> attr_out) const;
418 absl::StatusOr<std::vector<char>> GetCharAttrArray(const char* name,
419 int len) const;
420 absl::Status SetCharAttrArray(const char* name,
421 absl::Span<const char> new_values);
422 absl::Status SetCharAttrList(const char* name, absl::Span<const int> ind,
423 absl::Span<const char> new_values);
424
426 // Parameters
428
429 // Calls GRBsetparam().
430 //
431 // Prefer the typed versions (e.g. SetIntParam()) defined below.
432 absl::Status SetParam(const char* name, const std::string& value);
433
434 // Calls GRBsetintparam().
435 absl::Status SetIntParam(const char* name, int value);
436
437 // Calls GRBsetdblparam().
438 absl::Status SetDoubleParam(const char* name, double value);
439
440 // Calls GRBsetstrparam().
441 absl::Status SetStringParam(const char* name, const std::string& value);
442
443 // Calls GRBgetintparam().
444 absl::StatusOr<int> GetIntParam(const char* name);
445
446 // Calls GRBgetdblparam().
447 absl::StatusOr<double> GetDoubleParam(const char* name);
448
449 // Calls GRBgetstrparam().
450 absl::StatusOr<std::string> GetStringParam(const char* name);
451
452 // Calls GRBresetparams().
453 absl::Status ResetParameters();
454
455 // Typically not needed.
456 GRBmodel* model() const { return gurobi_model_; }
457
458 private:
459 // optional_owned_master_env can be null, model and model_env cannot.
460 Gurobi(GRBenvUniquePtr optional_owned_master_env, GRBmodel* model,
461 GRBenv* model_env);
462 // optional_owned_master_env can be null, master_env cannot.
463 static absl::StatusOr<std::unique_ptr<Gurobi>> New(
464 GRBenvUniquePtr optional_owned_master_env, GRBenv* master_env);
465
466 absl::Status ToStatus(
467 int grb_err, absl::StatusCode code = absl::StatusCode::kInvalidArgument,
469
470 const GRBenvUniquePtr owned_master_env_;
471 // Invariant: Not null.
472 GRBmodel* const gurobi_model_;
473 // Invariant: Not null. This is the environment created by GRBnewmodel(), not
474 // the master environment used to create a GRBmodel, see class documentation.
475 GRBenv* const model_env_;
476};
477
478} // namespace operations_research::math_opt
479
480#endif // OR_TOOLS_MATH_OPT_SOLVERS_GUROBI_G_GUROBI_H_
static constexpr SourceLocation current()
absl::StatusOr< double > CbGetDouble(int what) const
Definition: g_gurobi.cc:535
absl::StatusOr< double > CbSolution(absl::Span< const double > solution) const
Definition: g_gurobi.cc:579
CallbackContext(Gurobi *gurobi, void *cb_data, int where)
Definition: g_gurobi.cc:524
absl::Status CbGetDoubleArray(int what, absl::Span< double > result) const
Definition: g_gurobi.cc:543
absl::Status CbCut(absl::Span< const int > cutind, absl::Span< const double > cutval, char cutsense, double cutrhs) const
Definition: g_gurobi.cc:559
absl::StatusOr< std::string > CbGetMessage() const
Definition: g_gurobi.cc:549
absl::StatusOr< int > CbGetInt(int what) const
Definition: g_gurobi.cc:528
absl::Status CbLazy(absl::Span< const int > lazyind, absl::Span< const double > lazyval, char lazysense, double lazyrhs) const
Definition: g_gurobi.cc:569
absl::Status GetVars(absl::Span< int > vbegin, absl::Span< int > vind, absl::Span< double > vval, int first_var, int num_vars)
Definition: g_gurobi.cc:278
absl::Status GetIntAttrArray(const char *name, absl::Span< int > attr_out) const
Definition: g_gurobi.cc:406
static absl::StatusOr< std::unique_ptr< Gurobi > > New(GRBenvUniquePtr master_env=nullptr)
Definition: g_gurobi.cc:103
absl::Status AddConstrs(absl::Span< const char > sense, absl::Span< const double > rhs, absl::Span< const std::string > names)
Definition: g_gurobi.cc:220
absl::StatusOr< double > GetDoubleParam(const char *name)
Definition: g_gurobi.cc:506
absl::Status Optimize(Callback cb=nullptr)
Definition: g_gurobi.cc:311
absl::Status ChgCoeffs(absl::Span< const int > cind, absl::Span< const int > vind, absl::Span< const double > val)
Definition: g_gurobi.cc:260
absl::StatusOr< int > GetIntParam(const char *name)
Definition: g_gurobi.cc:500
absl::Status SetDoubleAttr(const char *attr_name, double value)
Definition: g_gurobi.cc:383
absl::Status AddQpTerms(absl::Span< const int > qrow, absl::Span< const int > qcol, absl::Span< const double > qval)
Definition: g_gurobi.cc:247
absl::StatusOr< int > GetNnz(int first_var, int num_vars)
Definition: g_gurobi.cc:271
absl::Status SetDoubleParam(const char *name, double value)
Definition: g_gurobi.cc:490
std::function< absl::Status(const CallbackContext &)> Callback
Definition: g_gurobi.h:225
static absl::StatusOr< std::unique_ptr< Gurobi > > NewWithSharedMasterEnv(GRBenv *master_env)
Definition: g_gurobi.cc:97
absl::Status SetIntAttr(const char *attr_name, int value)
Definition: g_gurobi.cc:379
absl::StatusOr< std::string > GetStringParam(const char *name)
Definition: g_gurobi.cc:512
absl::Status GetCharAttrArray(const char *name, absl::Span< char > attr_out) const
Definition: g_gurobi.cc:436
absl::Status SetCharAttrArray(const char *name, absl::Span< const char > new_values)
Definition: g_gurobi.cc:400
absl::StatusOr< int > GetIntAttr(const char *name) const
Definition: g_gurobi.cc:347
absl::Status DelVars(absl::Span< const int > ind)
Definition: g_gurobi.cc:215
absl::StatusOr< std::string > GetStringAttr(const char *name) const
Definition: g_gurobi.cc:361
absl::Status SetIntAttrList(const char *name, absl::Span< const int > ind, absl::Span< const int > new_values)
Definition: g_gurobi.cc:451
absl::Status GetDoubleAttrArray(const char *name, absl::Span< double > attr_out) const
Definition: g_gurobi.cc:421
absl::Status SetDoubleAttrArray(const char *name, absl::Span< const double > new_values)
Definition: g_gurobi.cc:394
absl::Status SetParam(const char *name, const std::string &value)
Definition: g_gurobi.cc:481
bool IsAttrAvailable(const char *name) const
Definition: g_gurobi.cc:343
absl::Status SetDoubleAttrList(const char *name, absl::Span< const int > ind, absl::Span< const double > new_values)
Definition: g_gurobi.cc:461
absl::StatusOr< double > GetDoubleAttr(const char *name) const
Definition: g_gurobi.cc:354
absl::Status SetIntParam(const char *name, int value)
Definition: g_gurobi.cc:486
absl::Status SetIntAttrArray(const char *name, absl::Span< const int > new_values)
Definition: g_gurobi.cc:388
absl::Status SetStringParam(const char *name, const std::string &value)
Definition: g_gurobi.cc:495
absl::Status DelConstrs(absl::Span< const int > ind)
Definition: g_gurobi.cc:242
absl::Status SetStringAttr(const char *attr_name, const std::string &value)
Definition: g_gurobi.cc:374
absl::Status AddVars(absl::Span< const double > obj, absl::Span< const double > lb, absl::Span< const double > ub, absl::Span< const char > vtype, absl::Span< const std::string > names)
Definition: g_gurobi.cc:166
absl::Status SetCharAttrList(const char *name, absl::Span< const int > ind, absl::Span< const char > new_values)
Definition: g_gurobi.cc:471
const std::string name
int64_t value
struct _GRBenv GRBenv
Definition: environment.h:25
struct _GRBmodel GRBmodel
Definition: environment.h:24
absl::StatusOr< GRBenvUniquePtr > GurobiNewMasterEnv(const std::optional< GurobiIsvKey > &isv_key)
Definition: g_gurobi.cc:66
std::unique_ptr< GRBenv, GurobiFreeEnv > GRBenvUniquePtr
Definition: g_gurobi.h:67
void operator()(GRBenv *const env) const
Definition: g_gurobi.cc:60