Get basic variables of Gurobi solution


Does anyone know how to get the basic variables after Gurobi solves an LP? It is not enough to just check for nonzero numbers in the solution since there could be degenerate basic variables. Gurobi exposes the function GRBgetBasisHead in its C API but I have no idea how to call this function with the Julia interface. Any help will be much appreciated!

Any function in the API can be accessed. I tried a while ago to get the tableau from CPLEX. Check cpx_matrix

One way for you to achieve this would be to fork Gurobi.jl and add your function there. Look at the code and search for @grb_ccall . Those are the calls to the API. If that seems to overwhelming for you, let me know. There are other options.

Actually, I dug a little deeper and my real application requires me to be able to swap the basic variables and non-basic variables out to find more vertices in the solution space (but not enumerate them all, i.e. I only want a certain number of them). It doesn’t look like Gurobi exposes this functionality. Do you know of any solver where this is possible?

If you need getBasisHead, please open an issue and we can walk you through how to wrap the function and make a PR :slight_smile: