I am trying to get the tableau from Gurobi and running into some problems. I went through the gurobi github and reference manual and was able to put this together but it is erroring out.
# dummy model
m = direct_model(Gurobi.Optimizer(OutputFlag=0))
x = @variable(m, x[1:5] >= 0)
c1 = @constraint(m, c1, dot(x, [1,1,1,1,1]) == 5)
c2 = @constraint(m, c2, dot(x, [1,2,3,4,5]) == 7)
@objective(m, Min, dot(x, [1,2,3,4,5]))
optimize!(m)
# set up the output structure SVector as defined in the reference manual
# http://www.gurobi.com/documentation/8.1/refman/c_advanced_simplex_routine.html
mutable struct SVector
len::Cint
ind::Array{Cint,1}
val::Array{Cdouble,1}
end
#call BinvRowi from Gurobi
function get_tableau_row(model::Gurobi.Model, row::Integer)
num_vars = Gurobi.num_vars(model) # Model is of the form Ax=b
output = SVector(Cint(num_vars), convert(Vector{Cint}, zeros(num_vars)), convert(Vector{Cdouble}, zeros(num_vars)))
ret = Gurobi.@grb_ccall(BinvRowi, Cint,
(Ptr{Cvoid}, Cint, SVector),
model, Cint(row-1), output)
if ret != 0
throw(Gurobi.GurobiError(model.env, ret))
end
return output
end
# call the tableau row generation function
get_tableau_row(backend(m).inner, 1)
I am able to get it from CPLEX (via a slight modification of the code bbrunaud posted on the CPLEX github to make it compatible in Julia 1.1), but I would prefer to do everything in Gurobi.
Any help would be greatly appreciated. I am pretty sure my error is with respect to the Svector structure thats being passed to grb_ccall.