Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
environment.cc
Go to the documentation of this file.
1// Copyright 2010-2024 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
15
16#include <mutex>
17#include <string>
18
19#include "absl/flags/flag.h"
20#include "absl/status/status.h"
21#include "absl/status/statusor.h"
22#include "absl/strings/match.h"
23#include "absl/strings/str_cat.h"
24#include "absl/strings/str_format.h"
25#include "absl/strings/str_join.h"
26#include "absl/synchronization/mutex.h"
27#include "ortools/base/file.h"
30
31namespace operations_research {
32
34 absl::StatusOr<GRBenv*> status = GetGurobiEnv();
35 if (!status.ok() || status.value() == nullptr) {
36 LOG(WARNING) << status.status();
37 return false;
38 }
39
40 GRBfreeenv(status.value());
41
42 return true;
43}
44
45// This was generated with the parse_header.py script.
46// See the comment at the top of the script.
47
48// This is the 'define' section.
49std::function<int(GRBenv**, const char*, const char*, const char*, int,
50 const char*)>
51 GRBisqp = nullptr;
52std::function<int(GRBmodel* model, const char* attrname)> GRBisattravailable =
53 nullptr;
54std::function<int(GRBmodel* model, const char* attrname, int* valueP)>
55 GRBgetintattr = nullptr;
56std::function<int(GRBmodel* model, const char* attrname, int newvalue)>
57 GRBsetintattr = nullptr;
58std::function<int(GRBmodel* model, const char* attrname, int element,
59 int* valueP)>
61std::function<int(GRBmodel* model, const char* attrname, int element,
62 int newvalue)>
64std::function<int(GRBmodel* model, const char* attrname, int first, int len,
65 int* values)>
67std::function<int(GRBmodel* model, const char* attrname, int first, int len,
68 int* newvalues)>
70std::function<int(GRBmodel* model, const char* attrname, int len, int* ind,
71 int* newvalues)>
73std::function<int(GRBmodel* model, const char* attrname, int element,
74 char* valueP)>
76std::function<int(GRBmodel* model, const char* attrname, int element,
77 char newvalue)>
79std::function<int(GRBmodel* model, const char* attrname, int first, int len,
80 char* values)>
82std::function<int(GRBmodel* model, const char* attrname, int first, int len,
83 char* newvalues)>
85std::function<int(GRBmodel* model, const char* attrname, int len, int* ind,
86 char* newvalues)>
88std::function<int(GRBmodel* model, const char* attrname, double* valueP)>
89 GRBgetdblattr = nullptr;
90std::function<int(GRBmodel* model, const char* attrname, double newvalue)>
91 GRBsetdblattr = nullptr;
92std::function<int(GRBmodel* model, const char* attrname, int element,
93 double* valueP)>
95std::function<int(GRBmodel* model, const char* attrname, int element,
96 double newvalue)>
98std::function<int(GRBmodel* model, const char* attrname, int first, int len,
99 double* values)>
101std::function<int(GRBmodel* model, const char* attrname, int first, int len,
102 double* newvalues)>
104std::function<int(GRBmodel* model, const char* attrname, int len, int* ind,
105 double* newvalues)>
107std::function<int(GRBmodel* model, const char* attrname, char** valueP)>
108 GRBgetstrattr = nullptr;
109std::function<int(GRBmodel* model, const char* attrname, const char* newvalue)>
110 GRBsetstrattr = nullptr;
111std::function<int(GRBmodel* model, int(GUROBI_STDCALL* cb)(CB_ARGS),
112 void* usrdata)>
114std::function<int(void* cbdata, int where, int what, void* resultP)> GRBcbget =
115 nullptr;
116std::function<int(void* cbdata, const double* solution, double* objvalP)>
117 GRBcbsolution = nullptr;
118std::function<int(void* cbdata, int cutlen, const int* cutind,
119 const double* cutval, char cutsense, double cutrhs)>
120 GRBcbcut = nullptr;
121std::function<int(void* cbdata, int lazylen, const int* lazyind,
122 const double* lazyval, char lazysense, double lazyrhs)>
123 GRBcblazy = nullptr;
124std::function<int(GRBmodel* model, int* numnzP, int* vbeg, int* vind,
125 double* vval, int start, int len)>
126 GRBgetvars = nullptr;
127std::function<int(GRBmodel* model)> GRBoptimize = nullptr;
128std::function<int(GRBmodel* model)> GRBcomputeIIS = nullptr;
129std::function<int(GRBmodel* model, const char* filename)> GRBwrite = nullptr;
130std::function<int(GRBenv* env, GRBmodel** modelP, const char* Pname,
131 int numvars, double* obj, double* lb, double* ub, char* vtype,
132 char** varnames)>
133 GRBnewmodel = nullptr;
134std::function<int(GRBmodel* model, int numnz, int* vind, double* vval,
135 double obj, double lb, double ub, char vtype,
136 const char* varname)>
137 GRBaddvar = nullptr;
138std::function<int(GRBmodel* model, int numvars, int numnz, int* vbeg, int* vind,
139 double* vval, double* obj, double* lb, double* ub,
140 char* vtype, char** varnames)>
141 GRBaddvars = nullptr;
142std::function<int(GRBmodel* model, int numnz, int* cind, double* cval,
143 char sense, double rhs, const char* constrname)>
144 GRBaddconstr = nullptr;
145std::function<int(GRBmodel* model, int numconstrs, int numnz, int* cbeg,
146 int* cind, double* cval, char* sense, double* rhs,
147 char** constrnames)>
148 GRBaddconstrs = nullptr;
149std::function<int(GRBmodel* model, int numnz, int* cind, double* cval,
150 double lower, double upper, const char* constrname)>
152std::function<int(GRBmodel* model, int numsos, int nummembers, int* types,
153 int* beg, int* ind, double* weight)>
154 GRBaddsos = nullptr;
155std::function<int(GRBmodel* model, const char* name, int resvar, int nvars,
156 const int* vars, double constant)>
158std::function<int(GRBmodel* model, const char* name, int resvar, int nvars,
159 const int* vars, double constant)>
161std::function<int(GRBmodel* model, const char* name, int resvar, int argvar)>
163std::function<int(GRBmodel* model, const char* name, int resvar, int nvars,
164 const int* vars)>
166std::function<int(GRBmodel* model, const char* name, int resvar, int nvars,
167 const int* vars)>
169std::function<int(GRBmodel* model, const char* name, int binvar, int binval,
170 int nvars, const int* vars, const double* vals, char sense,
171 double rhs)>
173std::function<int(GRBmodel* model, int numlnz, int* lind, double* lval,
174 int numqnz, int* qrow, int* qcol, double* qval, char sense,
175 double rhs, const char* QCname)>
176 GRBaddqconstr = nullptr;
177std::function<int(GRBmodel* model, int numqnz, int* qrow, int* qcol,
178 double* qval)>
179 GRBaddqpterms = nullptr;
180std::function<int(GRBmodel* model, int len, int* ind)> GRBdelvars = nullptr;
181std::function<int(GRBmodel* model, int len, int* ind)> GRBdelconstrs = nullptr;
182std::function<int(GRBmodel* model, int len, int* ind)> GRBdelsos = nullptr;
183std::function<int(GRBmodel* model, int len, int* ind)> GRBdelgenconstrs =
184 nullptr;
185std::function<int(GRBmodel* model, int len, int* ind)> GRBdelqconstrs = nullptr;
186std::function<int(GRBmodel* model)> GRBdelq = nullptr;
187std::function<int(GRBmodel* model, int cnt, int* cind, int* vind, double* val)>
188 GRBchgcoeffs = nullptr;
189std::function<int(GRBmodel* model)> GRBupdatemodel = nullptr;
190std::function<int(GRBmodel* model)> GRBfreemodel = nullptr;
191std::function<void(GRBmodel* model)> GRBterminate = nullptr;
192std::function<int(GRBmodel* model, int index, int priority, double weight,
193 double abstol, double reltol, const char* name,
194 double constant, int lnz, int* lind, double* lval)>
196std::function<int(GRBenv* env, const char* paramname, int* valueP)>
197 GRBgetintparam = nullptr;
198std::function<int(GRBenv* env, const char* paramname, double* valueP)>
199 GRBgetdblparam = nullptr;
200std::function<int(GRBenv* env, const char* paramname, char* valueP)>
201 GRBgetstrparam = nullptr;
202std::function<int(GRBenv* env, const char* paramname, int* valueP, int* minP,
203 int* maxP, int* defP)>
205std::function<int(GRBenv* env, const char* paramname, double* valueP,
206 double* minP, double* maxP, double* defP)>
208std::function<int(GRBenv* env, const char* paramname, char* valueP, char* defP)>
210std::function<int(GRBenv* env, const char* paramname)> GRBgetparamtype =
211 nullptr;
212std::function<int(GRBenv* env, int i, char** paramnameP)> GRBgetparamname =
213 nullptr;
214std::function<int(GRBenv* env, const char* paramname, const char* value)>
215 GRBsetparam = nullptr;
216std::function<int(GRBenv* env, const char* paramname, int value)>
217 GRBsetintparam = nullptr;
218std::function<int(GRBenv* env, const char* paramname, double value)>
219 GRBsetdblparam = nullptr;
220std::function<int(GRBenv* env, const char* paramname, const char* value)>
221 GRBsetstrparam = nullptr;
222std::function<int(GRBenv* env)> GRBresetparams = nullptr;
223std::function<int(GRBenv* dest, GRBenv* src)> GRBcopyparams = nullptr;
224std::function<int(GRBenv* env)> GRBgetnumparams = nullptr;
225std::function<int(GRBenv** envP)> GRBemptyenv = nullptr;
226std::function<int(GRBenv** envP, const char* logfilename)> GRBloadenv = nullptr;
227std::function<int(GRBenv* env)> GRBstartenv = nullptr;
228std::function<GRBenv*(GRBmodel* model)> GRBgetenv = nullptr;
229std::function<void(GRBenv* env)> GRBfreeenv = nullptr;
230std::function<const char*(GRBenv* env)> GRBgeterrormsg = nullptr;
231std::function<void(int* majorP, int* minorP, int* technicalP)> GRBversion =
232 nullptr;
233std::function<char*(void)> GRBplatform = nullptr;
234
235void LoadGurobiFunctions(DynamicLibrary* gurobi_dynamic_library) {
236 // This was generated with the parse_header.py script.
237 // See the comment at the top of the script.
238
239 // This is the 'assign' section.
240 gurobi_dynamic_library->GetFunction(&GRBisqp, "GRBisqp");
241 gurobi_dynamic_library->GetFunction(&GRBisattravailable,
242 "GRBisattravailable");
243 gurobi_dynamic_library->GetFunction(&GRBgetintattr, "GRBgetintattr");
244 gurobi_dynamic_library->GetFunction(&GRBsetintattr, "GRBsetintattr");
245 gurobi_dynamic_library->GetFunction(&GRBgetintattrelement,
246 "GRBgetintattrelement");
247 gurobi_dynamic_library->GetFunction(&GRBsetintattrelement,
248 "GRBsetintattrelement");
249 gurobi_dynamic_library->GetFunction(&GRBgetintattrarray,
250 "GRBgetintattrarray");
251 gurobi_dynamic_library->GetFunction(&GRBsetintattrarray,
252 "GRBsetintattrarray");
253 gurobi_dynamic_library->GetFunction(&GRBsetintattrlist, "GRBsetintattrlist");
254 gurobi_dynamic_library->GetFunction(&GRBgetcharattrelement,
255 "GRBgetcharattrelement");
256 gurobi_dynamic_library->GetFunction(&GRBsetcharattrelement,
257 "GRBsetcharattrelement");
258 gurobi_dynamic_library->GetFunction(&GRBgetcharattrarray,
259 "GRBgetcharattrarray");
260 gurobi_dynamic_library->GetFunction(&GRBsetcharattrarray,
261 "GRBsetcharattrarray");
262 gurobi_dynamic_library->GetFunction(&GRBsetcharattrlist,
263 "GRBsetcharattrlist");
264 gurobi_dynamic_library->GetFunction(&GRBgetdblattr, "GRBgetdblattr");
265 gurobi_dynamic_library->GetFunction(&GRBsetdblattr, "GRBsetdblattr");
266 gurobi_dynamic_library->GetFunction(&GRBgetdblattrelement,
267 "GRBgetdblattrelement");
268 gurobi_dynamic_library->GetFunction(&GRBsetdblattrelement,
269 "GRBsetdblattrelement");
270 gurobi_dynamic_library->GetFunction(&GRBgetdblattrarray,
271 "GRBgetdblattrarray");
272 gurobi_dynamic_library->GetFunction(&GRBsetdblattrarray,
273 "GRBsetdblattrarray");
274 gurobi_dynamic_library->GetFunction(&GRBsetdblattrlist, "GRBsetdblattrlist");
275 gurobi_dynamic_library->GetFunction(&GRBgetstrattr, "GRBgetstrattr");
276 gurobi_dynamic_library->GetFunction(&GRBsetstrattr, "GRBsetstrattr");
277 gurobi_dynamic_library->GetFunction(&GRBsetcallbackfunc,
278 "GRBsetcallbackfunc");
279 gurobi_dynamic_library->GetFunction(&GRBcbget, "GRBcbget");
280 gurobi_dynamic_library->GetFunction(&GRBcbsolution, "GRBcbsolution");
281 gurobi_dynamic_library->GetFunction(&GRBcbcut, "GRBcbcut");
282 gurobi_dynamic_library->GetFunction(&GRBcblazy, "GRBcblazy");
283 gurobi_dynamic_library->GetFunction(&GRBgetvars, "GRBgetvars");
284 gurobi_dynamic_library->GetFunction(&GRBoptimize, "GRBoptimize");
285 gurobi_dynamic_library->GetFunction(&GRBcomputeIIS, "GRBcomputeIIS");
286 gurobi_dynamic_library->GetFunction(&GRBwrite, "GRBwrite");
287 gurobi_dynamic_library->GetFunction(&GRBnewmodel, "GRBnewmodel");
288 gurobi_dynamic_library->GetFunction(&GRBaddvar, "GRBaddvar");
289 gurobi_dynamic_library->GetFunction(&GRBaddvars, "GRBaddvars");
290 gurobi_dynamic_library->GetFunction(&GRBaddconstr, "GRBaddconstr");
291 gurobi_dynamic_library->GetFunction(&GRBaddconstrs, "GRBaddconstrs");
292 gurobi_dynamic_library->GetFunction(&GRBaddrangeconstr, "GRBaddrangeconstr");
293 gurobi_dynamic_library->GetFunction(&GRBaddsos, "GRBaddsos");
294 gurobi_dynamic_library->GetFunction(&GRBaddgenconstrMax,
295 "GRBaddgenconstrMax");
296 gurobi_dynamic_library->GetFunction(&GRBaddgenconstrMin,
297 "GRBaddgenconstrMin");
298 gurobi_dynamic_library->GetFunction(&GRBaddgenconstrAbs,
299 "GRBaddgenconstrAbs");
300 gurobi_dynamic_library->GetFunction(&GRBaddgenconstrAnd,
301 "GRBaddgenconstrAnd");
302 gurobi_dynamic_library->GetFunction(&GRBaddgenconstrOr, "GRBaddgenconstrOr");
303 gurobi_dynamic_library->GetFunction(&GRBaddgenconstrIndicator,
304 "GRBaddgenconstrIndicator");
305 gurobi_dynamic_library->GetFunction(&GRBaddqconstr, "GRBaddqconstr");
306 gurobi_dynamic_library->GetFunction(&GRBaddqpterms, "GRBaddqpterms");
307 gurobi_dynamic_library->GetFunction(&GRBdelvars, "GRBdelvars");
308 gurobi_dynamic_library->GetFunction(&GRBdelconstrs, "GRBdelconstrs");
309 gurobi_dynamic_library->GetFunction(&GRBdelsos, "GRBdelsos");
310 gurobi_dynamic_library->GetFunction(&GRBdelgenconstrs, "GRBdelgenconstrs");
311 gurobi_dynamic_library->GetFunction(&GRBdelqconstrs, "GRBdelqconstrs");
312 gurobi_dynamic_library->GetFunction(&GRBdelq, "GRBdelq");
313 gurobi_dynamic_library->GetFunction(&GRBchgcoeffs, "GRBchgcoeffs");
314 gurobi_dynamic_library->GetFunction(&GRBupdatemodel, "GRBupdatemodel");
315 gurobi_dynamic_library->GetFunction(&GRBfreemodel, "GRBfreemodel");
316 gurobi_dynamic_library->GetFunction(&GRBterminate, "GRBterminate");
317 gurobi_dynamic_library->GetFunction(&GRBsetobjectiven, "GRBsetobjectiven");
318 gurobi_dynamic_library->GetFunction(&GRBgetintparam, "GRBgetintparam");
319 gurobi_dynamic_library->GetFunction(&GRBgetdblparam, "GRBgetdblparam");
320 gurobi_dynamic_library->GetFunction(&GRBgetstrparam, "GRBgetstrparam");
321 gurobi_dynamic_library->GetFunction(&GRBsetparam, "GRBsetparam");
322 gurobi_dynamic_library->GetFunction(&GRBsetintparam, "GRBsetintparam");
323 gurobi_dynamic_library->GetFunction(&GRBsetdblparam, "GRBsetdblparam");
324 gurobi_dynamic_library->GetFunction(&GRBsetstrparam, "GRBsetstrparam");
325 gurobi_dynamic_library->GetFunction(&GRBresetparams, "GRBresetparams");
326 gurobi_dynamic_library->GetFunction(&GRBcopyparams, "GRBcopyparams");
327 gurobi_dynamic_library->GetFunction(&GRBloadenv, "GRBloadenv");
328 gurobi_dynamic_library->GetFunction(&GRBstartenv, "GRBstartenv");
329 gurobi_dynamic_library->GetFunction(&GRBemptyenv, "GRBemptyenv");
330 gurobi_dynamic_library->GetFunction(&GRBgetnumparams, "GRBgetnumparams");
331 gurobi_dynamic_library->GetFunction(&GRBgetparamname, "GRBgetparamname");
332 gurobi_dynamic_library->GetFunction(&GRBgetparamtype, "GRBgetparamtype");
333 gurobi_dynamic_library->GetFunction(&GRBgetintparaminfo,
334 "GRBgetintparaminfo");
335 gurobi_dynamic_library->GetFunction(&GRBgetdblparaminfo,
336 "GRBgetdblparaminfo");
337 gurobi_dynamic_library->GetFunction(&GRBgetstrparaminfo,
338 "GRBgetstrparaminfo");
339 gurobi_dynamic_library->GetFunction(&GRBgetenv, "GRBgetenv");
340 gurobi_dynamic_library->GetFunction(&GRBfreeenv, "GRBfreeenv");
341 gurobi_dynamic_library->GetFunction(&GRBgeterrormsg, "GRBgeterrormsg");
342 gurobi_dynamic_library->GetFunction(&GRBversion, "GRBversion");
343 gurobi_dynamic_library->GetFunction(&GRBplatform, "GRBplatform");
344}
345
346std::vector<std::string> GurobiDynamicLibraryPotentialPaths() {
347 std::vector<std::string> potential_paths;
348 const std::vector<std::string> kGurobiVersions = {
349 "1103", "1102", "1101", "1100", "1003", "1002", "1001", "1000", "952", "951",
350 "950", "911", "910", "903", "902", "811", "801", "752"};
351 potential_paths.reserve(kGurobiVersions.size() * 3);
352
353 // Look for libraries pointed by GUROBI_HOME first.
354 const char* gurobi_home_from_env = getenv("GUROBI_HOME");
355 if (gurobi_home_from_env != nullptr) {
356 for (const std::string& version : kGurobiVersions) {
357 const std::string lib = version.substr(0, version.size() - 1);
358#if defined(_MSC_VER) // Windows
359 potential_paths.push_back(
360 absl::StrCat(gurobi_home_from_env, "\\bin\\gurobi", lib, ".dll"));
361#elif defined(__APPLE__) // OS X
362 potential_paths.push_back(
363 absl::StrCat(gurobi_home_from_env, "/lib/libgurobi", lib, ".dylib"));
364#elif defined(__GNUC__) // Linux
365 potential_paths.push_back(
366 absl::StrCat(gurobi_home_from_env, "/lib/libgurobi", lib, ".so"));
367 potential_paths.push_back(
368 absl::StrCat(gurobi_home_from_env, "/lib64/libgurobi", lib, ".so"));
369#else
370 LOG(ERROR) << "OS Not recognized by gurobi/environment.cc."
371 << " You won't be able to use Gurobi.";
372#endif
373 }
374 }
375
376 // Search for canonical places.
377 for (const std::string& version : kGurobiVersions) {
378 const std::string lib = version.substr(0, version.size() - 1);
379#if defined(_MSC_VER) // Windows
380 potential_paths.push_back(absl::StrCat("C:\\Program Files\\gurobi", version,
381 "\\win64\\bin\\gurobi", lib,
382 ".dll"));
383 potential_paths.push_back(absl::StrCat(
384 "C:\\gurobi", version, "\\win64\\bin\\gurobi", lib, ".dll"));
385 potential_paths.push_back(absl::StrCat("gurobi", lib, ".dll"));
386#elif defined(__APPLE__) // OS X
387 potential_paths.push_back(absl::StrCat(
388 "/Library/gurobi", version, "/mac64/lib/libgurobi", lib, ".dylib"));
389 potential_paths.push_back(absl::StrCat("/Library/gurobi", version,
390 "/macos_universal2/lib/libgurobi",
391 lib, ".dylib"));
392#elif defined(__GNUC__) // Linux
393 potential_paths.push_back(absl::StrCat(
394 "/opt/gurobi", version, "/linux64/lib/libgurobi", lib, ".so"));
395 potential_paths.push_back(absl::StrCat(
396 "/opt/gurobi", version, "/linux64/lib64/libgurobi", lib, ".so"));
397 potential_paths.push_back(
398 absl::StrCat("/opt/gurobi/linux64/lib/libgurobi", lib, ".so"));
399 potential_paths.push_back(
400 absl::StrCat("/opt/gurobi/linux64/lib64/libgurobi", lib, ".so"));
401#else
402 LOG(ERROR) << "OS Not recognized by gurobi/environment.cc."
403 << " You won't be able to use Gurobi.";
404#endif
405 }
406
407#if defined(__GNUC__) // path in linux64 gurobi/optimizer docker image.
408 for (const std::string& version :
409 {"11.0.3", "11.0.2", "11.0.1", "11.0.0", "10.0.3", "10.0.2", "10.0.1", "10.0.0",
410 "9.5.2", "9.5.1", "9.5.0"}) {
411 potential_paths.push_back(
412 absl::StrCat("/opt/gurobi/linux64/lib/libgurobi.so.", version));
413 }
414#endif
415 return potential_paths;
416}
417
419 std::vector<std::string> potential_paths) {
420 static std::once_flag gurobi_loading_done;
421 static absl::Status gurobi_load_status;
422 static DynamicLibrary gurobi_library;
423 static absl::Mutex mutex;
424
425 absl::MutexLock lock(&mutex);
426
427 std::call_once(gurobi_loading_done, [&potential_paths]() {
428 const std::vector<std::string> canonical_paths =
430 potential_paths.insert(potential_paths.end(), canonical_paths.begin(),
431 canonical_paths.end());
432 for (const std::string& path : potential_paths) {
433 if (gurobi_library.TryToLoad(path)) {
434 LOG(INFO) << "Found the Gurobi library in '" << path << ".";
435 break;
436 }
437 }
438
439 if (gurobi_library.LibraryIsLoaded()) {
440 LoadGurobiFunctions(&gurobi_library);
441 gurobi_load_status = absl::OkStatus();
442 } else {
443 gurobi_load_status = absl::NotFoundError(absl::StrCat(
444 "Could not find the Gurobi shared library. Looked in: [",
445 absl::StrJoin(potential_paths, "', '"),
446 "]. If you know where it"
447 " is, pass the full path to 'LoadGurobiDynamicLibrary()'."));
448 }
449 });
450 return gurobi_load_status;
451}
452
453absl::StatusOr<GRBenv*> GetGurobiEnv() {
455
456 GRBenv* env = nullptr;
457
458 if (GRBloadenv(&env, nullptr) != 0 || env == nullptr) {
459 return absl::FailedPreconditionError(
460 absl::StrCat("Found the Gurobi shared library, but could not create "
461 "Gurobi environment: is Gurobi licensed on this machine?",
462 GRBgeterrormsg(env)));
463 }
464 return env;
465}
466
467} // namespace operations_research
#define RETURN_IF_ERROR(expr)
bool LibraryIsLoaded() const
std::function< T > GetFunction(const char *function_name)
bool TryToLoad(const std::string &library_name)
const std::string name
A name for logging purposes.
int64_t value
absl::Status status
Definition g_gurobi.cc:44
double lower
double upper
#define GUROBI_STDCALL
Definition environment.h:27
struct _GRBenv GRBenv
Definition environment.h:32
struct _GRBmodel GRBmodel
Definition environment.h:31
#define CB_ARGS
GRBmodel * model
int where
int index
double solution
In SWIG mode, we don't want anything besides these top-level includes.
std::function< int(GRBmodel *model, int numnz, int *cind, double *cval, char sense, double rhs, const char *constrname)> GRBaddconstr
std::function< void(GRBenv *env)> GRBfreeenv
std::function< int(GRBmodel *model, const char *attrname, double *valueP)> GRBgetdblattr
std::function< int(GRBmodel *model, const char *attrname, int first, int len, double *values)> GRBgetdblattrarray
std::function< int(GRBmodel *model, const char *attrname, int first, int len, int *values)> GRBgetintattrarray
std::function< int(GRBmodel *model, const char *attrname, double newvalue)> GRBsetdblattr
std::function< int(GRBmodel *model, int len, int *ind)> GRBdelsos
std::function< int(GRBmodel *model, int numvars, int numnz, int *vbeg, int *vind, double *vval, double *obj, double *lb, double *ub, char *vtype, char **varnames)> GRBaddvars
std::function< int(GRBmodel *model, int(GUROBI_STDCALL *cb)(CB_ARGS), void *usrdata)> GRBsetcallbackfunc
std::function< int(GRBenv *dest, GRBenv *src)> GRBcopyparams
std::function< int(GRBmodel *model, int *numnzP, int *vbeg, int *vind, double *vval, int start, int len)> GRBgetvars
std::function< int(GRBmodel *model, const char *attrname, int len, int *ind, int *newvalues)> GRBsetintattrlist
std::function< int(GRBmodel *model, int cnt, int *cind, int *vind, double *val)> GRBchgcoeffs
std::function< int(GRBmodel *model, const char *attrname, int first, int len, char *values)> GRBgetcharattrarray
std::function< int(void *cbdata, int cutlen, const int *cutind, const double *cutval, char cutsense, double cutrhs)> GRBcbcut
std::function< int(GRBenv *env, const char *paramname, double *valueP)> GRBgetdblparam
std::function< int(GRBmodel *model, int numlnz, int *lind, double *lval, int numqnz, int *qrow, int *qcol, double *qval, char sense, double rhs, const char *QCname)> GRBaddqconstr
std::function< int(GRBmodel *model, int len, int *ind)> GRBdelvars
std::function< int(GRBmodel *model, const char *attrname, int newvalue)> GRBsetintattr
std::function< int(GRBenv *env, const char *paramname, const char *value)> GRBsetparam
std::function< int(GRBmodel *model, const char *attrname, int element, int *valueP)> GRBgetintattrelement
std::function< int(GRBenv *env, GRBmodel **modelP, const char *Pname, int numvars, double *obj, double *lb, double *ub, char *vtype, char **varnames)> GRBnewmodel
std::function< int(GRBmodel *model, int numnz, int *vind, double *vval, double obj, double lb, double ub, char vtype, const char *varname)> GRBaddvar
std::function< int(GRBmodel *model, const char *attrname, int first, int len, int *newvalues)> GRBsetintattrarray
absl::Status LoadGurobiDynamicLibrary(std::vector< std::string > potential_paths)
std::function< int(GRBmodel *model)> GRBupdatemodel
std::function< void(int *majorP, int *minorP, int *technicalP)> GRBversion
std::function< GRBenv *(GRBmodel *model)> GRBgetenv
std::function< int(GRBmodel *model, const char *attrname, int len, int *ind, char *newvalues)> GRBsetcharattrlist
bool GurobiIsCorrectlyInstalled()
std::function< int(GRBenv *env, const char *paramname, char *valueP)> GRBgetstrparam
std::function< int(GRBmodel *model, const char *attrname, int element, double *valueP)> GRBgetdblattrelement
std::function< int(GRBmodel *model, const char *attrname, int first, int len, char *newvalues)> GRBsetcharattrarray
std::function< int(GRBmodel *model)> GRBfreemodel
std::function< int(GRBmodel *model, int len, int *ind)> GRBdelqconstrs
std::function< int(void *cbdata, int lazylen, const int *lazyind, const double *lazyval, char lazysense, double lazyrhs)> GRBcblazy
std::function< int(GRBmodel *model)> GRBcomputeIIS
void LoadGurobiFunctions(DynamicLibrary *gurobi_dynamic_library)
std::function< int(void *cbdata, int where, int what, void *resultP)> GRBcbget
std::function< int(GRBenv *env, const char *paramname, int value)> GRBsetintparam
std::function< int(GRBmodel *model, const char *attrname)> GRBisattravailable
std::function< int(GRBenv *env, const char *paramname, const char *value)> GRBsetstrparam
std::function< int(GRBenv *env, const char *paramname, char *valueP, char *defP)> GRBgetstrparaminfo
std::function< int(GRBmodel *model, const char *attrname, int first, int len, double *newvalues)> GRBsetdblattrarray
std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars, double constant)> GRBaddgenconstrMin
std::function< int(GRBmodel *model, int numnz, int *cind, double *cval, double lower, double upper, const char *constrname)> GRBaddrangeconstr
std::function< int(GRBmodel *model, const char *name, int binvar, int binval, int nvars, const int *vars, const double *vals, char sense, double rhs)> GRBaddgenconstrIndicator
std::function< int(GRBmodel *model, const char *attrname, int element, char newvalue)> GRBsetcharattrelement
std::function< int(GRBmodel *model, const char *attrname, int element, int newvalue)> GRBsetintattrelement
std::function< int(GRBenv *env)> GRBresetparams
std::function< int(GRBmodel *model, const char *attrname, const char *newvalue)> GRBsetstrattr
std::function< int(GRBmodel *model)> GRBoptimize
std::function< int(GRBenv **envP, const char *logfilename)> GRBloadenv
std::function< int(GRBmodel *model, int numqnz, int *qrow, int *qcol, double *qval)> GRBaddqpterms
std::function< int(GRBenv **, const char *, const char *, const char *, int, const char *)> GRBisqp
This is the 'define' section.
std::function< int(GRBenv **envP)> GRBemptyenv
std::function< int(GRBenv *env, const char *paramname)> GRBgetparamtype
std::function< int(GRBmodel *model, int len, int *ind)> GRBdelconstrs
std::function< int(GRBmodel *model, const char *name, int resvar, int argvar)> GRBaddgenconstrAbs
std::vector< std::string > GurobiDynamicLibraryPotentialPaths()
std::function< int(GRBenv *env, int i, char **paramnameP)> GRBgetparamname
std::function< int(GRBmodel *model, const char *attrname, int *valueP)> GRBgetintattr
std::function< int(GRBmodel *model, int len, int *ind)> GRBdelgenconstrs
std::function< int(GRBmodel *model, int index, int priority, double weight, double abstol, double reltol, const char *name, double constant, int lnz, int *lind, double *lval)> GRBsetobjectiven
std::function< const char *(GRBenv *env)> GRBgeterrormsg
absl::StatusOr< GRBenv * > GetGurobiEnv()
std::function< int(GRBmodel *model, const char *filename)> GRBwrite
std::function< int(GRBenv *env, const char *paramname, double *valueP, double *minP, double *maxP, double *defP)> GRBgetdblparaminfo
std::function< int(GRBenv *env, const char *paramname, int *valueP)> GRBgetintparam
std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars)> GRBaddgenconstrAnd
std::function< int(GRBenv *env)> GRBstartenv
std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars)> GRBaddgenconstrOr
std::function< int(GRBmodel *model, int numconstrs, int numnz, int *cbeg, int *cind, double *cval, char *sense, double *rhs, char **constrnames)> GRBaddconstrs
std::function< int(GRBmodel *model, const char *attrname, int len, int *ind, double *newvalues)> GRBsetdblattrlist
std::function< int(GRBmodel *model, const char *name, int resvar, int nvars, const int *vars, double constant)> GRBaddgenconstrMax
std::function< char *(void)> GRBplatform
std::function< int(GRBenv *env, const char *paramname, int *valueP, int *minP, int *maxP, int *defP)> GRBgetintparaminfo
std::function< int(GRBmodel *model, int numsos, int nummembers, int *types, int *beg, int *ind, double *weight)> GRBaddsos
std::function< int(GRBenv *env)> GRBgetnumparams
std::function< int(GRBmodel *model, const char *attrname, int element, char *valueP)> GRBgetcharattrelement
std::function< int(GRBmodel *model, const char *attrname, char **valueP)> GRBgetstrattr
std::function< int(GRBmodel *model)> GRBdelq
std::function< int(void *cbdata, const double *solution, double *objvalP)> GRBcbsolution
std::function< void(GRBmodel *model)> GRBterminate
std::function< int(GRBenv *env, const char *paramname, double value)> GRBsetdblparam
std::function< int(GRBmodel *model, const char *attrname, int element, double newvalue)> GRBsetdblattrelement
int64_t weight
Definition pack.cc:510
int64_t start