# [Coin-ipopt] Hessian of the constraints

Stefan Vigerske stefan at math.hu-berlin.de
Tue Nov 6 06:10:57 EST 2007

```Hi,

> one more question,
>
> my constraints looks like this:  x0*x0 + x1*x1 + x2*x2 + x3*x3 = 1 and x0*x4 +
> x1*x5 + x2*x6 + x3*x7 = 0
>
> So my Jacobian looks like :     2*x0, 2*x1, 2*x2,2*x3,   0,   0,  0 ,
> 0; 1.constraint
>                                             x4,    x5,     x6,   x7,  x0, x1,
> x2, x3; 2.constraint
>
> and thé Hessian:                  2, 2, 2, 2;  for the 1.constraint
>                                         1, 1, 1, 1, 1, 1, 1, 1; for the second
> constraint
>
> My question is, should I add the hessian for the second constraint to the
> hessian matrix, because the values for the second constraint are 1?
> so the only thing that left is the lambda[1]

I'm not sure that I understand your question.
Ipopt requires you to provide the hessian of the lagrangian function.
So on those places in the hessian where you have the 1's in the hessian
of the second constraint, you have to add lambda[1].

code for jacobian and hessian is correct: If you set the option
derivative_test to second-order then Ipopt performs some numerical
tests, see http://www.coin-or.org/Ipopt/documentation/node49.html.

A wrong hessian can also be a cause for the problem with the failed
restoration you reported before. So a first step should be to check that
the hessian is correct.
You could also testwise set hessian_approximation to limited-memory,
then Ipopt does not use your hessian code but computes an approximated
hessian, see http://www.coin-or.org/Ipopt/documentation/node50.html.
If things work much nicer the approximated hessian, then there is
probably something wrong in the hessian you coded.

Best,
Stefan

--
Stefan Vigerske
Humboldt University Berlin, Numerical Mathematics
http://www.math.hu-berlin.de/~stefan

```