[Animal] Adds farm-specific genetic distribution inputs to herd_information - #3257
matthew7838 wants to merge 17 commits into
Conversation
…formation Exposes the CDCB national-average standard deviations and correlations of the TBV, permanent environmental, and temporary environmental distributions as optional animal inputs (herd_information) that default to the CDCB values when omitted. Genetics reads them from AnimalConfig instead of module constants.
|
Current Coverage: 99% Mypy errors on genetic-input-expansion branch: 1164 |
|
🚨 Please update the changelog. This PR cannot be merged until |
|
Current Coverage: 99% Mypy errors on genetic-input-expansion branch: 1164 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
allisterakun
left a comment
There was a problem hiding this comment.
LGTM! Very straight-forward changes
|
Current Coverage: 99% Mypy errors on genetic-input-expansion branch: 1164 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
Current Coverage: 99% Mypy errors on genetic-input-expansion branch: 1164 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
|
Current Coverage: 99% Mypy errors on genetic-input-expansion branch: 1164 |
|
🚨 Unauthorized changes detected in protected files. Please remove these changes if they are not intended. |
Adds the standard deviations and correlations of the genetic distributions used by the
Geneticssubmodule as optional, farm-specific animal inputs. When they are omitted the CDCB national-average values that were previously hard-coded are used, so existing input files run unchanged.Context
Issue(s) closed by this pull request: closes #2512
Follows up on the Genetics implementation in #2734.
What
herd_informationsection of the animal input, each defaulting to the CDCB national average indefault.json:tbv_fat_std(25.8 kg),tbv_protein_std(13.4 kg),tbv_correlation(0.59)permanent_environment_fat_std(38.8 kg),permanent_environment_protein_std(20.1 kg),permanent_environment_correlation(0.95)temporary_environment_fat_std(64.5 kg),temporary_environment_protein_std(33.4 kg),temporary_environment_correlation(0.78)AnimalConfigattributes (class defaults = CDCB values) and reads them inAnimalConfig.initialize_animal_config().Geneticsnow draws TBV, permanent environmental effect, and temporary environmental effect values from theAnimalConfigdistribution parameters instead of the module-level constants, which are removed. The newborn-calf TBV spread and the EBV estimation noise use the sameAnimalConfigTBV standard deviations.example_freestall_animal.jsonandexample_open_lot_animal.json.test_animal_genetics.py(parametrized default vs. farm-specific cases for TBV, E_permanent, E_temporary, newborn-calf TBV, and EBV noise) andtest_animal_config.py(sharedherd_informationfixture plus a test that the nine inputs are read).Why
The TBV, permanent environmental, and temporary environmental variances were hard-coded to the CDCB national averages, so farms with their own genetic evaluation could not use farm-specific values (#2512). The mean phenotype (μ_phenotype) from the same issue is already a user-supplied input through the
animal_mean_phenotypeCSV blob (by birth year), so no new input was added for it; the alternative of deriving it fromannual_milk_yieldand the milk fat/protein percentages raised in the issue discussion is left for the Animal Module discussion noted there.How
*_stdanimal inputs and theGeneticsimplementation (the variance is the square of the standard deviation). Each bivariate (fat, protein) distribution needs both standard deviations and its correlation, so the correlations are exposed alongside the variances.herd_informationnext tosimulate_geneticsrather than in a nested object because only string/number/bool properties are auto-filled from their metadata default when missing; a missing nested object would fail validation for existing input files.minimum: 0and correlations at[-1, 1]in the metadata; out-of-range values are repaired to the default with the usual validator warning.Genetics._calculate_ebv_values()scales the EBV noise by the TBV standard deviation rather than its variance. It now reads that value fromAnimalConfig, but the formula itself was left as-is so default-input outputs are identical.Test plan
InputManagerload of the freestall e2e inputs with a scratch animal file: with the nine keys removed, the pool andAnimalConfigreceive the CDCB defaults (validator logs "data fixed ... from None to 25.8" etc.); with custom values they are passed through; withtbv_fat_std = -3andtbv_correlation = 1.5both are repaired to the defaults with warnings.Input Changes
RUFAS/input/metadata/properties/default.json: nine new optional number properties underanimal_properties.herd_information(listed above), each with a CDCB default.input/data/animal/example_freestall_animal.jsonandinput/data/animal/example_open_lot_animal.json: the nine keys added at their default values.Output Changes
Filter