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

Leitz, Thomas thomas.leitz at fau.de
Fri May 15 05:33:36 EDT 2015

Hello Kshitij,

thank you for your elaborate answer. I already suspected, that computational time savings would be minimal for most applications, so it is good to hear, that it actually is. With regard to the hessian: Apart from the gradient I also need part of the full hessian d^2 f / (dq_i,dq_j), where q=[x,y], more specifically d^2 f / (dx_i, dy_j).


Thomas Leitz
Chair of Applied Dynamics
University of Erlangen-Nuremberg
Haberstrasse 1
D-91058 Erlangen, Germany
room 01.012
phone +49 (0)9131 85 61005

On 15.05.2015, at 10:52, Kshitij Kulshreshtha <kshitij at math.upb.de> wrote:

> 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
> gradient.
> 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
> declaration in the header param.h
> The simple usage is similar to your approach number 2, but does not
> require retaping. You just replace the parameter vector before calling
> gradient() using the call to set_param_vec(). See the adolc-manual.pdf
> 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
>> _______________________________________________
>> 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: TP21.1.21
> Besucheradresse:
> Technologiepark 21
> 33098 Paderborn.
> Privatanschrift:
> Arnikaweg 62
> 33100 Paderborn.

More information about the ADOL-C mailing list