Is there a way to guarantee that the solution returned by JuMP to a linear program is a basic solution?
I know this is probably a responsability of the solver. Is there an option I can pass from JuMP to any solver that guarantees that the solution is basic?
This would be a solver-level setting, though I believe (most of) the LP solvers available from julia will either use the simplex method or apply crossover after an interior point algorithm to give you an optimal basic solution. You can try calling the MathProgBase function getbasis to inspect the basis information, if the solver supports this.
Thanks. I was trying to find getbasis in MathProgBase docs but I could not find it. This code sample helps me a lot. Do you know what are cbasis and rbasis?
@chkwon, @joehuchette As a follow up question, how can I determine if a solution is degenerate (a basic variable is zero)?
Just looking at cbasis, rbasis and comparing the variable values to zero gets messy. The problem is that in a complex model, that I formulated through JuMP, I lost track of how the indices in cbasis, rbasis match to which variables / constrains in the model. Additionally, I do not know which variables have lower, and upper bounds, which are unbounded, and which are only restricted to be non-negative.
Is there a simpler way? Maybe MathProgBase exposes an isdegenerate API (I did not find any)?
Well I found a way. Use getsolution, getvarLB and getvarUB from MathProgBase to lower bounds and variable values in whatever order they got defined internally by Julia. Then for the variables where cbasis is :Basic, check whether the variable value equals the lower bound or the upper bound. If it does the solution is degenerate.