wds15 Developer
October 18
Hi Daniel!
Have a look at what I wrote here:
https://groups.google.com/group/stan-dev/attach/5b162997cf789/ode_system.pdf?part=0.1&authuser=0
Basically, the sensitivity states are crammed into a matrix S. Stheta is a NxM matrix, i.e. per parameter theta_m for which we take the sensitivity there is a column of N rows in that matrix (one per state).
In that notation the sensitivity ODE RHS is given by
• for the initials as
dSy0/dt = Jy * Sy0
• for the parameters as
dStheta/dt = Jy * Stheta + Jtheta
That means for the 3 cases with any sensitivites we endup with:
• v,d = varying initials, fixed parameters
• states (y,Sy0)
• Jy needed only
• d,v = fixed initials, varying parameters
• states (y, Stheta)
• Jy AND Jtheta needed
• v,v = both are varying
• states (y, Sy0, Stheta)
• Jy AND Jtheta needed
The code you refer to buries the math behind this - while I think it would be good to take advantage of the nice structure of matrix-vector products which will easy readability of the code a lot (at least to me).
I was saying that we have one adapter per integrator, yes. However, I do think that we should design things such that we do not need 4 different specializations underneath for each adapter. I think that can be done and it would make maintenance easier in going forward.
I’m OK with one specialization as long as it’s not a conditional/case-based
thing. Otherwise, I’d prefer multiple specializations with shared code
pulled out into subclasses or utility functions so that the objects actually
being used are simpler to reason about and test.
That is, I don’t want something like this
struct big_config_object {
int object_type;
that stores what type its for and then conditions behavior as in:
if (object_type == 1) ... do something ...
else if (object_type == 2) ... do something ...