Active set and list of (NL) constraints in JuMP

question

#1

Is there a convenient way to access all of the constraints (including @NLconstraint) in a JuMP (v0.18.4) model? I’ve tried accessing model.linconstr etc, but it doesn’t give the nonlinear constraints. I’d also like to get the list of dual variables for every constraint and have just been using getdual(model[:constraint_name]), but this depends on having the name of the constraints, and I’m wondering if there’s an easier way of doing this. Do I have to convert the NL model to another form? Thanks!


#2

Here is where getdual is defined for non-linear constraints:


You could access .nlconstrDuals, but this is pretty fragile so we wouldn’t recommend it.

The proper way to do this would be either to access the constraints from the model dictionary like you’re doing, or to maintain your own datastructure that stores all of the constraint references.