[ADOL-C] Activate/deactivate adoubles
kshitij at math.upb.de
Mon Jun 21 05:05:36 EDT 2010
As on 2010-06-19 13:20, Andreas Puettmann did write:
> Hi everyone!
> I want to use ADOL-C to compute PDE solution sensitivities w.r.t. a
> bunch of model parameters. Altogether, we are talking here about a
> number of approximately 20 parameters. However, in one single run of my
> solver, the user is usually not interested in partial derivatives w.r.t.
> all of these 20 parameters, but only say 5 of them (arbitrarily chosen
> from the whole set).
I assume you are using an iterative solver to solve the PDE and
differentiate through all the iterations?
> However, now I want to change to taping mode to be able to use the
> drivers for Hessian matrices etc. What would be the best way to realize
In case of Hessian computation ADOL-C's default is to use the reverse
mode on top of a forward mode evaluation. This means that all the
dependent intermediates and taylor coefficients will be stored either in
memory, or on disk if the size is large enough. This depends on the
number of iterations you require to solve the PDE.
In such cases the recommended method is to use checkpointing if the
number of iterations is large.
> I definitely want to keep all of my parameters as adoubles because the
> user should potentially be able to compute derivates w.r.t. all of them
> at the same time, although this will usually not be the case.
Keeping all parameters as adoubles, even if you only require derivatives
w.r.t. a few, will increase your memory requirement and make the speed
slower. It is always advisable to only use adoubles where you really
need the derivatives.
> Is there a means to activate and deactive adoubles? In my case, it would
> be perfect if I could make ADOL-C treat some (in fact most) of the
> adoubles just like regular doubles.
You may do some kind of trick with templates by defining some kind of
wapper class or use #define macros. For example:
#define adtype adouble
#define adtype double
Then before the declaration of active variables just
#define ACTIVE 1
and for inactive variables you can simply declare
The other thing is to selectively use the <<= and >>= operators that
define the independent and dependent sets in a similar fashion. This
would let only the adoubles marked independent be in a connected
component of the computational graph. The other adoubles will be
disconnected components in this graph and will not be traced.
Of course in order to change the activity you will need to recompile at
least the module which contains these declarations and the operators <<=
/ >>= and relink with the rest of the code.
I am not aware of any way to change activities on runtime in ADOL-C. I
hope this helps you in some way.
Institut für Mathematik,
Warburger Straße 100,
More information about the ADOL-C