Obtain slack variables value of constraints?

210 views
Skip to first unread message

Fernando Banez-Chicharro

unread,
Aug 13, 2016, 2:07:25 PM8/13/16
to julia-opt
Hi!

Is it possible to obtain the value of the slack variables of the constraints? 
I have obtained the value of all the variables of the model with:
value = MathProgBase.getsolution(model)

But I don't know how to obtain the value of the slack variables.

Thanks!


Miles Lubin

unread,
Aug 13, 2016, 6:55:14 PM8/13/16
to julia-opt
I don't believe there's a method to obtain slacks. If you're talking about linear constraints, just query the constraint matrix and bounds and compute the slacks yourself.

Fernando Banez-Chicharro

unread,
Aug 13, 2016, 8:23:45 PM8/13/16
to julia-opt
Ok.
What do you mean by "query the constraint matrix"? Can I retrieve the value of the constraint to compute the slack by comparing to the bounds?

Thanks!

Fernando Banez-Chicharro

unread,
Aug 14, 2016, 12:00:29 PM8/14/16
to julia-opt
I think I got it!
I am using slack = get_dblattrarray( m.inner, "Slack", 1, num_constrs(m.inner)) to obtain the slack variable.

Miles Lubin

unread,
Aug 15, 2016, 10:03:01 AM8/15/16
to julia-opt
That works if you're happy using Gurobi. More generally, you can use MathProgBase.getconstrmatrix, MathProgBase.getconstrLB, and MathProgBase.getconstrUB to recompute the slacks.

Robert Schwarz

unread,
Aug 25, 2016, 9:20:50 AM8/25/16
to julia-opt
I want to compute the constraint slacks for specific constraints only, but I don't know what row they are in.
Is there a way to extract the row coefficients and lhs/rhs for JuMP constraint references?
I built my linear constraints using @constraint, and would a solver independent solution.

Robert Schwarz

unread,
Aug 25, 2016, 9:34:23 AM8/25/16
to julia-opt
OK, I got something working with using JuMP.getinternalmodel and JuMP.linearindex (for both rows and colums). Sorry for the noise, I couldn't find linearindex(ConstraintRef) in the documentation at first.
Reply all
Reply to author
Forward
0 new messages