Identify how an addressable primitive object in a class is being used? for a given model run

Currently the Casal2 code base allows developers to set primitive objects i.e. Double, vector<Double>, map<string, Double> as addressable i.e RegisterAsAddressable(PARAM_K, &k_). It would be useful to know how these addressables are being used for a given model run. Particularly for how the Reset() methods are written.

I have the following example to illustrate this functionality. Age-length classes build and populate the age-length transition matrix. If this class knew for a given model configuration that none of the parameters which effect this matrix were being estimated. It would not have to recalculate this matrix every Reset() call, during an estimation run this can be called 1000’s of times. Thus for some model configurations reducing this re-calculation from 1000’s to 1.

Something to note when thinking about this code consideration is if an object changes due to time-varying interactions, that it may still need to be reset, so it has the correct values for the start of the model for the next iteration.

When I talked to Scott about this idea, he mentioned implementing functionality on the base class such as,

bool is_k_changing = is_referenced(&k_, Usage::kEstimated | Usage::kProfiled | Usage::kInputRun) 

Then classes could tailor the Reset() calls to be more effecient.

This has been addressed in the recent commit Here