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
8 changes: 4 additions & 4 deletions 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-1191%20errors-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Flake8](https://img.shields.io/badge/Flake8-failed-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Pytest](https://img.shields.io/badge/Pytest-failed-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Coverage](https://img.shields.io/badge/Coverage-%25-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)
[![Mypy](https://img.shields.io/badge/Mypy-1218%20errors-red)](https://github.com/RuminantFarmSystems/MASM/actions/workflows/combined_format_lint_test_mypy.yml)


# RuFaS: Ruminant Farm Systems
Expand Down
52 changes: 10 additions & 42 deletions RUFAS/biophysical/animal/herd_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,25 +498,21 @@ def _update_herd_structure(
removed_animals: list[Animal],
available_feeds: list[Feed],
current_day_conditions: CurrentDayConditions,
total_inventory: TotalInventory,
simulation_day: int,
) -> None:
"""Call the corresponding functions to update the herd structure and reassign animals to new pens."""
self._handle_graduated_animals(
graduated_animals, available_feeds, current_day_conditions, total_inventory, simulation_day
)
self._handle_newly_added_animals(
newborn_calves, available_feeds, current_day_conditions, total_inventory, simulation_day
)
self._handle_newly_added_animals(
newly_added_animals, available_feeds, current_day_conditions, total_inventory, simulation_day
)
self._handle_graduated_animals(graduated_animals, available_feeds, current_day_conditions, simulation_day)
self._handle_newly_added_animals(newborn_calves, available_feeds, current_day_conditions, simulation_day)
self._handle_newly_added_animals(newly_added_animals, available_feeds, current_day_conditions, simulation_day)

for removed_animal in removed_animals:
self._remove_animal_from_pen_and_id_map(removed_animal)

def daily_routines(
self, available_feeds: list[Feed], time: RufasTime, weather: Weather, total_inventory: TotalInventory
self,
available_feeds: list[Feed],
time: RufasTime,
weather: Weather,
) -> dict[str, ManureStream]:
"""
Perform daily routines for managing animal herds and updating associated data.
Expand All @@ -533,8 +529,6 @@ def daily_routines(
An instance of the RufasTime object representing the current time and simulation day.
weather : Weather
An object providing weather conditions affecting herd activities.
total_inventory : TotalInventory
Object representing the total inventory of herd-related resources.

Returns
-------
Expand Down Expand Up @@ -610,7 +604,6 @@ def daily_routines(
removed_animals=removed_animals,
available_feeds=available_feeds,
current_day_conditions=weather.get_current_day_conditions(time),
total_inventory=total_inventory,
simulation_day=time.simulation_day,
)

Expand Down Expand Up @@ -822,7 +815,6 @@ def _handle_graduated_animals(
graduated_animals: list[Animal],
available_feeds: list[Feed],
current_day_conditions: CurrentDayConditions,
total_inventory: TotalInventory,
simulation_day: int,
) -> None:
"""
Expand All @@ -836,25 +828,20 @@ def _handle_graduated_animals(
Nutrition information of feeds available to formulate animals rations with.
current_day_conditions : CurrentDayConditions
Object representing the current conditions of the day.
total_inventory : TotalInventory
Inventory currently available or projected to be available at a future date.
simulation_day : int
Day of simulation.

"""
for animal in graduated_animals:
self._remove_animal_from_pen_and_id_map(animal)
self._update_animal_array(animal)
self._add_animal_to_pen_and_id_map(
animal, available_feeds, current_day_conditions, total_inventory, simulation_day
)
self._add_animal_to_pen_and_id_map(animal, available_feeds, current_day_conditions, simulation_day)

def _handle_newly_added_animals(
self,
new_animals: list[Animal],
available_feeds: list[Feed],
current_day_conditions: CurrentDayConditions,
total_inventory: TotalInventory,
simulation_day: int,
) -> None:
"""
Expand All @@ -868,16 +855,12 @@ def _handle_newly_added_animals(
Nutrition information of feeds available to formulate animals rations with.
current_day_conditions : CurrentDayConditions
Object representing the current conditions of the day.
total_inventory : TotalInventory
Inventory currently available or projected to be available at a future date.
simulation_day: int
Day of simulation.

"""
for animal in new_animals:
self._add_animal_to_pen_and_id_map(
animal, available_feeds, current_day_conditions, total_inventory, simulation_day
)
self._add_animal_to_pen_and_id_map(animal, available_feeds, current_day_conditions, simulation_day)
self._add_animal_to_new_array(animal)

def _remove_animal_from_pen_and_id_map(self, animal: Animal) -> None:
Expand All @@ -900,7 +883,6 @@ def _add_animal_to_pen_and_id_map(
animal: Animal,
available_feeds: list[Feed],
current_day_conditions: CurrentDayConditions,
total_inventory: TotalInventory,
simulation_day: int,
) -> None:
"""
Expand All @@ -914,8 +896,6 @@ def _add_animal_to_pen_and_id_map(
Nutrition information of feeds available to formulate animals rations with.
current_day_conditions : CurrentDayConditions
Object representing the current conditions of the day.
total_inventory : TotalInventory
Inventory currently available or projected to be available at a future date.
simulation_day : int
Day of simulation.

Expand Down Expand Up @@ -944,7 +924,6 @@ def _add_animal_to_pen_and_id_map(
pen=pen_with_min_stocking_density,
pen_available_feeds=pen_available_feeds,
current_temperature=current_day_conditions.mean_air_temperature,
total_inventory=total_inventory,
simulation_day=simulation_day,
)

Expand Down Expand Up @@ -1364,8 +1343,6 @@ def update_all_max_daily_feeds(
The maximum daily feeds for each feed type.

"""
if not self.simulate_animals:
return IdealFeeds({})
for rufas_id in next_harvest_dates.keys():
self._update_single_max_daily_feed(rufas_id, next_harvest_dates[rufas_id], total_inventory, time)

Expand Down Expand Up @@ -1408,7 +1385,6 @@ def formulate_rations(
available_feeds: list[Feed],
current_temperature: float,
ration_interval_length: int,
total_inventory: TotalInventory,
simulation_day: int,
) -> RequestedFeed:
"""
Expand All @@ -1422,8 +1398,6 @@ def formulate_rations(
Current temperature (C).
ration_interval_length : int
Length of the ration interval (days).
total_inventory : TotalInventory
The total inventory of all available feeds.
simulation_day : int
Day of simulation.

Expand All @@ -1448,9 +1422,7 @@ def formulate_rations(
else:
ration_feed_ids = RationManager.get_ration_feeds(pen.animal_combination)
pen_available_feeds = self._find_pen_available_feeds(available_feeds, ration_feed_ids)
self._reformulate_ration_single_pen(
pen, pen_available_feeds, current_temperature, total_inventory, simulation_day
)
self._reformulate_ration_single_pen(pen, pen_available_feeds, current_temperature, simulation_day)
total_requested_feed += pen.get_requested_feed(ration_interval_length)
return total_requested_feed

Expand All @@ -1459,7 +1431,6 @@ def _reformulate_ration_single_pen(
pen: Pen,
pen_available_feeds: list[Feed],
current_temperature: float,
total_inventory: TotalInventory,
simulation_day: int,
) -> None:
"""
Expand All @@ -1473,8 +1444,6 @@ def _reformulate_ration_single_pen(
List of available feeds in this pen.
current_temperature : float
Current temperature (C).
total_inventory : TotalInventory
Inventory currently available or projected to be available at a future date.
simulation_day : int
Day of simulation.

Expand All @@ -1497,7 +1466,6 @@ def _reformulate_ration_single_pen(
current_temperature,
self._max_daily_feeds,
self.advance_purchase_allowance,
total_inventory,
simulation_day,
)

Expand Down
3 changes: 0 additions & 3 deletions RUFAS/biophysical/animal/pen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,6 @@ def formulate_optimized_ration( # noqa: C901
temperature: float,
max_daily_feeds: dict[RUFAS_ID, float],
advance_purchase_allowance: AdvancePurchaseAllowance,
total_inventory: TotalInventory,
simulation_day: int,
) -> None:
"""
Expand All @@ -1047,8 +1046,6 @@ def formulate_optimized_ration( # noqa: C901
Maximum amounts of each feed type that may be fed per animal per day.
advance_purchase_allowance : AdvancePurchaseAllowance
Maximum amounts of each feed type that may be purchased at the beginning of a feed interval.
total_inventory : TotalInventory
Amounts of feeds currently held in storage.
simulation_day : int
Day of simulation.

Expand Down
Loading