[Animal] Add Warning for Milk Production Reduction#3099
Conversation
|
Current Coverage: 99% Mypy errors on milk_production_reduction_warnings branch: 1144 |
|
🚨 Please update the changelog. This PR cannot be merged until |
|
Current Coverage: % Mypy errors on milk_production_reduction_warnings branch: 1144 |
|
🚨 Some tests have failed. |
|
Current Coverage: 99% Mypy errors on milk_production_reduction_warnings branch: 1144 |
|
Current Coverage: 99% Mypy errors on milk_production_reduction_warnings branch: 1136 |
|
🚨 Please update the changelog. This PR cannot be merged until |
gmg228
left a comment
There was a problem hiding this comment.
This looks pretty straightforward to me.
I was easily able to test and successfully view the warning after toying with
(ration formulation (mild/moderate changes), threshold changes of reduced milk production coinciding with extreme ration changes, etc).
This is a clean solution that seems to function well.
Thank you!
|
Current Coverage: 99% Mypy errors on milk_production_reduction_warnings branch: 1136 |
|
🚨 Please update the changelog. This PR cannot be merged until |
Adds a summary warning in
HerdManager.formulate_rations()when any cows have had their milk production reduced due to ration formulation failure, reporting the number of affected animals and the average reduction in kg.Context
Issue(s) closed by this pull request: closes #1874.
What
formulate_rations()inherd_manager.py. After all pens have been reformulated, the method checks if any cows have amilk_production_reduction > 0. If so, it logs a warning viaOutputManager.add_warning()with the number of affected animals, the average reduction amount (in kg, formatted to 2 decimal places), and the simulation day.Why
When a ration cannot be formulated for a cow, the model reduces the cow's milk production to lower nutrient requirements and make formulation feasible. While the reduction amount is collected in the output variables, this was not immediately evident to the user during the simulation. Adding a once-per-ration-formulation-interval warning alerts users that milk production has been reduced, how many animals were affected, and by how much on average, making the behavior transparent without requiring the user to inspect output variables.
How
At the end of
formulate_rations(), after all pens have been reformulated, a list comprehension filtersself.cowsfor any cow withmilk_production.milk_production_reduction > 0. If the list is non-empty, the average reduction is computed and a warning is logged viaself.om.add_warning(). This runs once per ration formulation interval call, summarizing all affected cows in a single warning rather than emitting per-animal warnings.Test plan
Input Changes
Output Changes
Filter