[ADOL-C] Solutions of ADOL-C numerically not exact - What's the problem?

Christian Wolf ChristianLupus at gmx.de
Fri Nov 7 10:38:25 EST 2014


Hello to everybody,

I want to solve some optimisation problem in ipopt that represents an 
optimal control problem. I discretized the time and introduced an 
initial state for each time slot as well as an input and an additional 
value zeta that is necessary for the formulation of the optimal control 
problem.

Now I have written a bunch of C++ classes that calculate the right hand 
side of the system dynamics, that discretize the system, etc. For use in 
ipopt I need the first and second order derivatives. I intend to 
calculate those via adol-c. I activated the derivative-checker of ipopt 
(which just compares the derivatives with numerical ones) I saw that 
there was quite a problem with my code.

I wrote an additional main file to test the non-ipopt related part of 
the project. Under the following link you can get the simplified code:
http://wolf-stuttgart.net/~christian/Problem.tgz
Just check the paths in the makefile and call make to build a programm 
tester.

In the implementation I needed to calculate the hessian of the 
lagrangian L = sigma f + sum lambda g where sigma and lambda are given 
by teh optimizer and f and g are the objective function and the vector 
of the constraints. To allow this to be correctly differentiated in 
adol-c I augmented the variables of the optimizer by sigma and lambda.

If you run tester, you see the output of different deifferntations of 
the lagrangian. Just to be clear, the vctor var in this example is
v = [x0, zeta0, u0, x1, zeta1]
all those values are scalars for the sake of simplicity.
In the file collo.cpp around line 95 there are different possible 
calculations of L given that will be used to generate the adol-c tape. 
By default it is constant thus should result in a all-zeros vector for 
the gradient of the lagrangian. In fact you see in the output for gE 
(gradient of the extended/augmentet variable set) small but non-zero values.
normally I would guess for numerical issues but I thing that adol-c uses 
exact differentiatins and thus I do not understand the result.

When instead using a linear function in one of the variables the 
corresponding value changes (correctly) to 1 (or the corefficient if != 
1). The non-zeros keep existing.

When I then use the correct lagrangian and choose lambda = 0 and sigma = 
1 I have the cost functional (which is zeta1 in this case) but the 
gradient calculated by adol-c has many entries that are far off 0.

The hessian has the same problems but this seems to be related. My 
(personal) guess was that adol-c uses a completely differnt function to 
evaluate the gradients and hessians on.

I know this is not really easy to read all the code, but I was not able 
to restore the problem with a minimum (non)working example. Thus I added 
the main code (or at least parts of it). Maybe you can give me advice 
where to look...

Thanks a lot
Christian


More information about the ADOL-C mailing list