[ADOL-C] Solutions of ADOL-C numerically not exact - What's the problem?
kshitij at math.upb.de
Wed Nov 19 09:11:15 EST 2014
I finally got round to looking at your code. I see nothing but zeros in
my output of the tester using the latest ADOL-C. The only garbage is in
the upper part of the Hessian matrix which is not initialized by ADOL-C
at all. ADOL-C always only computes the lower half of the hessian.
Also in the current SVN trunk of ADOL-C look at the ipopt examples for a
new interface that allows one to have sigma and lambda as non adouble
parameter variables. This reduces the hessian computation time considerably.
On 2014-11-07 16:38, Christian Wolf wrote:
> 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
> 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:
> Just check the paths in the makefile and call make to build a programm
> 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
> 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
> ADOL-C mailing list
> ADOL-C at list.coin-or.org
Dr. Kshitij Kulshreshtha
Institut für Mathematik,
Warburger Straße 100,
More information about the ADOL-C