google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
11.1k stars 2.11k forks source link

Could not find function 'GRBsetlogfile' when using Gurobi 9.5.0 #3045

Closed gokhanceyhan closed 2 years ago

gokhanceyhan commented 2 years ago

What version of OR-Tools and what language are you using? Version: 9.2.9972 Language: Java

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi) Gurobi 9.5.0

What operating system (Linux, Windows, ...) and version? MacOS Monterey, 12.0.1

What did you do? Steps to reproduce the behavior:

  1. Add 'ortools-java' version 9.2.9972 from Maven repository to your pom.xml file
  2. Set 'GUROBI_HOME' to the installation folder for Gurobi 9.5.0
  3. Create a simple MIP and solve

What did you expect to see A regular run of Gurobi MIP solver

What did you see instead?

WARNING: Logging before InitGoogleLogging() is written to STDERR
I1229 11:00:06.678586     1 environment.cc:738] Found the Gurobi library in '/Library/gurobi950/macos_universal2/lib/libgurobi95.dylib.
F1229 11:00:06.678863     1 dynamic_library.h:68] Check failed: function_address != nullptr Error: could not find function GRBsetlogfile in /Library/gurobi950/macos_universal2/lib/libgurobi95.dylib

Make sure you include information that can help us debug (full error message, model Proto).

Anything else we should know about your project / environment

Mizux commented 2 years ago

Just found:

/* The following four routines are deprecated in Gurobi 2.0.
   Use the 'LogFile' parameter to control logging instead. */
int __stdcall
  GRBgetlogfile(GRBenv *env, FILE **logfileP);
int __stdcall
  GRBsetlogfile(GRBenv *env, FILE *logfile);

ref: https://users.cs.duke.edu/~ssintos/kRMS_SEA/Hist/gurobi_c.h

So maybe we should update our Gurobi interface https://github.com/google/or-tools/blob/2cb85b4eead4c38e1c54b48044f92087cf165bce/ortools/gurobi/environment.cc#L361-L362

https://github.com/google/or-tools/blob/2cb85b4eead4c38e1c54b48044f92087cf165bce/ortools/gurobi/environment.cc#L612-L613

lperron commented 2 years ago

To be clear, these have been removed in 9.5 ? If yes, provided we do not call them directly, yes, we should remove them.

Mizux commented 2 years ago

@lperron I didn't found any usage of it, continue to search...

[0]─[~/work/master/ortools]
[^u^]─mizux@nuc10i7 %grepc -rIin "GRB[gs]etlogfile" .
./gurobi/environment.h:640:extern std::function<int(GRBenv *env, FILE **logfileP)> GRBgetlogfile;
./gurobi/environment.h:641:extern std::function<int(GRBenv *env, FILE *logfile)> GRBsetlogfile;
./gurobi/environment.cc:361:std::function<int(GRBenv* env, FILE** logfileP)> GRBgetlogfile = nullptr;
./gurobi/environment.cc:362:std::function<int(GRBenv* env, FILE* logfile)> GRBsetlogfile = nullptr;
./gurobi/environment.cc:612:  gurobi_dynamic_library->GetFunction(&GRBgetlogfile, "GRBgetlogfile");
./gurobi/environment.cc:613:  gurobi_dynamic_library->GetFunction(&GRBsetlogfile, "GRBsetlogfile");
gokhanceyhan commented 2 years ago

Hi,

Do you see that this issue can be fixed soon? This blocks our usage of latest gurobi versions via or-tools.

Thanks,

gokhanceyhan commented 2 years ago

Thanks for fixing this!