ImperialCollegeLondon / virtual_ecosystem

This repository is the home for the codebase for the Virtual Ecosystem project.
https://virtual-ecosystem.readthedocs.io
BSD 3-Clause "New" or "Revised" License
9 stars 1 forks source link

Organizing functions between AnimalCohort and AnimalCommunity #223

Closed TaranRallings closed 7 months ago

TaranRallings commented 1 year ago

With the addition of the AnimalCommunity class, the logic for where certain functions are kept needs to be examined. My intention is to get through a broader implementation of trophic dynamics (with predation and spatial search) and then get review the logic.

David gave me some good suggestions for this below:

          Should this be a method of `AnimalCohort`? A cohort will have a number of individuals in a given (average) state that might be capable of reproducing and generating a new cohort. Then at the `AnimalCommunity` level, the update might do something like:
for this_name, these_cohorts in self.cohorts.items():
    # generate new cohorts for this functional group
    new_cohorts_for_name = [chrt.reproduce() for chrt in these_cohorts if chrt.can_reproduce()]
    # potentially merge those new cohorts (all age=0) if we don't care
    # (currently/ever) about maternal and paternal effects.
    self.cohorts[this_name].extend(new_cohorts_for_name)

I don't think there's any issue with the content of this method, but it logically feels like it should be a step further in?

_Originally posted by @davidorme in https://github.com/ImperialCollegeLondon/virtual_rainforest/pull/198#discussion_r1196301394_

davidorme commented 7 months ago

Closed as outdated by model development