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).
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?