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

Noam Gat noamgat at gmail.com
Tue Jun 21 06:48:33 EDT 2011


Making the proposed changes let to a crash in fos_gradient.
In the assign_ind case the ADOLC_GET_TAYLOR call (which translates to
get_tay_block_r) crashes because
fseek fails because ADOLC_CURRENT_TAPE_INFOS.tay_file is null...

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.coin-or.org/pipermail/adol-c/attachments/20110621/42a8cb4c/attachment.html 


More information about the ADOL-C mailing list