[CppAD] Efficiency questions

Brad Bell bradbell at seanet.com
Thu Jan 8 14:18:58 EST 2009


Notation:
Using your notation below we define
        z = f(x, y)
where x, y, z are vectors of length nx, ny, and nz respectively.
Furthermore nx ~= ny ~= 2 * nz (where ~= means approximately equal).

Answer to Q2 below:
If you are only interested in computing partials with respect to x, it is more efficient to treat y as parameters (not variables) and declare x to the be the vector of independent variables.

Answer to Q1 below:
Thus, and with an abuse of notation,
        z = f(x)
When computing the derivative of this function, the Jacobian driver
        http://www.coin-or.org/CppAD/Doc/jacobian.xml
will use reverse mode because nz < nx. This is not clear from the documentation (and I will fix that).  If you look at near the end of
https://projects.coin-or.org/CppAD/browser/trunk/cppad/local/jacobian.hpp
you will see that the Jacobian driver tries to use either forward or reverse mode depending on which is more efficient.

Answer to Q3 below:
CppAD requests memory in large blocks, and tries reduce the number of times it preforms such requests (while still being efficient about handing memory back to the system). The time to compute your Jacobians should not increase as more and more Jacobians are computed (CppAD should not cause memory to become fragmented).

On Thu, 8 Jan 2009 15:47:34 +0100, Lars Struen Imsland wrote
> In my problem, I have a function z = f(x,y), for which Ineed the Jacobian wrt x, \frac{\partial f}{\partial x}. This Jacobian will beevaluated many times, for varying x and y. Typical dimensions are 2 n_z \approxn_x \approx n_y \approx 100.
>  
> I have implemented this using the Jacobian driver with x asindependent variable. I understand the Jacobian driver uses forward mode.
>  
> Q1: Will it be more efficient to use some reverse mode/driver(since n_z is smaller than n_x)?
>  
> Presently, I retape the operations before each call to theJacobian, since y varies.
>  
> Q2: Will it be more efficient to do only one taping with xand y as independent variables, and just pick out the relevant columns of theJacobian?
>  
> A more general question:
>  
> Q3: Since I will calculate the Jacobian _many_ times(presently with retaping of the operations), should I worry about memoryfragmentation?
>  
> So far, CppAD seems to work splendidly, and is very easy touse. Many thanks to the developers.
>  
> TIA,
> Lars

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.coin-or.org/pipermail/cppad/attachments/20090108/7e73ca81/attachment.html 


More information about the CppAD mailing list