MINOS: Show Lagrange Multipliers

199 views
Skip to first unread message

ijma...@uc.cl

unread,
Nov 23, 2014, 11:13:49 AM11/23/14
to am...@googlegroups.com
Is there any way to show the Lagrange Multipliers which correspond to the optimal solution given by MINOS?

Robert Fourer

unread,
Nov 24, 2014, 9:19:15 PM11/24/14
to am...@googlegroups.com
If you have a constraint defined by, say

subject to Demand {i in ORIG, j in DEST}: ...

then "display Demand;" or equivalently "display Demand.dual;" will show you MINOS's Lagrange multipliers for that constraint.

Bob Fourer
am...@googlegroups.com

=======

mahraz amini

unread,
Aug 28, 2017, 9:15:17 AM8/28/17
to AMPL Modeling Language, 4...@ampl.com
Hi all

I have a question.

When we have inequality constraint with upper and lower bound like 

subject to const :

lb <=x <= ub;

by using "display const;" it gave back one number. as this constraint is actually combination of two constraints : x<= ub and x=> lb, should not AMPL give back two number related to Lagrange multiplier of these constraints? I am not sure the number that AMPL gave back as lagrange multiplier is associated with which constraint.

Thanks,

Mahraz

Michael Saunders

unread,
Aug 28, 2017, 12:31:30 PM8/28/17
to am...@googlegroups.com, Fourer Robert
Hi Mahraz,

Lagrange multipliers for bound constraints lj <= xj <= uj can be thought of
as a single number dj for each variable xj.

Assuming the objective is being minimized and x is feasible,
if dj < 0 the objective could be improved by increasing xj
(which the solver would do unless xj = uj).
If dj > 0 the objective could be improved by decreasing xj
(which the solver would do unless xj = lj).

Michael

--
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+unsubscribe@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.

mahraz amini

unread,
Aug 29, 2017, 9:23:57 AM8/29/17
to AMPL Modeling Language, 4...@ampl.com
thanks for your respond Micheal,

for constraint on variables, your are right. but what if the constraint is like this:

lb <= h(x) <= ub

In this case, don't we need two lagrange multiplier?

Thanks,

Mahraz

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.

Michael Saunders

unread,
Aug 29, 2017, 12:08:55 PM8/29/17
to am...@googlegroups.com, Fourer Robert
Hi Mahraz,

You're right, the same question arises for general constraints lb <= h(x) <= ub.
The answer is the same: there's only one Lagrange multiplier d.  It implies the
2 values that you're thinking of.  If neither bound is active, d=0 for both constraints.
If one constraint is active, d applies to that constraint and the other multiplier is 0.

Michael

To unsubscribe from this group and stop receiving emails from it, send an email to ampl+unsubscribe@googlegroups.com.

mahraz amini

unread,
Sep 15, 2017, 10:56:18 AM9/15/17
to AMPL Modeling Language
Thanks Michael

 I am solving my problem in MATLAB and calling AMPL to solve the optimization problem. after solving a problem in AMPL I can save variables value in MATLAB as follow :

SOC = ampl.getVariable('S').getValues.getColumnAsDoubles('val');


so to save lagrange multiplier I tried


PlimDual = ampl.getVariable('PLim.dual').getValues.getColumnAsDoubles('val');



I faced this error :


Struct contents reference from a non-struct array object.


Error in runMPC_LLC_Bat_interp3_dual (line 68)

PlimDual = ampl.getVariable('PLim.dual').getValues.getColumnAsDoubles('val');



  Do you have any idea how I can fix that? 


Thanks

Mahraz

Filipe Brandão

unread,
Sep 16, 2017, 10:34:53 AM9/16/17
to AMPL Modeling Language
Hi Mahraz,

ampl.getVariable('PLim.dual') does not work since PLim.dual is not a variable; it is a suffix (http://www.ampl.com/NEW/suffbuiltin.html) of the variable PLim. You should do the following instead:
ampl.getData('PLim.dual').getColumnAsDoubles('PLim.dual')

Best regards,
Filipe Brandão

mahraz amini

unread,
Apr 24, 2018, 11:22:15 AM4/24/18
to AMPL Modeling Language
Hi all

I have a constraint called SOC_init in my model and I want to see its Lagrange multiplier and as you explained above I can use 
ampl.eval('display SOC_init.dual;')
however it returns some negative number

SOC_init.dual [*] :=
 1 -0.016522       9 -0.0156748     17 -0.0160519     25 -0.0114808
 2 -0.0164822     10 -0.0153654     18 -0.0196729     26 -0.0114808
 3 -0.0166432     11 -0.0156748     19 -0.0182842     27 -0.0132575
 4 -0.0166686     12 -0.0195436     20 -0.0175545     28 -0.015913
 5 -0.0163785     13 -0.0195436     21 -0.0142846     29 -0.0132575
 6 -0.0162654     14 -0.0206059     22 -0.0139584     30 -0.0132575
 7 -0.0163099     15 -0.0220946     23  0.000544918
 8 -0.0162079     16 -0.0177345     24 -0.00856382

 I thought the Lagrange multiplier as defined as a penalty term should be always positive. Do you have any idea what are meaning of negative lagrange multiplier? 

thanks

Michael Saunders

unread,
Apr 24, 2018, 11:50:50 AM4/24/18
to am...@googlegroups.com
Hi Mahraz,

The sign of Lagrange multipliers depends on whether you have <= or >= (for inequalities).
Equality constraints can have multipliers or either sign.

Note that all your multipliers are quite small.
This might be a warning that the SOC_initial constraint is not well scaled,
or the objective function is not well scaled.
Consider dividing SOC_init by 100, or multiplying the objective by 100.

The main aim is to make typical constraint gradients and objective gradients O(1).
It's hard to see these, but maybe you know one way or another.

Michael


To unsubscribe from this group and stop receiving emails from it, send an email to ampl+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages