[ADOL-C] Branch switch when using same inputs as taping

Kshitij Kulshreshtha kshitij at math.upb.de
Mon Jun 20 08:45:27 EDT 2011


Hello, please try replacing a few of your commands. I am writing my
suggestions in line below:

As on 2011-06-20 14:35, Noam Gat did write:
> Hi,
> 
> I have a strange problem when using adol-c to create a gradient.
> Before I try to prevent re-taping, I am currently retaping before each
> gradient evaluation.
> 
> The general structure of the code is :
>
// replace this
>     trace_on(0);
// with
      trace_on(1,1)

>     for (int i=0; i<N; i++)
>     {
>         rawGradParams[i] <<= X[i];
>     }
>     adouble result = objective(rawGradParams);
>     double retVal;
>     result >>= retVal;

// replace this
>     trace_off(0);
// with
      trace_off();

// replace this
>     int gradientRetVal = gradient(0,N,X,G);
// with
      double one = 1;
      int retval = fos_reverse(1, 1, N, &one, G);

You should get the gradient in G with this. This is using the taping
process itself as the zero order forward call which is required before
calling the first order reverse call to compute the gradient.

If you want to prevent retaping you need to make totally sure that all
your comparison statements always give the same result and all loops
always run for the same number of iterations for every argument value.

-- 
Dr. Kshitij Kulshreshtha

Institut für Mathematik,
Universität Paderborn,
Warburger Straße 100,
33098 Paderborn.

Büro: A3.235

Privatanschrift:
Arnikaweg 62
33100 Paderborn.



More information about the ADOL-C mailing list