Как использовать Gurobi?

#julia #gurobi

#джулия #gurobi

Вопрос:

Я хочу использовать Gurobi в такой программе:

 use Gurobi
 

На что выдается следующее сообщение об ошибке:

 ERROR: LoadError:     Gurobi not properly installed. Please run Pkg.build("Gurobi"). For
    more information go to https://github.com/jump-dev/Gurobi.jl

Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] top-level scope at /Users/prikshetsharma/.julia/packages/Gurobi/P6eVP/src/Gurobi.jl:7
 [3] include(::Function, ::Module, ::String) at ./Base.jl:380
 [4] include(::Module, ::String) at ./Base.jl:368
 [5] top-level scope at none:2
 [6] eval at ./boot.jl:331 [inlined]
 [7] eval(::Expr) at ./client.jl:467
 [8] top-level scope at ./none:3
in expression starting at /Users/prikshetsharma/.julia/packages/Gurobi/P6eVP/src/Gurobi.jl:4
ERROR: LoadError: Failed to precompile Gurobi [2e9cd046-0924-5485-92f1-d5272153d98b] to /Users/prikshetsharma/.julia/compiled/v1.5/Gurobi/do9v6_rMyJO.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1305
 [3] _require(::Base.PkgId) at ./loading.jl:1030
 [4] require(::Base.PkgId) at ./loading.jl:928
 [5] require(::Module, ::Symbol) at ./loading.jl:923
 [6] include(::Function, ::Module, ::String) at ./Base.jl:380
 [7] include(::Module, ::String) at ./Base.jl:368
 [8] exec_options(::Base.JLOptions) at ./client.jl:296
 [9] _start() at ./client.jl:506
in expression starting at /Users/prikshetsharma/Documents/clotorch/src/clotorch/flight/opt.jl:

 

При установке самого Gurobi я получаю следующую ошибку, в которой упоминается проблема с установкой и шаги по ее устранению:

 Pkg.build("Gurobi")
   Building Gurobi → `~/.julia/packages/Gurobi/P6eVP/deps/build.log`
┌ Error: Error building `Gurobi`: 
│ ERROR: LoadError: Unable to locate Gurobi installation. If the advice above did not help,
│ open an issue at https://github.com/jump-dev/Gurobi.jl and post the full
│ print-out of this diagnostic attempt.
│ 
│ Stacktrace:
│  [1] error(::String) at ./error.jl:33
│  [2] top-level scope at /Users/prikshetsharma/.julia/packages/Gurobi/P6eVP/deps/build.jl:161
│  [3] include(::String) at ./client.jl:457
│  [4] top-level scope at none:5in expression starting at /Users/prikshetsharma/.julia/packages/Gurobi/P6eVP/deps/build.jl:155
│ 
│ **Unable to locate Gurobi installation. Running some common diagnostics.**
│ 
│ Gurobi.jl only supports the following versions:
│ 
│  - gurobi90
│  - gurobi91
│ 
│ Did you download and install one of these versions from gurobi.com?
│ Installing Gurobi.jl via the Julia package manager is _not_ sufficient!
│ 
│ Found GUROBI_HOME =  /Library/gurobi910/mac64/
│ 
│ Does this point to the correct install location?
│ 
│ We're going to look for the Gurobi library in this directory:
│     /Library/gurobi910/mac64/lib
│ 
│ That directory has the following files:
│ 
│ Aha! We tried looking in `/Library/gurobi910/mac64/lib`, but something went wrong. Are
│ you sure that your GUROBI_HOME environment variable is correct?
│ When combined with the appropriate suffix (e.g., `lib` or
│ `bin`, it needs to point to a valid directory.
│ 
│ 
│ You should set the `GUROBI_HOME` environment variable to point to the
│ install location then try again. For example (updating the path to the
│ correct location if needed):
│ ```
│ # On Windows, this might be
│ ENV["GUROBI_HOME"] = "C:\Program Files\gurobi910\win64\"
│ import Pkg
│ Pkg.add("Gurobi"
│ Pkg.build("Gurobi")
│ 
│ # On OSX, this might be
│ ENV["GUROBI_HOME"] = "/Library/gurobi910/mac64/"
│ import Pkg
│ Pkg.add("Gurobi")
│ Pkg.build("Gurobi")
│ 
│ # On Unix, this might be
│ ENV["GUROBI_HOME"] = "/opt/gurobi910/linux64/"
│ import Pkg
│ Pkg.add("Gurobi")
│ Pkg.build("Gurobi")
│ ```
│ **Note: your path may differ. Check which folder you installed the Gurobi
│ binary in, and update the path accordingly.**
└ @ Pkg.Operations /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Operations.jl:949


 

Я уже выполнил шаги, упомянутые для macOS в приведенной выше трассировке, но я все еще получаю указанную выше ошибку. Как установить Gurobi и успешно использовать его?

Комментарии:

1. Просто комментарий: вы должны делать using Gurobi , а не use Gurobi FWIW

2. Просто чтобы проверить, вы действительно установили Gurobi по указанному вами пути? Gurobi является коммерческим продуктом и требует, чтобы вы получили лицензию: github.com/jump-dev/Gurobi.jl#installation

Ответ №1:

Сначала вам необходимо установить автономный пакет Gurobi. Пожалуйста, следуйте инструкциям в этих руководствах для получения дополнительной информации. Как уже упоминалось в комментариях, вам также следует приобрести лицензию на запуск Gurobi.