Skip to content

888 animal model foraging time budget#906

Merged
TaranRallings merged 6 commits intodevelopfrom
888-animal-model---foraging-time-budget
Jun 20, 2025
Merged

888 animal model foraging time budget#906
TaranRallings merged 6 commits intodevelopfrom
888-animal-model---foraging-time-budget

Conversation

@TaranRallings
Copy link
Copy Markdown
Collaborator

Description

This PR fixes a bug where the time allocated to foraging was being reused such that the more types of resources a cohort foraged on, the more time it had to forage. Each diet-type was given the full "work-day" to forage on.

The fix takes the available time and divides it equally among the different resource types of resources can forage on. So if you consume just animals, animal foraging gets the whole time. If you consume animals and plants, each get half of the time, and so on.

Changes:

  • DietType.count_dietary_categories()
  • AnimalCohort.diet_category_count
  • Revised time logic in AnimalCohort.forage_cohort()
  • Revised tests

Fixes # (issue)

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works
  • Relevant documentation reviewed and updated

@TaranRallings TaranRallings self-assigned this Jun 19, 2025
@TaranRallings TaranRallings linked an issue Jun 19, 2025 that may be closed by this pull request
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 19, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 93.96%. Comparing base (422be4c) to head (1843cb7).
Report is 7 commits behind head on develop.

Files with missing lines Patch % Lines
virtual_ecosystem/models/animal/animal_cohorts.py 66.66% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #906   +/-   ##
========================================
  Coverage    93.96%   93.96%           
========================================
  Files           77       77           
  Lines         5861     5862    +1     
========================================
+ Hits          5507     5508    +1     
  Misses         354      354           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code-wise, this looks totally fine. I'm curious about the science of it, though. I bet there're diet that animals consume only as a last resort if there's nothing else available, right? I understand that might be hard to model, though.

@TaranRallings
Copy link
Copy Markdown
Collaborator Author

Code-wise, this looks totally fine. I'm curious about the science of it, though. I bet there're diet that animals consume only as a last resort if there's nothing else available, right? I understand that might be hard to model, though.

You're absolutely right. In real life, animal diets are diversely weighted at any particular moment and, broadly, quite adaptive. I spent a big chunk of my doctoral work on this problem in herbivores.

The plan for animal diets its to stage out the complexity over time, particularly as we see how run-time is looking:

  1. flat herbivore/carnivore distinction
  2. highly resolved, equally weighted, non-adaptive
  3. highly resolved, diversely weighted, non-adaptive
  4. highly resolved, diversely weighted, adaptive

We have just moved from stage 1 -> stage 2. It is currently unclear whether our final destination is stage 3 (a standard, defensible approach) or stage 4 (more state-of-the-art).

Moving to an weighting system with functional groups requires some additional scientific work so I'll tackle it after the basic version is up and running.

@TaranRallings TaranRallings merged commit 21a5636 into develop Jun 20, 2025
16 checks passed
@TaranRallings TaranRallings deleted the 888-animal-model---foraging-time-budget branch January 9, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Animal Model - foraging time budget

3 participants