Closed aornugent closed 2 years ago
On names: I think Traits
is safest to avoid name clashes with the Species
class. Traits
matches well with the <T>
type used throughout the C++ templates.
So:
Species<T, E> = Traits<T> + Environment<E>
where the Traits
object(s) that are passed into the solver represent one or more instances of Strategy <T>
?
Hi @aornugent
Just checking where this is up to? I am considering the logic with hyper-parameterisation, and want to align with new API.
I see parts have been merged but perhaps not all?
Hi @dfalster - I think the only thing left was a re-naming of Parameters. I'll file a separate issue for this and close the PR. The core API features have been merged:
result <- run_scm_collect(parameters, environment, control)
Background
When exposing Environment state variables in #305 we found it difficult to add new environment settings and accessing them in the correct place.
Worse -we only wanted to use some settings with some strategies. For example, the FF16_Strategy operates in a light only environment, but the new Water_Strategy includes water infiltration.
Both strategies leverage the FF16_Environment (to reuse the adaptive Canopy interpolator for calculating shading) but the FF16_Strategy does not initialise any soil layers, whereas the Water_Strategy segfaults if not initialised with a soil layer.
Proposed solution
We decided to resolve this by separating the Parameters object, which was kind of a dumping ground passing things into the SCM and Patch APIs:
Previously:
where the Parameters object holds a Control object, some information about the DisturbanceRegime, a Strategy and Environment type and one or more Strategies object(s)
Now: By passing in fully configured SpeciesParameters, Environment, DisturbanceRegime and Control objects, we can provide maximum flexibility, with sensible defaults for each strategy handled by the R interface:
Notes
FF16_Environment.cpp
that are then overridden as needed in Rpatch_type
argument is removed)