# [ADMB Users] Solving a system of non-linear equations inside an optimisation

dave fournier davef at otter-rsch.com
Thu Apr 28 09:35:04 PDT 2011

```   The right approach will depend on the form of your problem.

say that  your nonlinear system is described by the differentiable
function

G(x,u)=0;

and that your objective function is

F(x,u)

Solving G(x,u)=0 for uhat(x)  i.e

G(x,ubar(x))=0                             1.0

for all x

We now have  the objective function  K(x)

where K(x) = F(x,ubar(x))

The derivative of K(x)  is given by the chain rule

dK(x)/dx = F_x + F_u d ubar(x)/dx

Now G_x + G_u d ubar(x)/dx =0

So  d ubar(x)/dx = -inv(G_u) *G_x

so

dK(x)/dx = F_x - F_u  * inv(G_u) *G_x

Exactly how you get all these will depend on the form of your problem.

This is  in some ways a simpler form of the inner optimization for the
RE model.

The thing could be automated by modifying that code.  The df1b2variables
are overkill for
this and to be elegant one could modify that class to df1b1variables,
but it is not necessary