Allgeier-Lab / arrR

:package: Individual-based simulation model of artificial reefs
https://allgeier-lab.github.io/arrR/
GNU General Public License v3.0
1 stars 0 forks source link

Bug in rcpp_fishpop_growth and behavior 3 #74

Closed mhesselbarth closed 3 years ago

mhesselbarth commented 3 years ago

@kmunsterman

I think I found a bug in rcpp_fishpop_growth() and I'm not sure at what point it was added. In behavior 3 (foraging) there was the problem that individuals filled their reserves bigger than the maximum reserves because it was only checked if nutrients_left >= consumption_limit but not how big the "reserves capacity" of the individual still is.

I think 8c4a47d1e5fb2d9c9afce161da9d7b398bea0c2a should fix that. Please have a look if that makes sense and if it screws up any of your thoughts/ideas.

kmunsterman commented 3 years ago

@mhesselbarth oh yes I see the issue - it needs that statement to have the two checks: 1) for the consumption limit > amt to fill reserves ('nutrients_diff') and 2) nutrients_diff must be less than what is available in the cell in order to fill the reserves. is that correct? this looks good to me, but I need to familiarize myself again with this when I get back from the field. thanks for fixing this!

mhesselbarth commented 3 years ago

Not sure if I can follow you completely. So my thoughts were

1) Reserves can be filled completely if the consumption limit is bigger than the difference between the current reserves and the max reserves and at the same time there are more nutrients in the cell than that difference.

2) If not both of the statements above are true, either the consumption limit is consumed or whatever is left in the cell if that's less than the consumption limit.

In all cases, the detritus is reduced by the amount used for growth and additional the amount that was consumed to fill the reserves.

Is that what you just wrote?

mhesselbarth commented 3 years ago

And we actually need to check if reserves == reserves_max cause that is still causing problems

mhesselbarth commented 3 years ago

Should be fixed in bf5e53d9a4069952b8bcfdc947305657e7d2e283