Conversation
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1677 |
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1740 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1739 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
Original PR: #2608 |
|
I just tried to run the branch as-is, and got the following error (pasted below). Looks like input manager is still looking for animal_net_merit in the metadata? |
Should be fixed now! |
|
Current Coverage: % Mypy errors on genetics_implementation branch: 1269 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
…FarmSystems/RuFaS into genetics_implementation
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1169 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1169 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
matthew7838
left a comment
There was a problem hiding this comment.
LGTM, left a bunch of comments, but they are minor. Be sure to update e2e filters again before merging, since the herd size management PR was merged yesterday, and that likely changes some outputs. Nice work, Allister.
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1169 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
Current Coverage: 99% Mypy errors on genetics_implementation branch: 1180 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
Implements the Genetics submodule into the Animal module, replacing the simple
net_meritattribute with a fullGeneticsclass that tracks true breeding values (TBV), estimated breeding values (EBV), phenotypes, and environmental effects for fat and protein traits.Context
Issue(s) closed by this pull request: closes issue #2511 (a sub-issue under #2614), #2838.
Original PR: #2608. See previous discussion there.
Documentation
Design doc (last updated Dec 2, 2025)
Genetics Technical Solutions (last updated Apr 15, 2026)
Ongoing documentation issue: Scientific Documentation: Animal Genetics Update #2943
What
Geneticsclass into theAnimalclass, replacing thenet_meritfloat attribute with a full genetics model tracking TBV, EBV, phenotypes, permanent/temporary environmental effects, and a ranking index for fat and protein traits.GeneticHistorydata type andupdate_genetic_historymethod onAnimalto record genetic state at each simulation day.AnimalConfigto loadaverage_phenotypeandtop_listing_semendatasets during initialization.Animal.__init__to accept aRufasTimeobject instead of asimulation_dayinteger, and to initializeGeneticsdifferently for newborn calves (with optional dam TBV values) vs. existing animals.MilkProductionStatisticsto include genetic attributes (TBV, EBV, phenotype, environmental effects, ranking index).ReproductionInputsto passdam_tbv_fatanddam_tbv_proteininstead ofnet_merit.net_meritfrom all animal typed dicts (CalfValuesTypedDict,HeiferI/II/IIIValuesTypedDict,CowValuesTypedDict).animal_net_meritfromREQUIRED_FILE_BLOBSininput_manager.py.NetMerit_HO.csv,TopListingSemen_HO.csv,mean_phenotype.csv) intoinput/data/animal/animal_genetics/.default.jsonproperties file with genetics-related configuration.simulation_engine.py,herd_factory.py,herd_manager.py, andanimal_module_reporter.pyto accommodate the new genetics integration.RufasTimeparameter, and removednet_meritreferences.util.pywith supporting changes.Why
The previous implementation used a single
net_meritfloat value to represent animal genetics, which was an oversimplification. The newGeneticssubmodule provides a biologically meaningful representation of animal genetics by modeling true breeding values, estimated breeding values, phenotypes, and environmental effects for milk fat and protein traits. This enables more accurate simulation of genetic progress, selection decisions, and milk production variability within the herd.How
The
Geneticsclass computes TBV, EBV, phenotypes, and environmental effects based on birth year, animal type, parity, and optional dam genetic values. For newborn calves with known dam TBV values, genetics are initialized using parental inheritance. For all other animals (existing herd or calves without dam data), genetics are initialized based on population-level data fromaverage_phenotypeandtop_listing_semendatasets loaded intoAnimalConfig. TheAnimalconstructor now requires aRufasTimeobject to determine birth year/month for genetic initialization. Genetic state is tracked over time viaGeneticHistoryrecords appended each simulation day. Thenet_meritfield has been fully replaced by theranking_indexcomputed within theGeneticsclass.Test plan
test_animal.py,test_animal_config.py,test_herd_factory.py,test_herd_manager_daily_routines.py,test_herd_manager_herd_statistics.py,test_animal_module_reporter.py,test_milk_production.py,test_reproduction.py, andtest_simulation_engine.pyto accommodate the newGeneticsintegration andRufasTimeparameter.test_animal_genetics.pyfor theGeneticsclass.Input Changes
input/data/animal/animal_genetics/NetMerit_HO.csv,input/data/animal/animal_genetics/TopListingSemen_HO.csvinput/data/animal_genetics/TopListingSemen_HO.csv,input/data/animal_genetics/mean_phenotype.csv(moved to new location underinput/data/animal/animal_genetics/)freestall_e2e_metadata.json,open_lot_e2e_metadata.json,no_animal_e2e_metadata.json,example_freestall_dairy_metadata.json,example_open_lot_metadata.json,example_no_animal_metadata.json)input/metadata/properties/default.jsonupdated with genetics-related properties.Output Changes
Animal.genetics: NewGeneticsobject replacing thenet_meritfloat attribute.Animal.genetic_history: New list ofGeneticHistoryrecords tracking genetic state over time.Animal.milk_statistics: Now includesTBV_fat,TBV_protein,E_permanent_fat,E_permanent_protein,E_temporary_fat,E_temporary_protein,phenotype_fat,phenotype_protein,EBV_fat,EBV_protein,ranking_index.Animal.net_merit: Removed fromAnimaland all animal typed dicts.Filter
Genetics History
"AnimalModuleReporter._report_all_animals_genetic_history.*"Daily Milk
"AnimalModuleReporter.report_milk.*"Daily Average Genetics (Herd, Calves, HeiferIs, HeiferIIs, HeiferIIIs, Cows)
"AnimalModuleReporter.report_average_genetics.*"