Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
e88fb45
Update changelog.md
allisterakun Feb 5, 2026
66ac5b1
Update changelog.md
allisterakun Feb 5, 2026
2ab48cd
Merge branch 'dev' into genetics_implementation
allisterakun Feb 5, 2026
b8536f4
Revert "Merge branch 'dev' into genetics_implementation"
allisterakun Feb 10, 2026
1f723ab
2721
allisterakun Feb 10, 2026
afd4baf
manure sync with dev
allisterakun Feb 10, 2026
f6b50a2
Merge branch 'dev' into genetics_implementation
allisterakun Feb 10, 2026
ef499f2
Merge f6b50a2751afe8b71e77c0b9ce6160bb6a96524c into 2f73b6a8e7abf5588…
allisterakun Feb 10, 2026
3e1c3e0
Apply Black Formatting
github-actions[bot] Feb 10, 2026
36e8c62
Update badges on README
allisterakun Feb 10, 2026
16486e5
Merge branch 'dev' into genetics_implementation
allisterakun Feb 11, 2026
fe775e1
Merge 16486e56232cf155ca13de7d596d44c91b35df7e into 6e54aeb1e8d42e1b9…
allisterakun Feb 11, 2026
9e20d2a
Apply Black Formatting
github-actions[bot] Feb 11, 2026
86fb626
Update badges on README
allisterakun Feb 11, 2026
e72c006
Update input_manager.py
allisterakun Mar 23, 2026
879fda1
Merge branch 'dev' into genetics_implementation
allisterakun Mar 23, 2026
7be9224
Merge 879fda17c62e388b2beed75b916961b3d2f6d4ba into 19a697be425755d8b…
allisterakun Mar 23, 2026
e67e054
Apply Black Formatting
github-actions[bot] Mar 23, 2026
64c0432
Update badges on README
allisterakun Mar 23, 2026
df3d25c
update all file paths to `TopListingSemen_HO.csv`
allisterakun Mar 25, 2026
a77ad58
Merge branch 'dev' into genetics_implementation
allisterakun Mar 25, 2026
2ae07a5
Merge a77ad5882b07b1854d3e6c5e93a7dbae5315a972 into 6b1bf25ddea38a70d…
allisterakun Mar 25, 2026
be8aa0d
Apply Black Formatting
github-actions[bot] Mar 25, 2026
957d1cd
fix broken unit tests
allisterakun Mar 25, 2026
8111ec8
Merge 957d1cdace856c0ac8895937ddf6c142bfdcde7c into 6b1bf25ddea38a70d…
allisterakun Mar 25, 2026
f0a104d
Apply Black Formatting
github-actions[bot] Mar 25, 2026
97cabc1
Update badges on README
allisterakun Mar 25, 2026
723fff6
mypy error fix part 1
allisterakun Mar 25, 2026
7e31b68
Merge 723fff696880856ffb51a03bef86686fd888cd6a into 6b1bf25ddea38a70d…
allisterakun Mar 25, 2026
9f7f834
Apply Black Formatting
github-actions[bot] Mar 25, 2026
0ff5420
Update badges on README
allisterakun Mar 25, 2026
c1f2b25
flake8
allisterakun Mar 25, 2026
f7e4df9
Merge c1f2b25fcb4037d438f528107b5bf66532090186 into 6b1bf25ddea38a70d…
allisterakun Mar 25, 2026
a1ec6da
Apply Black Formatting
github-actions[bot] Mar 25, 2026
c19bc07
Update badges on README
allisterakun Mar 25, 2026
4ef57b3
compress genetic history and reduce runtime
allisterakun Apr 1, 2026
65ac834
merge conflicts
allisterakun Apr 1, 2026
6ef30a2
Merge 65ac83421883f0bd0e0472160f6912ed994f4243 into 7b090b9c17b481f1c…
allisterakun Apr 1, 2026
33b41d8
Apply Black Formatting
github-actions[bot] Apr 1, 2026
f24a75b
Update badges on README
allisterakun Apr 1, 2026
d113542
Merge branch 'dev' into genetics_implementation
allisterakun Apr 6, 2026
e30178a
Merge d113542366f7db4dd02b8cbd094bea3a0e9b5dc3 into f794363cc15eba689…
allisterakun Apr 6, 2026
de2e829
Apply Black Formatting
github-actions[bot] Apr 6, 2026
7455957
Update badges on README
allisterakun Apr 6, 2026
9c56868
clamp birthdates and raise only one warning
allisterakun Apr 6, 2026
4dedce8
Merge 9c56868e35a4dd4f8bd92eee604769e74bfa4af0 into f794363cc15eba689…
allisterakun Apr 6, 2026
a0a7ffc
Apply Black Formatting
github-actions[bot] Apr 6, 2026
0adf58c
Introduce on-off switch for Genetics submodule
allisterakun Apr 6, 2026
03fe344
Merge branch 'dev' into genetics_implementation
allisterakun Apr 6, 2026
6cc82dd
Merge 03fe3446924a6ac849be897f56a371f5cbc42ba4 into 1320c3c98b8f80e55…
allisterakun Apr 6, 2026
b0dcf74
Apply Black Formatting
github-actions[bot] Apr 6, 2026
f4a3a2e
Update badges on README
allisterakun Apr 6, 2026
6e0b6dd
Update example_freestall_animal.json
allisterakun Apr 6, 2026
1ccad33
Merge branch 'genetics_implementation' of https://github.com/Ruminant…
allisterakun Apr 6, 2026
1ef922d
Skip genetic history reporting when genetics is turned off
allisterakun Apr 8, 2026
1cfc3ae
update `simulate_genetics` location and set default to false
allisterakun Apr 14, 2026
d26efad
unit tests
allisterakun Apr 14, 2026
7759165
Merge branch 'dev' into genetics_implementation
allisterakun Apr 15, 2026
87d2273
Merge 7759165f442d920a40ebeff8f734a7308ae135e4 into e5083e9ade04c972d…
allisterakun Apr 15, 2026
d0cea73
Apply Black Formatting
github-actions[bot] Apr 15, 2026
49bd80d
Update badges on README
allisterakun Apr 15, 2026
0e039ce
flake8
allisterakun Apr 15, 2026
ba952d7
Merge branch 'dev' into genetics_implementation
allisterakun Apr 15, 2026
e6ad90f
Merge ba952d778ed02c2ec73391d1724545508ad99131 into 5fa2e6f84c970ce31…
allisterakun Apr 15, 2026
c2f0a8a
Apply Black Formatting
github-actions[bot] Apr 15, 2026
8ee6d7e
Update badges on README
allisterakun Apr 15, 2026
60ca0cc
mypy
allisterakun Apr 15, 2026
dd63ce7
Merge 60ca0cc273c1a64acdcb75b2fb11fe57cdb6c80f into 5fa2e6f84c970ce31…
allisterakun Apr 15, 2026
b77241b
Apply Black Formatting
github-actions[bot] Apr 15, 2026
65d4d46
Update badges on README
allisterakun Apr 15, 2026
7858c10
update E_temporary std and correlation values
allisterakun Apr 15, 2026
00b3f7f
Merge branch 'genetics_implementation' of https://github.com/Ruminant…
allisterakun Apr 15, 2026
0605612
Merge 00b3f7fc716d2677a391f4171bbc70330eaaa4d0 into 5fa2e6f84c970ce31…
allisterakun Apr 15, 2026
52f7221
Apply Black Formatting
github-actions[bot] Apr 15, 2026
e65794f
remove comments
allisterakun Apr 15, 2026
b1ea4a0
Merge branch 'genetics_implementation' of https://github.com/Ruminant…
allisterakun Apr 15, 2026
c971be8
Merge b1ea4a0bb923b5851a9015fa09c715593a937e47 into 5fa2e6f84c970ce31…
allisterakun Apr 15, 2026
19f5452
Apply Black Formatting
github-actions[bot] Apr 15, 2026
0fb2f7a
Merge branch 'dev' into genetics_implementation
allisterakun Apr 16, 2026
952d574
Merge 0fb2f7a7fa9ba58ad5b0086605f872354598451a into 609e7b5cdc3fa9aed…
allisterakun Apr 16, 2026
ff27c44
Apply Black Formatting
github-actions[bot] Apr 16, 2026
e780baa
Update test_animal.py
allisterakun Apr 16, 2026
ddef102
Merge branch 'genetics_implementation' of https://github.com/Ruminant…
allisterakun Apr 16, 2026
f4e2915
Merge ddef102db7b1180db1ddaa16c31b0cb2bea32e11 into 609e7b5cdc3fa9aed…
allisterakun Apr 16, 2026
795691d
Apply Black Formatting
github-actions[bot] Apr 16, 2026
32550c0
Update badges on README
allisterakun Apr 16, 2026
53447fd
Merge branch 'dev' into genetics_implementation
matthew7838 Apr 16, 2026
8c65c32
Merge 53447fdfde8ea61b006255d1c0dc86b4690303f2 into 194023d0779c866e0…
allisterakun Apr 16, 2026
b992d40
Apply Black Formatting
github-actions[bot] Apr 16, 2026
222eec1
implement Matthew's comment
allisterakun Apr 16, 2026
39194f1
Merge 222eec1ca15fe6bd983e9d7ec17fbfd17cbdd485 into 194023d0779c866e0…
allisterakun Apr 16, 2026
c1ddec4
Apply Black Formatting
github-actions[bot] Apr 16, 2026
e636f11
update e2e
allisterakun Apr 16, 2026
d921073
Merge e636f11d88229c071f108a5c1ba196c27346e70b into 194023d0779c866e0…
allisterakun Apr 16, 2026
52a8769
Apply Black Formatting
github-actions[bot] Apr 16, 2026
6899e48
Update badges on README
allisterakun Apr 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Flake8](https://img.shields.io/badge/Flake8-passed-brightgreen)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Pytest](https://img.shields.io/badge/Pytest-passed-brightgreen)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Coverage](https://img.shields.io/badge/Coverage-99%25-brightgreen)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Mypy](https://img.shields.io/badge/Mypy-1190%20errors-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Mypy](https://img.shields.io/badge/Mypy-1180%20errors-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)


# RuFaS: Ruminant Farm Systems
Expand Down
236 changes: 191 additions & 45 deletions RUFAS/biophysical/animal/animal.py

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions RUFAS/biophysical/animal/animal_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ class AnimalConfig:

milk_reduction_maximum: float

average_phenotype: dict[str, dict[int, float]] = {}
top_listing_semen: dict[str, dict[str, float]] = {}
simulate_genetics: bool = False

@classmethod
def initialize_animal_config(cls) -> None:
"""Initialize the animal config from the input manager user input data."""
Expand Down Expand Up @@ -527,3 +531,18 @@ def initialize_animal_config(cls) -> None:
"function": "initialize_animal_config",
},
)

average_phenotype = im.get_data("animal_mean_phenotype")
cls.average_phenotype = {
trait: dict(zip(average_phenotype["birth_year"], values))
for trait, values in average_phenotype.items()
if trait != "birth_year"
}

top_listing_semen = im.get_data("animal_top_listing_semen")
cls.top_listing_semen = {
trait: dict(zip(top_listing_semen["year_month"], values))
for trait, values in top_listing_semen.items()
if trait != "year_month"
}
cls.simulate_genetics = animal_data["herd_information"]["simulate_genetics"]
650 changes: 387 additions & 263 deletions RUFAS/biophysical/animal/animal_genetics/animal_genetics.py

Large diffs are not rendered by default.

114 changes: 100 additions & 14 deletions RUFAS/biophysical/animal/animal_module_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from dataclasses import asdict
from typing import Any

from RUFAS.biophysical.animal.animal_config import AnimalConfig
from RUFAS.biophysical.animal.animal_genetics.animal_genetics import UNITS as genetics_units
from RUFAS.biophysical.animal.data_types.animal_events import AnimalEvents
from RUFAS.biophysical.animal.data_types.animal_population import AnimalPopulationStatistics
from RUFAS.biophysical.animal.data_types.animal_typed_dicts import SoldAnimalTypedDict, StillbornCalfTypedDict
Expand Down Expand Up @@ -160,22 +162,77 @@ def report_milk(cls, milk_reports: list[MilkProductionStatistics], simulation_da
"class": AnimalModuleReporter.__name__,
"function": AnimalModuleReporter.report_milk.__name__,
"data_origin": [("MilkProduction", "perform_daily_milking_update")],
"units": MilkProductionStatistics.UNITS,
"units": (
(MilkProductionStatistics.UNITS | MilkProductionStatistics.GENETIC_UNITS)
if AnimalConfig.simulate_genetics
else MilkProductionStatistics.UNITS
),
}

for milk_stats in milk_reports:
updated_milk_data: dict[str, int | float] = asdict(milk_stats)
updated_milk_data["is_milking"] = milk_stats.is_milking
updated_milk_data["estimated_daily_milk_produced"] = milk_stats.estimated_daily_milk_produced
updated_milk_data["milk_protein"] = milk_stats.milk_protein
updated_milk_data["milk_fat"] = milk_stats.milk_fat
updated_milk_data["milk_lactose"] = milk_stats.milk_lactose
updated_milk_data["parity"] = milk_stats.parity
updated_milk_data["cow_id"] = milk_stats.cow_id
updated_milk_data["pen_id"] = milk_stats.pen_id
updated_milk_data["simulation_day"] = simulation_day
updated_milk_data: dict[str, int | float | str] = {
"cow_id": milk_stats.cow_id,
"pen_id": milk_stats.pen_id,
"is_milking": milk_stats.is_milking,
"days_in_milk": milk_stats.days_in_milk,
"estimated_daily_milk_produced": milk_stats.estimated_daily_milk_produced,
"milk_protein": milk_stats.milk_protein,
"milk_fat": milk_stats.milk_fat,
"milk_lactose": milk_stats.milk_lactose,
"parity": milk_stats.parity,
"simulation_day": simulation_day,
}
if AnimalConfig.simulate_genetics:
updated_milk_data["days_born"] = milk_stats.days_born
updated_milk_data["days_in_pregnancy"] = milk_stats.days_in_pregnancy
updated_milk_data["animal_type"] = milk_stats.animal_type.name
updated_milk_data["TBV_fat"] = milk_stats.TBV_fat
updated_milk_data["TBV_protein"] = milk_stats.TBV_protein
updated_milk_data["E_permanent_fat"] = milk_stats.E_permanent_fat
updated_milk_data["E_permanent_protein"] = milk_stats.E_permanent_protein
updated_milk_data["E_temporary_fat"] = milk_stats.E_temporary_fat
updated_milk_data["E_temporary_protein"] = milk_stats.E_temporary_protein
updated_milk_data["phenotype_fat"] = milk_stats.phenotype_fat
updated_milk_data["phenotype_protein"] = milk_stats.phenotype_protein
updated_milk_data["EBV_fat"] = milk_stats.EBV_fat
updated_milk_data["EBV_protein"] = milk_stats.EBV_protein
updated_milk_data["ranking_index"] = milk_stats.ranking_index

om.add_variable("milk_data_at_milk_update", updated_milk_data, info_map)

@classmethod
def report_average_genetics(
cls, average_genetics: dict[str, float | None], variable_name_prefix: str, simulation_day: int
) -> None:
"""
Reports the average genetics data with associated simulation metadata. The
method adds the given genetics data to a managed output variable, using
a specific variable name prefix and simulation day.

Parameters
----------
average_genetics : dict[str, float | None]
A dictionary containing genetic measurements, where the key is
the measurement name and the value is the averaged measurement.
variable_name_prefix : str
A prefix to be appended to the variable name for distinguishing
the reported data in the output.
simulation_day : int
The specific day in the simulation timeline, used to annotate the
reported data for temporal tracking.

Returns
-------
None
"""
info_map = {
"class": AnimalModuleReporter.__name__,
"function": AnimalModuleReporter.report_average_genetics.__name__,
"units": genetics_units,
"simulation_day": simulation_day,
}
om.add_variable(f"{variable_name_prefix}_average_genetics", average_genetics, info_map)

@classmethod
def report_ration_per_animal(
cls,
Expand Down Expand Up @@ -929,6 +986,9 @@ def report_sold_animal_information(cls, herd_statistics: HerdStatistics) -> None
)
om.add_variable("days_in_milk", animal["days_in_milk"], dict(info_map, **{"units": MeasurementUnits.DAYS}))
om.add_variable("parity", animal["parity"], dict(info_map, **{"units": MeasurementUnits.UNITLESS}))
om.add_variable(
"genetic_history", animal["genetic_history"], dict(info_map, **{"units": MeasurementUnits.UNITLESS})
)

@classmethod
def report_stillborn_calves_information(
Expand Down Expand Up @@ -1094,6 +1154,7 @@ def report_end_of_simulation(
time: RufasTime,
heiferII_events_by_id: dict[str, AnimalEvents],
cow_events_by_id: dict[str, AnimalEvents],
all_animals_genetic_history: dict[int, str],
) -> None:
"""
Calls all reporter methods that should happen at the end of the simulation.
Expand All @@ -1110,8 +1171,21 @@ def report_end_of_simulation(
The dictionary of HeiferII events.
cow_events_by_id : dict[str, AnimalEvents]
The dictionary of Cow events.
all_animals_genetic_history : dict[int, str]
The dict of genetic histories for all animals in the herd by their IDs.
"""
empty_sold_animals: list[SoldAnimalTypedDict] = [{"sold_at_day": 0, "body_weight": 0}]
empty_sold_animals: list[SoldAnimalTypedDict] = [
{
"id": 0,
"animal_type": "",
"sold_at_day": 0,
"body_weight": 0.0,
"cull_reason": None,
"days_in_milk": 0,
"parity": 0,
"genetic_history": "",
}
]
AnimalModuleReporter.report_sold_animal_information(herd_statistics)
if herd_statistics.sold_calves_info:
AnimalModuleReporter.report_sold_animal_information_sort_by_sell_day(
Expand Down Expand Up @@ -1184,15 +1258,17 @@ def report_end_of_simulation(

AnimalModuleReporter._record_heiferIIs_conception_rate(herd_reproduction_statistics)
AnimalModuleReporter._record_cows_conception_rate(herd_reproduction_statistics)
if AnimalConfig.simulate_genetics:
AnimalModuleReporter._report_all_animals_genetic_history(all_animals_genetic_history)

@classmethod
def _record_animal_events(cls, animal_events_by_id: dict[str, str], simulation_day: int) -> None:
def _record_animal_events(cls, animal_events_by_id: dict[str, AnimalEvents], simulation_day: int) -> None:
"""
Record the events of the animals.

Parameters
----------
animal_events_by_id : dict[str, str]
animal_events_by_id : dict[str, AnimalEvents]
A dictionary of animal events, where the key is a string containing the animal id and the animal type,
and the value is the string representation of the events of the animal.
simulation_day : int
Expand Down Expand Up @@ -1308,6 +1384,16 @@ def _record_cows_conception_rate(cls, herd_reproduction_statistics: HerdReproduc
dict(info_map, **{"units": MeasurementUnits.CONCEPTIONS_PER_SERVICE}),
)

@classmethod
def _report_all_animals_genetic_history(cls, all_animals_genetic_history: dict[int, str]) -> None:
"""Report all animals genetic history."""
info_map = {
"class": AnimalModuleReporter.__name__,
"function": AnimalModuleReporter._report_all_animals_genetic_history.__name__,
"units": MeasurementUnits.UNITLESS,
}
om.add_variable("animals_genetic_history", all_animals_genetic_history, info_map)

@classmethod
def report_animal_population_statistics(cls, prefix: str, herd_summary: AnimalPopulationStatistics) -> None:
"""Reports the herd summary statistics for the starting animal population."""
Expand Down
9 changes: 3 additions & 6 deletions RUFAS/biophysical/animal/data_types/animal_typed_dicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class CalfValuesTypedDict(TypedDict):
wean_weight: float
mature_body_weight: float
events: str
net_merit: float
initial_phosphorus: NotRequired[float]
body_weight_history: NotRequired[list[BodyWeightHistory]]
pen_history: NotRequired[list[PenHistory]]
Expand All @@ -36,7 +35,8 @@ class NewBornCalfValuesTypedDict(TypedDict):
days_born: int
birth_weight: float
initial_phosphorus: float
net_merit: float
dam_tbv_fat: NotRequired[float]
dam_tbv_protein: NotRequired[float]
body_weight_history: NotRequired[list[BodyWeightHistory]]
pen_history: NotRequired[list[PenHistory]]
conceptus_weight: NotRequired[float]
Expand All @@ -55,7 +55,6 @@ class HeiferIValuesTypedDict(TypedDict):
wean_weight: float
mature_body_weight: float
events: str
net_merit: float
body_weight_history: NotRequired[list[BodyWeightHistory]]
pen_history: NotRequired[list[PenHistory]]
conceptus_weight: NotRequired[float]
Expand All @@ -74,7 +73,6 @@ class HeiferIIValuesTypedDict(TypedDict):
wean_weight: float
mature_body_weight: float
events: str
net_merit: float
body_weight_history: NotRequired[list[BodyWeightHistory]]
pen_history: NotRequired[list[PenHistory]]
conceptus_weight: NotRequired[float]
Expand Down Expand Up @@ -109,7 +107,6 @@ class HeiferIIIValuesTypedDict(TypedDict):
wean_weight: float
mature_body_weight: float
events: str
net_merit: float
body_weight_history: NotRequired[list[BodyWeightHistory]]
pen_history: NotRequired[list[PenHistory]]
conceptus_weight: NotRequired[float]
Expand Down Expand Up @@ -144,7 +141,6 @@ class CowValuesTypedDict(TypedDict):
wean_weight: float
mature_body_weight: float
events: str
net_merit: float
body_weight_history: NotRequired[list[BodyWeightHistory]]
pen_history: NotRequired[list[PenHistory]]
conceptus_weight: NotRequired[float]
Expand Down Expand Up @@ -186,6 +182,7 @@ class SoldAnimalTypedDict(TypedDict):
cull_reason: str | None
days_in_milk: int | str
parity: int | str
genetic_history: str


class StillbornCalfTypedDict(TypedDict):
Expand Down
33 changes: 33 additions & 0 deletions RUFAS/biophysical/animal/data_types/genetic_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from typing import TypedDict

from RUFAS.biophysical.animal.data_types.animal_types import AnimalType


class GeneticHistory(TypedDict):
"""
A class to represent the genetic history of an individual animal on a farm.

This class is used to track the genetic attributes of an animal over the course of a simulation.
It contains information about the simulation day, the age of the animal in days, and its genetic attributes.

Attributes
----------
start_day : int
The simulation day corresponding to the start of the genetic record of the animal.
end_day : int
The simulation day corresponding to the end of the genetic record of the animal.
id : int
The unique identifier of the animal.
animal_type : AnimalType
The type of animal.
genetics: dict[str, float]
Dictionary containing the genetic attributes of the animal.
"""

start_day: int
end_day: int

id: int
animal_type: AnimalType

genetics: dict[str, float]
61 changes: 61 additions & 0 deletions RUFAS/biophysical/animal/data_types/milk_production.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dataclasses import dataclass

from RUFAS.biophysical.animal.data_types.animal_events import AnimalEvents
from RUFAS.biophysical.animal.data_types.animal_types import AnimalType
from RUFAS.units import MeasurementUnits


Expand Down Expand Up @@ -76,6 +77,34 @@ class MilkProductionStatistics:
The daily lactose content in the milk produced by the animal, (kg/day).
parity : int
The number of claves the cow has given birth, (unitless).
days_born : int
The number of days since the birth of the animal, (days).
days_in_pregnancy : int
The number of days since the animal has been pregnant, (days).
animal_type : AnimalType
The type of animal, (unitless).
TBV_fat : float or None
The True Breed Value for fat of the animal, (kg). Defaults to None.
TBV_protein : float or None
The True Breed Value for protein of the animal, (kg). Defaults to None.
E_permanent_fat : float or None
The Permanent Environment Effect for fat of the animal, (kg). Defaults to None.
E_permanent_protein : float or None
The Permanent Environment Effect for protein of the animal, (kg). Defaults to None.
E_temporary_fat : float or None
The Temporary Environment Effect for fat of the animal, (kg). Defaults to None.
E_temporary_protein : float or None
The Temporary Environment Effect for protein of the animal, (kg). Defaults to None.
phenotype_fat : float or None
The fat phenotype of the animal, (kg). Defaults to None.
phenotype_protein : float or None
The protein phenotype of the animal, (kg). Defaults to None.
EBV_fat : float or None
The Estimated Breeding Value for fat of the animal, (kg). Defaults to None.
EBV_protein : float or None
The Estimated Breeding Value for protein of the animal, (kg). Defaults to None.
ranking_index : float or None
The ranking index of the animal, (unitless). Defaults to None.
"""

cow_id: int
Expand All @@ -86,6 +115,22 @@ class MilkProductionStatistics:
milk_fat: float
milk_lactose: float
parity: int
days_born: int
days_in_pregnancy: int
animal_type: AnimalType

TBV_fat: float | None = None
TBV_protein: float | None = None
E_permanent_fat: float | None = None
E_permanent_protein: float | None = None

E_temporary_fat: float | None = None
E_temporary_protein: float | None = None
phenotype_fat: float | None = None
phenotype_protein: float | None = None
EBV_fat: float | None = None
EBV_protein: float | None = None
ranking_index: float | None = None
Comment thread
allisterakun marked this conversation as resolved.

UNITS = {
"cow_id": MeasurementUnits.UNITLESS,
Expand All @@ -99,6 +144,22 @@ class MilkProductionStatistics:
"is_milking": MeasurementUnits.UNITLESS,
"simulation_day": MeasurementUnits.SIMULATION_DAY,
}
GENETIC_UNITS = {
"days_born": MeasurementUnits.DAYS,
"days_in_pregnancy": MeasurementUnits.DAYS,
"animal_type": MeasurementUnits.UNITLESS,
"TBV_fat": MeasurementUnits.KILOGRAMS,
"TBV_protein": MeasurementUnits.KILOGRAMS,
"E_permanent_fat": MeasurementUnits.KILOGRAMS,
"E_permanent_protein": MeasurementUnits.KILOGRAMS,
"E_temporary_fat": MeasurementUnits.KILOGRAMS,
"E_temporary_protein": MeasurementUnits.KILOGRAMS,
"phenotype_fat": MeasurementUnits.KILOGRAMS,
"phenotype_protein": MeasurementUnits.KILOGRAMS,
"EBV_fat": MeasurementUnits.KILOGRAMS,
"EBV_protein": MeasurementUnits.KILOGRAMS,
"ranking_index": MeasurementUnits.UNITLESS,
}

@property
def is_milking(self) -> bool:
Expand Down
Loading