How do I set up Mathematica to use the commercial Gurobi optimizer? Mathematica should be able to use it, as the Method -> "Gurobi" option exists for various optimization functions. I do have an academic license for Gurobi, and the Gurobi shell recognizes it correctly on my machine. However, Mathematica does not:

ConvexOptimization[x + 2 y, {x^2 + y^2 <= 1}, {x, y}, Method -> "Gurobi"]

ConvexOptimization::opmlicwf: The method Gurobi cannot be used since a valid
license could not be found. See get a license for Gurobi.

The Mathematica workflow, to which the error message points, does not really help.

(Windows 10, 64bits, Mathematica 13.3, Gurobi 11.0, installed automatically to C:\\gurobi1100.)

  • 1
    $\begingroup$ In the \$UserBaseDirectory, I added to the file init.m in the Kernel directory the path to the GUROBI license file with AppendTo. For instance, I added the following line: AppendTo[$Path,"/YYY/home/XXX/local/gurobi/linux64/license"]. $\endgroup$ Dec 6, 2023 at 16:44
  • $\begingroup$ @HolgerI.Meinhardt The directory that holds the gurobi.lic file is already on my $Path. $\endgroup$ Dec 6, 2023 at 17:16
  • $\begingroup$ I saw your post in chat. I used ConexOptimization with Gurobi in the past, but it was on an old laptop and I did not save the notebook. $$ $$ I cannot say this with 100% certainty, but if I remember correctly you need to use GurobiLink to interface between Mathematica and Gurobi software $\endgroup$
    – ydd
    Dec 7, 2023 at 3:32


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.