gadget-framework / gadget3

TMB-based gadget implemtation
GNU General Public License v2.0
8 stars 6 forks source link

More parameterised defaults for actions #68

Closed lentinj closed 1 year ago

lentinj commented 2 years ago

@willbutler42 Having given g3a_renewal_vonb() defaults as parameterised values, it seems obvious we should do the same to a lot more places. g3a_renewal_normalparam(), g3a_grow_lengthvbsimple(), g3a_grow_weightsimple(), g3a_naturalmortality_exp(). Lots of boilerplate would vanish.

Can you think of any reason not to?

One of the fiddly parts is where a function by default takes parameters by species and by substock, e.g. g3a_initialconditions_normalparam() would need a separate by_stock parameter for mean_f and alpha_f. Not really a problem though.

I've also been assuming that the need for bounded() has gone with parscale, so haven't been bothering to put that back. Although again wouldn't be impossible.

willbutler42 commented 1 year ago

Sorry for the late response. Yes, I think this would be a good idea & can't think of any reason not to. And we could add the g3a_mature_ functions too (the alpha and l50 parameters)?

Maybe a solution would be to have some sort of 'by_stock' groupings which would be consistent across functions, e.g., by_stock_alphabeta for alpha_f and beta_f in g3a_initialconditions_normalparam and g3a_renewal_normalparam, or by_stock_growth for vonb parameters?

Regarding bounded(), yes, parscale has been working nicely so there's no need to add bounded() here

lentinj commented 1 year ago

Sorry for the late response. Yes, I think this would be a good idea & can't think of any reason not to. And we could add the g3a_mature_ functions too (the alpha and l50 parameters)?

Yeah, I think so.

Maybe a solution would be to have some sort of 'by_stock' groupings which would be consistent across functions, e.g., by_stock_alphabeta for alpha_f and beta_f in g3a_initialconditions_normalparam and g3a_renewal_normalparam, or by_stock_growth for vonb parameters?

Yeah, that's the way to do it. The comment is a bit cryptic, it's not a huge problem, more a note-to-self to not accidentally combine them into using the same "by_stock" parameter for everything.

lentinj commented 1 year ago

@willbutler42 @bthe Adding defaults to parameterise g3a_mature_continuous() is pretty easy, but the default names of "mat1" and "mat2" put me on-edge. Can we change them to "mat.alpha" and "mat.l50"?

Looking through gadget-models there's plenty of prior art using mat1 and mat2 though, so it'd be an annoying change, and maybe it's a more accepted shorthand than I realise.

lentinj commented 1 year ago

Bar my name quibbles, this is done with the above.

@willbutler42 as a bonus I also make the scale/offset parameters for g3_parameterized() themselves parameters if you give a string instead of a constant. This makes init_abund & renewal in demo-ling a simple 1-liner.