# [ADOL-C] Evaluating Hessian of Lagrangian

Norman Goldstein normvcr at telus.net
Sun Apr 7 18:31:50 EDT 2013

```Perhaps you can trace L as a function of both x and lambda.
Then when you need the hessian,
calculate the hessian only with respect to x.
Not sure if this is better/worse than what you suggested.

When using the Hessian of the Lagrangian, you will eventually be restricting
attention to the kernel of your constraints.  Do you know if this fact
would offer a simplification to how the hessian could be computed?

Norm

On 04/05/2013 04:02 AM, Ingrid Hallen wrote:
> Hi,
>
> I'm doing non-linear optimization with IPOPT. For this, I'm using ADOL-C
> to compute the Hessian of the Lagrangian
>
> L(x,lambda) = f(x) + sum_{i}lambda_{i}h_{i}(x),
>
> where x are the variables, lambda the Lagrange multipliers and
> f(x) and h_{i}(x) objective and constraint functions.
>
> What I'm doing in my code is the following (omitting details):
>
> // **********************
>
> // Trace Lagrangian function
> trace_on(tag);
>
> for(i=0;i<n;i++) {
> }
>
>
>
> trace_off();
>
> // Evaluate Hessian of the Lagrangian
> repeat = 0;
> sparse_hess(tag,n,repeat,x,&nnz,&rind,&cind,&values,&options)
>
> // ***********************
>
> This works fine, but is not so efficient. One reason is that, since
> lambda changes,
> the Lagrangian function has to be retaped every time the Hessian is
> needed and so it
> appears that I cannot set repeat = 1 when calling sparse_hess.
>
> One way to circumvent this problem could perhaps be to trace the objective
> and constraint functions individually and then construct the Hessian of
> the Lagrangian using multiple calls to sparse_hess, but is there a
> more convenient way to do it?
>
> Sincerely,
>
> Ingrid
>
>
>
> _______________________________________________