How to print the dual solutions?

482 views
Skip to first unread message

Swaprava Nath

unread,
Feb 11, 2016, 3:33:10 PM2/11/16
to Gurobi Optimization
I have set up the primal LP in the model and solved the optimization using Gurobi. However, it is important to print the dual variables for my understanding. Can this be printed in Gurobi? If yes, then how? For the primal: I can call the primal variable (say k) as

k.getAttr('x')

But how to do it for duals (for which I don't know the variable names)?

Thanks,
Swaprava


Renan Garcia

unread,
Feb 11, 2016, 3:35:33 PM2/11/16
to gur...@googlegroups.com
Duals are constraint (not variable) attributes. In particular, you should use the Pi constraint attribute (see https://www.gurobi.com/documentation/6.5/refman/pi.html#attr:Pi).

--

---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Swaprava Nath

unread,
Feb 11, 2016, 3:50:48 PM2/11/16
to gur...@googlegroups.com
Can you provide an example of getting the attribute?

I was tending to do: m.getConstr() which is not a right thing apparently.

Renan Garcia

unread,
Feb 11, 2016, 3:56:11 PM2/11/16
to gur...@googlegroups.com
Please see https://www.gurobi.com/documentation/6.5/refman/python_attribute_examples.html#PythonAttributeExamples for general guidance on querying attributes in Python. For example, you could use

  for c in m.getConstrs():
    print(c.pi)
Reply all
Reply to author
Forward
0 new messages