plant icon indicating copy to clipboard operation
plant copied to clipboard

[Access strategy functions] Change Strategy type to expose and access strategy functions

Open aornugent opened this issue 2 years ago • 1 comments

Recent changes have motivated a switch in the Strategy type that we expose in R.

Currently, RcppR6 generates a Strategy as a simple list object, which is lightweight, but does not expose any methods implemented in C++. Using a R6 object to expose these additional routines would allow better control of the ExtrinsicDrivers (implemented in #334) and other state transformations (as described in #309), simplifying some of our R code.

This change will introduce some additional complexity and require changes to how we initialise a Patch using a Parameters object.

The existing workflow involves:

  • Generating scm_base_parameters or equiv.
  • Adding parameterised strategies using expand_parameters, appending a list of Strategies to p$strategies
  • Passing the Parameters object into the Patch or SCM solver
  • Initialising each species and their ExtrinsicDrivers

An alternative might instead be to remove the strategies from Parameters and instead:

  • Generate a list of parameterised Strategy objects using e.g. generate_strategies
  • Set or modify the extrinsic drivers using set_variable(driver_name, x_vector, y_vector) or set_constant(driver_name, y)
  • Pass the list of Strategies into run_scm(strategy_list, environment, parameters, control)

This change could require substantial modifications to existing workflows and documentation. Happy to spend the time documenting a solution before we commit to implementation. Please share your thoughts!

aornugent avatar Apr 27 '22 08:04 aornugent

Thanks @aornugent

You're right it requires careful consideration. I'm full booked this week, but can discuss next week, after Tuesday?

dfalster avatar Apr 27 '22 22:04 dfalster