[Animal] Add Warning for Milk Production Reduction#3099
Open
allisterakun wants to merge 11 commits into
Open
Conversation
Contributor
|
Current Coverage: 99% Mypy errors on milk_production_reduction_warnings branch: 1144 |
Contributor
|
🚨 Please update the changelog. This PR cannot be merged until |
Contributor
|
Current Coverage: % Mypy errors on milk_production_reduction_warnings branch: 1144 |
Contributor
|
🚨 Some tests have failed. |
Contributor
|
Current Coverage: 99% Mypy errors on milk_production_reduction_warnings branch: 1144 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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