[ADOL-C] Change parameters of a function without retaping

Kshitij Kulshreshtha kshitij at math.upb.de
Fri May 15 04:52:01 EDT 2015

Hello Thomas,

if the function is really scalar valued, i.e. the range is R, then the
complexity of the gradient() call does not depend on the number of
inputs. It depends on the number of operations, and that remains the
same, whether both x and y are independent variables or only x is, with
y being constant. This is known as the cheap gradient principle.

So your approach number 1 is what you want. You won't save anything in
terms of rumtime if you could declare y as parameters and only a partial

However if you require hessian of the function w.r.t. x and not w.r.t. y
then you would save some time by not computing the whole hessian. Also
if you were computing the jacobian of a vector valued function in
forward mode, you would have some small benefit by declaring y as
parameters.

In the current svn trunk or git master of ADOL-C (development code, not
considered stable) there is an interface to do such a parameter

The simple usage is similar to your approach number 2, but does not
require retaping. You just replace the parameter vector before calling
in the same code repository in ADOL-C/doc/ in section 6 for usage.

Best wishes
Kshitij

On 2015-05-09 00:49, Leitz, Thomas wrote:
> Hi,
>
> lets assume I have a function f(x,y) : R^n \times R^m -> R and I only
> need the gradient with respect to x, but every time I need to change
> both variables x and y. (y could be some parameters like coefficients of
> a polynomial function etc.). There are basically two ways I know how to
> achieve this:
>
> 1. mark both x and y as independent variables, tape once and every time
> I need a gradient I compute the whole gradient df/d(x,y) at some (x0,y0)
> and just use df/dx (i.e. the first n values of the gradient df/d(x,y)).
> This way I can change both variables but I also compute the gradient
> df/dy that I don't need.
>
> 2. mark only x as independent and tape the function with any y0 every
> time before computing the gradient df/dx.
>
> Is there any way to tape once, and later compute the gradient df/dx at
> any (x0,y0) without retaping?
>
>
> Thomas
>
>
> _______________________________________________
>

--
Dr. Kshitij Kulshreshtha

Institut für Mathematik,
Warburger Straße 100,