Lagrange Multipliers

213 views
Skip to first unread message

Christian Alexander Rueda Mayorga

unread,
Mar 27, 2021, 1:06:03 AM3/27/21
to Pyomo Forum

I'd like to know how it's possible to obtain the lagrange multipliers from an optimal solution in a Concrete model solved with glpk?

Thanks!

David Woodruff

unread,
Mar 27, 2021, 9:08:36 AM3/27/21
to pyomo...@googlegroups.com

On Fri, Mar 26, 2021 at 10:06 PM Christian Alexander Rueda Mayorga <christian...@gmail.com> wrote:

I'd like to know how it's possible to obtain the lagrange multipliers from an optimal solution in a Concrete model solved with glpk?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyomo-forum/90bc04de-f135-4f40-b847-2723b78319aen%40googlegroups.com.

Sebasta Joséi

unread,
Mar 28, 2021, 12:41:49 AM3/28/21
to pyomo...@googlegroups.com
This is simple. But not Is necessary that use pyomo AND glpk, you should use scipy minimize, if you use pyomo AND a Solver is like kill a bee with ak-47

Antonello Lobianco

unread,
Mar 28, 2021, 3:31:23 AM3/28/21
to pyomo...@googlegroups.com
Politely, I disagree :-) It depends.
If a problem is a single equation to minimise, scipi minimise is perfect, but if you have a _model_, made of several multidimensional constraints, algebraic modelling languages like Pyomo (..but also Ampl, Gamps, Jump..) are so time (and error) saving, even if the mathematical optimisation problem is in itself trivial !


Christian Alexander Rueda Mayorga

unread,
Mar 28, 2021, 6:11:31 PM3/28/21
to pyomo...@googlegroups.com

I checked and tried the recommended documentation  https://pyomo.readthedocs.io/en/stable/working_models.html#accessing-duals  however I had an error accessing the duals. Any ideas for this error ?:

# display all duals
print ("Duals")
for c in model.component_objects(pyo.Constraint, active=True):
    print ("   Constraint",c)
    for index in c:
        print ("      ", index, model.dual[c[index]])

Duals
   Constraint Carga

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
C:\Users\Daniel Rueda\.conda\envs\Tesis\lib\site-packages\pyomo\common\collections\component_map.py in __getitem__(self, obj)
     99         try:
--> 100             return self._dict[id(obj)][1]
    101         except KeyError:

KeyError: 1947256489064

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-41-cf302eb9ef0a> in <module>
      4     print ("   Constraint",c)
      5     for index in c:
----> 6         print ("      ", index, model.dual[c[index]])
      7 

C:\Users\Daniel Rueda\.conda\envs\Tesis\lib\site-packages\pyomo\common\collections\component_map.py in __getitem__(self, obj)
    101         except KeyError:
    102             raise KeyError("Component with id '%s': %s"
--> 103                            % (id(obj), str(obj)))
    104 
    105     def __setitem__(self, obj, val):

KeyError: "Component with id '1947256489064': Carga[Bus_0001,1]"

You received this message because you are subscribed to a topic in the Google Groups "Pyomo Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyomo-forum/W2sLo7a532I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyomo-forum...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyomo-forum/CAERj1nWHv%2B3SXZUZ0wGEObXMm43kVOZBp9vg7NTNVYYyP49B8w%40mail.gmail.com.


--
christianalexanderruedamayorgaChristian Rueda

Estudiante Ingeniería Eléctrica E.P.N.

+593 984 592 441Ambato, Ecuador

Mike1712

unread,
Jun 1, 2022, 9:23:08 AM6/1/22
to Pyomo Forum
Hi, I come up with the same error while accessing dual values. Have you found a solution yet?
Reply all
Reply to author
Forward
0 new messages