[ADOL-C] tapeless adol-c question

Kshitij Kulshreshtha kshitij at math.upb.de
Wed May 21 13:13:22 EDT 2014


Hello,

So this warning is produced only in the case when some objects of type
adtl::adouble still exist in memory after the function computation with
them has finished. These exisiting objects already have some memory
allocated to them and if setNumDir() tries to increase the number of
directions, these objects will still have the old memory and cannot
store all the directions.

The way out of this is to make absolutely certain that all adtl::adouble
objects have been deallocated before you call setNumDir(). Then they
must be allocated again for the next function computation.

Also you don't require the #define ADOLC_TAPELESS anymore since you're
using both traced and traceless versions in their respective namespaces.

Regards
Kshitij.

As on 2014-05-20 23:21h, Ian Washington did write:
> Hello all,
> 
> I am new to the tapeless version of adol-c and I have a question related
> to setting the number of directional derivatives (numdirs) when using
> the forward vector mode.
> 
> In essence I would like to reset numdirs for a number of possibly
> different Jacobian matrices.
> 
> For example, consider the following 'pseudo' code:
> 
> #define ADOLC_TAPELESS
> #include <adolc/adolc.h>
> #include <adolc/adolc_sparse.h>
> #include <adolc/adtl.h>
> #include <ColPack/ColPackHeaders.h>
> 
> int main() {
> 
>   // n = indep.
>   // m = dep.
>   // xinit = initial point
>   // gGraph = colpack via 'BipartiteGraphPartialColoringInterface'
>   // Seed_J = seed
>   // Jac_P = jac. pattern using 'jac_pat'
>   // nnz = nonzeros
>   // numdirs = directions
> 
>   // preprocess to get Seed and Jac. pattern
> 
>   ad_preprocess(n, m, xinit, &gGraph, &Seed_J, &Jac_P, &nnz, &numdirs);
> 
>   // note, ad_preprocess uses the tape-based adolc to get Jac_P, Seed_J
> 
>   // set numdirs (must be called before adtl::adouble definitions)
> 
>   adtl::setNumDir(numdirs);
> 
>   // evaluate to get compressed Jac.
> 
>   ad_evaluate(n, m, numdirs, xinit, Seed_J, &Jc);
> 
>   // re-set everything and get a possibly new Jac.
> 
>   adtl::setNumDir(numdirs_n);  <--- PROBLEM HERE
> 
>   ad_evaluate(n_n, m_n, numdirs_n, xinit_n, Seed_J_n, &Jc_n);
> 
>   return 0;
> }
> 
> where the 'ad_evaluate' function is:
> 
> void ad_evaluate
> ( int n, int m, int numdirs, double *xinit,
>   double **Seed_J, double ***Jc_ret )
> {
> 
>   adtl::adouble *x = new adtl::adouble[n];
>   adtl::adouble *y = new adtl::adouble[m];
> 
>   for (int i=0; i<n; i++) x[i] = xinit[i];
> 
>   for (int i=0; i<n;++i) {
>     x[i].setADValue(Seed_J[i]);
>   }
> 
>   ceval_ad_tl(n, x, m, y); <-- evaluate functions
> 
>   double **Jc = myalloc2(m, numdirs);
> 
>   for (int i=0; i<m; i++){
>     for (int j=0; j<numdirs; j++)
>       Jc[i][j] = y[i].getADValue(j);
>   }
> 
>   *Jc_ret = Jc;
> 
>   delete[] x;
>   delete[] y;
> }
> 
> 
> The problem with the above is when I reset numdirs using
> adtl::setNumDir(numdirs_n) the second time I get the following:
> 
> ADOL-C Warning: Tapeless: Setting numDir will not change the number of
> directional derivative in existing adoubles and may lead to erronious
> results or memory corruption
> 
> Note, if I just remove the second adtl::setNumDir(numdirs_n) and
> evaluate the same Jacobian everything works fine.
> 
> So my question is how do I compute two different Jacobian matrices in
> the same program, which have a different Seed and number of directional
> derivatives?
> 
> Thanks,
> Ian.
> 
> 
> 
> 
> 
> _______________________________________________
> ADOL-C mailing list
> ADOL-C at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/adol-c
> 

-- 
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