Do JuMP Variable ensure contiguous memory to Gurobi?

The motivation is that I notices Gurobi exposes the 3 APIs.

Allegedly, using GRBsetdblattrarray should be the fastest (than using the list counterpart, than using the element entrywise in a (julia) loop).
But the array API only exposes a start and a len arg. So it’s probably only effective for variables with a contiguous index pattern.

So I wonder if JuMP.jl (based on Gurobi.jl) can ensure the contiguous pattern when creating JuMP variables? e.g.

JuMP.@variable(m, x[2:3, [4]])
# some other code
y = JuMP.@variable(m, [i = 1:5, j = i:5, u = (0, 1)])

can I expect that the x and y has a contiguous index pattern in the Gurobi solver? (The order in julia is x -> y, and intra-x it’s for i in x, intra-y it’s for i in y).

A related question is,
considering this API

function GRBsetdblattrarray(model, attrname, first, len, newvalues)
    ccall((:GRBsetdblattrarray, libgurobi), Cint, (Ptr{GRBmodel}, Ptr{Cchar}, Cint, Cint, Ptr{Cdouble}), model, attrname, first, len, newvalues)
end

in julia if I call the above API, I need to input a len (e.g. 3).

Do I have to input Cint(3) (meaning that I cannot input 3 directly)? or will julia auto-convert that for me so I can input 3 directly?

Yes, they used 0 instead of Cint(0). I wonder if that’s valid action.

The GRBsetdblattrarray function called in the code above is a Gurobi version-specific function that calls ccall with the appropriate types, e.g., Gurobi.jl/src/gen100/libgrb_api.jl at master · jump-dev/Gurobi.jl · GitHub.

can I expect that the x and y has a contiguous index pattern in the Gurobi solver?

Yes, although this is not true for every solver.

For example, CSDP does not support free variables, so @variable(model, x) will actually create two columns in the solver (with the substitution rule x := x1 - x2)

I find it reasonably satisfying to use the Gurobi C-API shipped with Gurobi.jl. Does it suggest that Gurobi has no need to release a stand-alone julia API in the future?

I personally don’t think they need a different API. But that’s a commercial decision for them to make.