[Ipopt] Lagrange multipliers during iterations using Ipopt

Chunhua Men chhmen at gmail.com
Wed Jul 19 13:08:11 EDT 2017


Hi all,

I did some tests to obtain the Lagrange multipliers. I printed out
the multipliers for each iteration (by using "intermediate_callback") and
the the multipliers at the last iteration (by using "finalize_solution").
At " finalize_solution", I printed out both "lambda" and the data from
"ip_cq'. So my code is like this:

 Ipopt::TNLPAdapter* tnlp_adapter = NULL;
        if( ip_cq != NULL )
        {
            Ipopt::OrigIpoptNLP* orignlp;
            orignlp =
dynamic_cast<Ipopt::OrigIpoptNLP*>(GetRawPtr(ip_cq->GetIpoptNLP()));
            if( orignlp != NULL )
            {
                tnlp_adapter =
dynamic_cast<Ipopt::TNLPAdapter*>(GetRawPtr(orignlp->nlp()));
                double* dualeqs = new double[m];
                tnlp_adapter->ResortG(*ip_data->curr()->y_c(),
*ip_data->curr()->y_d(), dualeqs);
                for (int ii = 0; ii < m; ii++)
                {
                  //1: print out dualeqs[ii]
                 //2: print out lambda[ii]
                }
            }
        }


For some tests, dualeqs[ii] is the same as lambda[ii]; but for some tests,
they are not the same at all.

Do I miss anything?

Thank you!




On Wed, May 17, 2017 at 2:59 AM, Antonello Lobianco <antonello at lobianco.org>
wrote:

> From the documentation
> <https://www.coin-or.org/Ipopt/documentation/node23.html#SECTION00053410000000000000>
> it should, at least using the C++ interface:
>
> virtual bool intermediate_callback()
>
> This method is called once per iteration (during the convergence check),
> and can be used to obtain information about the optimization status while
> IPOPT solves the problem, and also to request a premature termination.
> [...]
> A frequently asked question is how to access the values of the primal and
> dual variables in this callback. The values are stored in the ip_cq object
> for the internal representation of the problem. To access the values in a
> form that corresponds to those used in the evaluation routines, the user
> has to request IPOPT's TNLPAdapter object to ``resort'' the data vectors
> and to fill in information about possibly filtered out fixed variables.
>
>
>
>
>
> On 17 May 2017 at 11:32, Alex Ferrer <aferrer at cimne.upc.edu> wrote:
>
>> Yes, I need to know the values of the Lagrange multipliers during
>> iterations. Does Ipopt (independetly of using Matlab) provide them?
>>
>> Thanks,
>>
>> Àlex
>>
>> On 14/05/17 22:25, Antonello L. wrote:
>>
>> sorry, I didn't read that you need it **during iterations**..
>> Jump provides solver callbacks, but I am not sure you can use them in
>> nonlinear programming nor to extract lagrangian values..
>>
>> On 14 May 2017 9:39 p.m., "Antonello Lobianco" <antonello at lobianco.org>
>> wrote:
>>
>>> You could access IPOPT using Jump
>>> <http://jump.readthedocs.io/en/latest/> instead of Matlab and get the
>>> lagrangian with getdual([constraint name]).
>>> Antonello
>>>
>>> On 14 May 2017 at 11:34, Àlex Ferrer <aferrer at cimne.upc.edu> wrote:
>>>
>>>> Hi everyone,
>>>>
>>>> I am using Ipopt via the Matlab interface for solving my optimization
>>>> problem.
>>>>
>>>> I need to know the values of the Lagrange multipliers during iterations
>>>> and I could not find a way to get them from Ipopt.
>>>>
>>>> I was wondering if someone could help me with this.
>>>>
>>>> Thank you in advance,
>>>>
>>>> Àlex
>>>>
>>>> _______________________________________________
>>>> Ipopt mailing list
>>>> Ipopt at list.coin-or.org
>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.co
>>>> in-2Dor.org_mailman_listinfo_ipopt&d=DwIGaQ&c=Ngd-ta5yRYsqeU
>>>> sEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=8oTnxj08sd2ffhbFEprcyo6DDTVD
>>>> vo_DCJ2aU6CdYWE&m=1jOELYmw264NINGn1HEz2upD-LjqU5T1BFjnufFgTt
>>>> Q&s=u-hPWd-wE0VwNG492NzItoGXa1vTGSGwtrREgNROxVs&e=
>>>
>>>
>>>
>>>
>>> --
>>> Antonello Lobianco
>>> AgroParisTech, Laboratoire d'Economie Forestière
>>> 14 Rue Girardet - 54000 Nancy, France
>>> Tel: +33.383396865 <+33%203%2083%2039%2068%2065>
>>> Email, university: antonello.lobianco at inra.fr
>>> <antonello.lobianco at nancy.inra.fr>
>>> Email, personal: antonello at lobianco.org
>>> http://antonello.lobianco.org
>>>
>>
>> --
>> Alex Ferrer
>> *Ph.D. candidate student, M.Sc. Aeronautical Engineering*
>> *CIMNE*
>> a: Building C1 Campus Nord UPC C/ Gran Capità, S/N 08034 Barcelona, Spain
>> w: www.cimne.com/  e: aferrer at cimne.upc.edu
>>
>
>
>
> --
> Antonello Lobianco
> AgroParisTech, Laboratoire d'Economie Forestière
> 14 Rue Girardet - 54000 Nancy, France
> Tel: +33.383396865 <+33%203%2083%2039%2068%2065>
> Email, university: antonello.lobianco at inra.fr
> <antonello.lobianco at nancy.inra.fr>
> Email, personal: antonello at lobianco.org
> http://antonello.lobianco.org
>
> _______________________________________________
> Ipopt mailing list
> Ipopt at list.coin-or.org
> https://list.coin-or.org/mailman/listinfo/ipopt
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/ipopt/attachments/20170719/64c59d5f/attachment.html>


More information about the Ipopt mailing list