API documentation for gurobi.jl

There is two ways to use Gurobi in Julia that you are mixing in:

# JULIA
model = Model(Gurobi.Optimizer)
Gurobi.add_vars!(model, 0.0, I, J, Gurobi.GRB_BINARY, "r_i_j")

The first line is using Gurobi through JuMP, which is the recommended way. Then you can create the binary variables with

@variable(model, r[I, J], Bin)

as detailed in the docs.

The second line use the Julia wrapper of the Gurobi C interface. If you want to that interface, without JuMP, then you should not use Model(Gurobi.Optimizer) as this would create a JuMP model. You should not use anything from JuMP in that case, Gurobi.jl simply wraps the C-interface as is (the Julia interface is even automatically generated with Clang.jl). So check the C-interface documentation in the Gurobi website.
Again, I would recommend using the JuMP interface directly. It is much easier and will allow you to easily switch to another solver without any change to your code (except changing the line Model(Gurobi.Optimizer) of course)

3 Likes