gadget-framework / gadget3

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

Predation - Otherfood equivalent #155

Closed lentinj closed 3 months ago

lentinj commented 4 months ago

@bthe / @willbutler42 / @vbartolino

For #29, gadget2 has OtherFood, we need something similar.

I'm thinking of a variation of initialconditions, say g3a_renewal_staticstock(), that works identically to initialconditions but will run on every step rather than just the first one, throwing away any stock from previous step and repopulating.

Does this sound good? Will GoB need it?

bthe commented 4 months ago

This sounds good, and would allow you more flexibility, e.g. define length and/or based predation on otherfood. I think otherfood is always needed as you will need to balance the feeding equations with additional energy from other sources.

lentinj commented 4 months ago

According to gadget2 userguide otherfood's length is only really there to paper over any problems which would occur without, which makes sense, otherfood is only about making sure there's a biomass of something else available.

It's similar in gadget3, there's a few broken edge-cases if the length dimension isn't there. But it's probably easier to do the same by defining with a single length group with g3_stock('otherfood', c(30, 50), open_ended = FALSE) or just g3_stock('otherfood', 0) (0..Infinity).

But either way, without a meaningful length grouping g3a_otherfood_normalcv() / g3a_otherfood_normalparam() are kinda pointless. A parametrised mean-weight & parameterized-by-year abundance is probably all the option you need.

Or would you define length groupings for otherfood, given the choice? It's only a bit of copy-paste to make them, but does make what is already a rambling mess of a man page even longer.

vbartolino commented 4 months ago

I'm thinking of a variation of initialconditions, say g3a_renewal_staticstock(), that works identically to initialconditions but will run on every step rather than just the first one, throwing away any stock from previous step and repopulating.

my initial guess was that otherfood would have been implemented with something like g3_timeareadata but your suggestion is probably better as @bthe points out (ie, it would allow to define length...).

Will GoB need it?

certainly it will have otherfood.

I assume it would be possible to have more than one otherfood component if wished, correct? In principle, if I find a reasonable time series of stickleback abundance, we could have two otherfood components, one reflecting stickleback and another generic for the rest

lentinj commented 4 months ago

your suggestion is probably better as @bthe points out (ie, it would allow to define length...).

I somehow managed to write all the above without noticing that. Sorry!

I assume it would be possible to have more than one otherfood component if wished, correct?

Yup, they're stocks like any other. You can call them what you like and add as many of them as you like. Just they only have one action associated with them as opposed to the normal heap of actions.

lentinj commented 4 months ago

I think this is largely done now. Otherfoods get defined like any other stock:

https://github.com/gadget-framework/gadget3/blob/a5d4f905d0d7f9f18453cac55f92f60ae0524942/tests/test-action_renewal-otherfood.R#L6-L8

...then for each, we add the otherfood action:

https://github.com/gadget-framework/gadget3/blob/a5d4f905d0d7f9f18453cac55f92f60ae0524942/tests/test-action_renewal-otherfood.R#L28-L34

lentinj commented 4 months ago

Also, the point I was supposed to make with the above. ifmissing = 0 is needed because our order of actions is (initialconditions) / (early_report) / (stop model run). So we run g3a_otherfood once after the model has finished.

This knot could probably do with unpicking, but having a value for other years is very likely for projections anyway.

lentinj commented 3 months ago

The above makes g3a_otherfood() a bit nicer to work with.