Dual variable of a constraint (python)

19 views
Skip to first unread message

Juan Zhang

unread,
May 20, 2018, 12:04:00 PM5/20/18
to AMPL Modeling Language
Hi,

I am trying to retrieve the value of the dual variable associated with a constraint. So far I have not been successful, Is the following syntax correct?






Output


AMPL Google Group

unread,
May 20, 2018, 3:57:10 PM5/20/18
to Ampl Modeling Language
You can use <Constraint_name>.dual to get the dual values.

--
Paras Tiwari
am...@googlegroups.com
{#HS:584436544-8147#}
On Sun, May 20, 2018 at 4:04 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Hi,

I am trying to retrieve the value of the dual variable associated with a constraint. So far I have not been successful, Is the following syntax correct?

Code.PNG






Output

Output.PNG


--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.



AMPL Google Group

unread,
May 21, 2018, 7:37:08 AM5/21/18
to Ampl Modeling Language
The error "Wrong number of indices used" indicates that the constraint is indexed. For indexed constraints you can obtain the dual values as follows:

print ("Load_Balance1 = ", LoadCost1.getValues().toList())

or, alternatively:

print ("Load_Balance1 = ", LoadCost1.getValues().toDict())

--
Filipe Brandão
am...@googlegroups.com
{#HS:584436544-8147#}
On Sun, May 20, 2018 at 7:56 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
You can use <Constraint_name>.dual to get the dual values.

--
Paras Tiwari
am...@googlegroups.com


On Sun, May 20, 2018 at 4:04 PM UTC, Ampl Modeling Language <am...@googlegroups.com> wrote:
Hi,

I am trying to retrieve the value of the dual variable associated with a constraint. So far I have not been successful, Is the following syntax correct?

Code.PNG






Output

Output.PNG


Reply all
Reply to author
Forward
0 new messages