[Ipopt] gradient of the Lagrangien

Andreas Waechter andreasw at watson.ibm.com
Wed Sep 1 08:00:49 EDT 2010


Hi Sebastien,

The code for the Ipopt algorithm is purposely written in a way that does 
not require access to individual elements of vectors and matrices.  This 
abstraction allows that the particular representation of vectors and 
matrices can be changed (e.g., in a parallel distributed memory setting).

If you really need the individual elements for vectors, you should use the 
methods in

Ipopt/src/LinAlg/TMatrices/IpTripletHelper.hpp

particularly FillValuesFromVector and PutValuesInVector.  With those, you 
can allocate an array of size x->Dim() and have it filled with 
FillValuesFromVector.  If you want to put values from the array back into 
the vector, you use PutValuesInVector.  If you grep for those names in the 
Ipopt code, you can see some examples how we used this.  However, if you 
can get away with only using the methods of the Vector base class, your 
code would be more portable (e.g., when Ipopt would be parallel), and I 
would try to do that instead.  (It is sometime a bit awkward, but for us 
it payed off in the end.)

I hope this helps,

Andreas

On Wed, 1 Sep 2010, sebastien lengagne wrote:

> Dear all,
>
> I am using IPOPT, and I would like to test other Hessian approximation 
> (sparse one).
>
> To get the data I need, I implemented the *intermediate_callback *function*. 
> *Through the *IpoptCalculatedQuantities* ip_cq, *I can have the vector of the 
> Lagrangian like this:
>
> *SmartPtr<const Vector> x =  ip_cq->curr_grad_lag_x();*
>
> I can know the size of this vector like this:
>
> *size = x->Dim();*
> *
> *But I do not know how I can know the values of each component of this 
> vector*
>
> *I checked the help and the *IpVector.hpp* file but I did not find anything
>
> Does anybody know how to do it ?*
> *
> best regards
>
> -- 
> Sébastien LENGAGNE, Ph.D
> CNRS-AIST JRL(Joint Robotics Laboratory), UMI3218/CRT
> INTELLIGENT SYSTEMS RESEARCH INSTITUTE (IS), AIST
> AIST Central 2, 1-1-1 Umezono, Tsukuba, 305-8568 JAPAN
> tel : +81-29-8626508
> fax : +81-29-8626507
> mail : sebastien.lengagne at aist.go.jp
> website : http://staff.aist.go.jp/sebastien.lengagne/
>
>


More information about the Ipopt mailing list