Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions RUFAS/biophysical/animal/animal_module_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ class AnimalModuleConstants:
MILK_LACTOSE: float = 4.85
"""Milk lactose content, percentage."""

DMI_CONSTRAINT_FRACTION: float = 0.30
DMI_CONSTRAINT_FRACTION: float = 0.00
"""The +/- fraction of DMI estimated allowed for ration formulation."""

DMI_REQUIREMENT_BOOST: float = 1.1
DMI_REQUIREMENT_BOOST: float = 1.0
"""The fraction of the dry matter intake requirement used as the basis for
the inclusion rate bounds in user defined ration formulation method."""

Expand Down
1 change: 1 addition & 0 deletions RUFAS/biophysical/animal/herd_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def __init__(

self.is_ration_defined_by_user = is_ration_defined_by_user
ration_feed_config = self.im.get_data("feed")
RationManager.lac_cow_dry_matter_intake = ration_feed_config["lac_cow_dry_matter_intake"]
if self.is_ration_defined_by_user:
RationManager.set_user_defined_rations(ration_feed_config)
RationManager.set_user_defined_ration_tolerance(ration_feed_config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from RUFAS.biophysical.animal.ration.amino_acid import AminoAcidCalculator
from RUFAS.general_constants import GeneralConstants
from RUFAS.user_constants import UserConstants
from RUFAS.biophysical.animal.ration.ration_manager import RationManager

from .nutrition_requirements_calculator import NutritionRequirementsCalculator

Expand Down Expand Up @@ -657,13 +658,16 @@ def _calculate_dry_matter_intake(

"""
if lactating:
parity_adjustment_factor = 1 if parity > 1 else 0
dry_matter_intake_estimate = (
(3.7 + parity_adjustment_factor * 5.7)
+ 0.305 * net_energy_lactation
+ 0.022 * body_weight
+ (-0.689 - 1.87 * parity_adjustment_factor) * body_condition_score_5
) * (1 - (0.212 + parity_adjustment_factor * 0.136) * exp(-0.053 * days_in_milk))
if RationManager.lac_cow_dry_matter_intake == 0:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JoeWaddell ! Do you think null might be a better design choice here?

null means "no value provided, use the model." 0 means zero — which is physically impossible.

It also eliminates the float comparison issue. == 0 on a float is fragile. if RationManager.lac_cow_dry_matter_intake is None is exact and unambiguous.

parity_adjustment_factor = 1 if parity > 1 else 0
dry_matter_intake_estimate = (
(3.7 + parity_adjustment_factor * 5.7)
+ 0.305 * net_energy_lactation
+ 0.022 * body_weight
+ (-0.689 - 1.87 * parity_adjustment_factor) * body_condition_score_5
) * (1 - (0.212 + parity_adjustment_factor * 0.136) * exp(-0.053 * days_in_milk))
else:
dry_matter_intake_estimate = RationManager.lac_cow_dry_matter_intake
else:
dry_matter_intake_estimate = (
0.0226 * mature_body_weight * (1 - exp(-1.47 * (body_weight / mature_body_weight)))
Expand Down
1 change: 1 addition & 0 deletions RUFAS/biophysical/animal/ration/ration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class RationManager:
user_defined_rations: dict[AnimalCombination, dict[RUFAS_ID, float]] | None
tolerance: float | None = 0.0
maximum_ration_reformulation_attempts: int
lac_cow_dry_matter_intake: float

@classmethod
def set_ration_feeds(cls, ration_config: dict[str, list[int]]) -> None:
Expand Down
1 change: 1 addition & 0 deletions input/data/feed/example_Midwest_feed.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
],
"tolerance": 0.1
},
"lac_cow_dry_matter_intake": 27,
"max_daily_feed_recalculations_per_year": 4,
"allowances": [
{
Expand Down
6 changes: 6 additions & 0 deletions input/metadata/properties/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -4375,6 +4375,12 @@
"maximum": 365,
"default": 4
},
"lac_cow_dry_matter_intake": {
"type": "number",
"description": "Fixed amount of dry matter intake (kg) for lactating cows. Set to 0 to use NASEM or NRC predicted dry matter intake.",
"minimum": 0,
"default": 0
},
"allowances": {
"type": "array",
"properties": {
Expand Down