Error building `Gurobi`

I have installed Gurobi.jl(v"0.8.1"), When I build it, some wrong happened.
Julia version:JuliaPro 1.5.1-1. What should I do next? Thank you for your help.

julia>ENV["GUROBI_HOME"] = "C:\\gurobi911\\win64"
julia>import Pkg

Building Gurobi → C:\Users\ipso17.GXU\.julia\packages\Gurobi\7YNJV\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 and post the full
│ print-out of this diagnostic attempt.

│ Stacktrace:
│ [1] error(::String) at .\error.jl:33
│ [2] top-level scope at C:\Users\ipso17.GXU.julia\packages\Gurobi\7YNJV\deps\build.jl:154
│ [3] include(::String) at .\client.jl:457
│ [4] top-level scope at none:5
│ in expression starting at C:\Users\ipso17.GXU.julia\packages\Gurobi\7YNJV\deps\build.jl:152
│ Unable to locate Gurobi installation. Running some common diagnostics.

│ Gurobi.jl only supports the following versions:

│ - gurobi90
│ - gurobi81
│ - gurobi80
│ - gurobi75
│ - gurobi70

│ Did you download and install one of these versions from

│ Found GUROBI_HOME = C:\gurobi911\win64

│ Does this point to the correct install location?
│ - on Windows, this might be C:\Program Files\gurobi810\win64\
│ - alternatively, on Windows, this might be C:/Program Files/gurobi810/win64/
│ - on OSX, this might be /Library/gurobi810/mac64/
│ - on Unix, this might be /home/my_user/gurobi810/linux64/

│ Note: this has to be a full path, not a path relative to your current
│ directory or your home directory.

│ We’re going to look for the Gurobi library in this directory:
│ C:\gurobi911\win64\bin

│ That directory has the following files:

│ - C:\gurobi911\win64\bin\Gurobi91.NET.XML
│ - C:\gurobi911\win64\bin\Gurobi91.NET.dll
│ - C:\gurobi911\win64\bin\GurobiJni91.dll
│ - C:\gurobi911\win64\bin\grb_ts.exe
│ - C:\gurobi911\win64\bin\grbcluster.exe
│ - C:\gurobi911\win64\bin\grbgetkey.exe
│ - C:\gurobi911\win64\bin\grbprobe.exe
│ - C:\gurobi911\win64\bin\grbtune.exe
│ - C:\gurobi911\win64\bin\gurobi.bat
│ - C:\gurobi911\win64\bin\gurobi91.dll
│ - C:\gurobi911\win64\bin\gurobi91_light.dll
│ - C:\gurobi911\win64\bin\gurobi_cl.exe
│ - C:\gurobi911\win64\bin\vslauncher.exe
│ - C:\gurobi911\win64\bin\vswhere.exe

│ We were looking for (but could not find) a file named like, libgurobiXXX.dylib, or gurobiXXX.dll. You
│ should update your GUROBI_HOME environment variable to point to the
│ correct location.
└ @ Pkg.Operations D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\Pkg\src\Operations.jl:949

It looks like you have an old version of Gurobi.jl. Please update to the latest. ] add Gurobi@0.9.12.

1 Like

The above problem has been solved according to your suggestion. But when I run the code, a new error has occurred.

using JuMP,JuMPeR,Gurobi

# Define problem parameters
I = 3           # Number of factories
T = 24          # Number of time periods
d_nom = 1000*[1 + 0.5*sin(π*(t-1)/12)  for t in 1:T]  # Nominal demand
θ = 0.20        # Uncertainty level
α = [1.0, 1.5, 2.0]  # Production costs
c = [α[i] * (1 + 0.5*sin(π*(t-1)/12))  for i in 1:I, t in 1:T]
P = 567         # Maximimum production per period
Q = 13600       # Maximumum production over all
Vmin = 500      # Minimum inventory at warehouse
Vmax = 2000     # Maximum inventory at warehouse
v1 = Vmin       # Initial inventory (not provided in paper)

# Setup robust model
invmgmt = RobustModel(solver=GurobiSolver(OutputFlag=0))

# Uncertain parameter: demand at each time stage lies in a interval
@uncertain(invmgmt, d_nom[t]*(1-θ) <= d[t=1:T] <= d_nom[t]*(1+θ))

# Decision: how much to produce at each factory at each time
# As this decision can be updated as demand is realized, we will use adaptive
# policy - in particular, an affine policy where production at time t is an
# affine function of the demand realized previously.
@adaptive(invmgmt, p[i=1:I,t=1:T], policy=Affine, depends_on=d[1:t-1])

# Objective: minimize total cost of production
@variable(invmgmt, F)  # Overall cost
@objective(invmgmt, Min, F)
@constraint(invmgmt, F >= sum{c[i,t] * p[i,t], i=1:I, t=1:T})

# Constraint: cannot exceed production limits
for i in 1:I, t in 1:T
    @constraint(invmgmt, p[i,t] >= 0)
    @constraint(invmgmt, p[i,t] <= P)
for i in 1:I
    @constraint(invmgmt, sum{p[i,t], t=1:T} <= Q)

# Constraint: cannot exceed inventory limits
for t in 1:T
        v1 + sum{p[i,s], i=1:I, s=1:t} - sum{d[s],s=1:t} >= Vmin)
        v1 + sum{p[i,s], i=1:I, s=1:t} - sum{d[s],s=1:t} <= Vmax)

# Solve
status = solve(invmgmt)

    LoadError: The C API of Gurobi.jl has been rewritten to expose the complete C API, and
    all old functions have been removed. For more information, see the Discourse
    Here is a brief summary of the changes.
  • Constants have changed. For example CB_MIPNODE is now GRB_CB_MIPNODE
    to match the C API.
  • Function names have changed. For example free_env(env) is now
  • For users of Gurobi.Optimizer(), model.inner is now a pointer to the C
    model, instead of a Gurobi.Model object. However, conversion means that
    you should always pass model instead of model.inner to the low-level
    functions. For example:
    model = direct_model(Gurobi.Optimizer())
    grb_model = backend(model)  # grb_model is Gurobi.Optimizer
    # Old
    # New
  • Some functions have been removed entirely. For example:
    using JuMP, Gurobi
    model = direct_model(Gurobi.Optimizer())
    grb_model = backend(model)
    stat = Gurobi.get_status_code(grb_model.inner)
    is now:
    using JuMP, Gurobi
    model = direct_model(Gurobi.Optimizer())
    valueP = Ref{Cint}()
    grb_model = backend(model)
    ret = GRBgetintattr(grb_model, "Status", valueP)
    if ret != 0
        # Do something because the call failed
    stat = valueP[]

The new API is more verbose, but the names and function arguments are now
identical to the C API, documentation for which is available at:

To revert to the old API, use:
import Pkg
Pkg.add(Pkg.PackageSpec(name = “Gurobi”, version = v"0.8.1"))
Then restart Julia for the change to take effect.
in expression starting at untitled-254185b6f7c55e2fdb6293d5d74fc246:17
error(::String) at error.jl:33
GurobiSolver(; kwargs::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:OutputFlag,),Tuple{Int64}}}) at deprecated_functions.jl:548
(::Gurobi.var"#GurobiSolver##kw")(::NamedTuple{(:OutputFlag,),Tuple{Int64}}, ::typeof(GurobiSolver)) at deprecated_functions.jl:548
top-level scope at untitled-254185b6f7c55e2fdb6293d5d74fc246:17
include_string(::Function, ::Module, ::String, ::String) at loading.jl:1088

The last version of this package is from “Feb 24 2019”, so it provabably depends on old version of the Julia packages that probably only support old versions of the solvers. I recommend looking at which versions of the packages/solver were available at date and try to mimic them. It is a package from a thesis, so it was probably mostly made for use of the own author.

1 Like

JuMPeR is a modeling language for robust optimization. Other than it, I don’t know of any other packages that can achieve robust optimization. Some packages can be given? Thank you very much.

JuMPeR has not been maintained for two years. It relies on an old version of JuMP, and cannot be used with Gurobi 9.1. I’m not aware of a similar package for robust optimization in Julia.

If you really wanted to get it working, use a different solver, or install an old version of Gurobi the solver (e.g., 8.1 or 9.0, not 9.1). Then run (in a clean environment):

ENV["GUROBI_HOME"] = "C:\\gurobi90\\win64" # <-- modify as needed
] add
] add Gurobi@0.8

Note that you will need to read the old JuMP documentation: JuMP — Julia for Mathematical Optimization — JuMP -- Julia for Mathematical Optimization 0.18 documentation.

1 Like

OK, thank you very much.