-
Notifications
You must be signed in to change notification settings - Fork 24
sensitivity analysis branch #1913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
JoeWaddell
wants to merge
93
commits into
dev
Choose a base branch
from
sobol
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
93 commits
Select commit
Hold shift + click to select a range
a0aab1c
tasks updated
JoeWaddell 30e440e
added sobol sampler
JoeWaddell b5c7ef1
sobol1k run
JoeWaddell 828b889
analytical methods and new input files
JoeWaddell 40c8fba
analysis updates
JoeWaddell 3acd668
analysis updates only inputs
JoeWaddell d5b4db0
inputs_to_collate analysis
JoeWaddell 538b81a
outputs_to_collate
JoeWaddell 693747f
analysis updates- bugfix
JoeWaddell c6be8cc
analyze SA updates
JoeWaddell 3577b42
Merge branch 'main' into sobol
JoeWaddell 908bfd1
updated inputs
JoeWaddell 1f90393
morris analysis
JoeWaddell 7e22e0d
input bound updates
JoeWaddell e29dee3
removed cull params from inputs, updated task manager metadata
JoeWaddell 28d49e9
tasks update
JoeWaddell 3e949b8
added minimum new stall size of 1
JoeWaddell 9bc9c32
updated minimums in test sobol animal tasks
JoeWaddell 159d605
minimum daily milk of 1 kg
JoeWaddell f9ff78b
added Catastrophic ration formulation error
JoeWaddell 7a32110
added bound clipping
JoeWaddell 570c8b4
analysis updates
JoeWaddell 0f45153
ration fixes from other branches
JoeWaddell 0ddee70
another task file
JoeWaddell af726fc
exploratory analysis updates
JoeWaddell 96054f8
fix for gestation_length - AnimalBase.config["days_in_preg_when_dry"]
JoeWaddell f46ef5a
try_catch
matthew7838 35de46f
try_catch
matthew7838 ed9260f
return
matthew7838 338b782
Revert "return"
matthew7838 58e73cd
Revert "try_catch"
matthew7838 112e777
return
matthew7838 79735d6
checkout
matthew7838 16ee562
removing the try catch
matthew7838 ac9c764
input file updates
JoeWaddell 1f4c513
Merge branch 'sobol' of https://github.com/RuminantFarmSystems/MASM i…
JoeWaddell 64b0593
Merge branch 'dev' into sobol
JoeWaddell e71c439
Merge 64b05932504da818c87f75e4c5d744b09a793401 into ea84f288f884aa53f…
JoeWaddell 1b256d5
Apply Black Formatting
github-actions[bot] 51cc63e
Update badges on README
JoeWaddell 2a17534
fixing lfkae8 errors
JoeWaddell 7837069
Merge branch 'sobol' of https://github.com/RuminantFarmSystems/MASM i…
JoeWaddell 3c77433
Merge 783706940e31bc1397102b60e9312a29321ac21f into ea84f288f884aa53f…
JoeWaddell 61d3b51
Apply Black Formatting
github-actions[bot] 8e8e2d8
Update badges on README
JoeWaddell d3b40fd
Merge branch 'dev' into sobol
JoeWaddell c839f58
Merge d3b40fde7a385654e0e00439cd20baffbb4b7733 into 1fac8c1b6231eb3a8…
JoeWaddell ba6cafa
Apply Black Formatting
github-actions[bot] dcb53b9
Update badges on README
JoeWaddell fdcbddc
updated optimizer to catch warnings and correct RUP
JoeWaddell 1f164f2
updated MP calcs in ration driver
JoeWaddell b435f59
added catch in requirements for complex number
JoeWaddell e23fdcf
days_in_preg_when_dry temporary fix
JoeWaddell dfe133a
temp fix self.days_in_preg >= self.gestation_length
JoeWaddell ae2e0d6
changed days_in_preg_when_dry bound
JoeWaddell f059c5f
Merge branch 'dev' into sobol
JoeWaddell 91be788
Merge f059c5ffb592174ba8c49bc71d749bb8bf1d0d80 into e3a36c4aeaa869f3b…
JoeWaddell 8c5c301
Apply Black Formatting
github-actions[bot] d3e6ed7
Update badges on README
JoeWaddell 9f3a26d
updated task file for benchmark
JoeWaddell 39c2fc7
Merge branch 'sobol' of https://github.com/RuminantFarmSystems/MASM i…
JoeWaddell e792ed2
Merge 39c2fc773a593e9cd27b354743cac238ab02fd7b into e3a36c4aeaa869f3b…
JoeWaddell 4105a44
Apply Black Formatting
github-actions[bot] 5f41535
adjusted protein upper limit factor
JoeWaddell 41f60cf
Merge 5f41535c2e3f07b854f68cd9194388e1daf5b032 into e3a36c4aeaa869f3b…
JoeWaddell befd0bf
Apply Black Formatting
github-actions[bot] 6154655
updated feed prices
JoeWaddell 2198d9f
Merge branch 'sobol' of https://github.com/RuminantFarmSystems/MASM i…
JoeWaddell efd501c
Create get_runtime.py
allisterakun 1cde023
added crude util logic to accept numerical dict key
JoeWaddell 053b3b0
updated crude in progress analytical scripts
JoeWaddell 46c9785
updated tasks file and metadata
JoeWaddell 22169d9
analytical updates
JoeWaddell b7d6afc
updated and reorganized analysis scripts
JoeWaddell c4e0c9f
updated for benchmarking
JoeWaddell e5c338f
updated names, balancing
JoeWaddell df11084
Merge branch 'dev' into sobol
JoeWaddell 712a151
moved analytical scripts, archived old input sheets
JoeWaddell 4cd1cc0
brought feed back to dev
JoeWaddell c467424
reverting defaults
JoeWaddell bafd5ba
Merge c467424f00846b13084c32fa015f6915b522acb3 into 72cb55044cb51716d…
JoeWaddell 776ba0e
Apply Black Formatting
github-actions[bot] 5ae3cae
Update badges on README
JoeWaddell 6598021
updated useful analytical scripts, removed deprecated
JoeWaddell 45f70a4
Merge branch 'sobol' of https://github.com/RuminantFarmSystems/MASM i…
JoeWaddell 7d6a2e7
Merge 45f70a4b67f0120ad05cd42feff301d038ac5500 into 72cb55044cb51716d…
JoeWaddell ef45950
Apply Black Formatting
github-actions[bot] 09540e1
removed debugging statements
JoeWaddell 66c8a3b
Merge branch 'sobol' of https://github.com/RuminantFarmSystems/MASM i…
JoeWaddell ba5349c
Merge 66c8a3bce2d29a7484128ea9342393bef5e916af into 72cb55044cb51716d…
JoeWaddell 67b5aa6
Apply Black Formatting
github-actions[bot] cdddff5
updating bounds
JoeWaddell a684903
Merge branch 'sobol' of https://github.com/RuminantFarmSystems/MASM i…
JoeWaddell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -390,7 +390,7 @@ def milking_update(self, sim_day: int, calving_interval: int | float) -> None: | |
| Journal of Dairy Science, Volume 105, Issue 9, 2022, | ||
| Pages 7525-7538, ISSN 0022-0302. | ||
| """ | ||
| if self.days_in_preg == AnimalBase.config["days_in_preg_when_dry"]: | ||
| if self.days_in_preg >= AnimalBase.config["days_in_preg_when_dry"]: | ||
| self.milking = False | ||
| self.events.add_event(self.days_born, sim_day, const.DRY) | ||
| self.days_in_milk = 0 | ||
|
|
@@ -716,9 +716,13 @@ def get_bw_change(self, CI: int | float) -> float: # noqa | |
| if self.days_in_preg == AnimalBase.config["days_in_preg_when_dry"] - 1: | ||
| self.tissue_changed = 40 * self.days_in_milk / 70 * math.exp(1 - self.days_in_milk / 70) | ||
| else: # dry period | ||
| bodyweight_tissue = self.tissue_changed / ( | ||
| self.gestation_length - AnimalBase.config["days_in_preg_when_dry"] | ||
| ) | ||
| # TODO | ||
| try: | ||
| bodyweight_tissue = self.tissue_changed / ( | ||
| self.gestation_length - AnimalBase.config["days_in_preg_when_dry"] | ||
| ) | ||
| except Exception as e: | ||
| bodyweight_tissue = 0.0 | ||
|
||
|
|
||
| return target_adg_cow + conceptus_growth + bodyweight_tissue | ||
|
|
||
|
|
@@ -748,7 +752,7 @@ def update(self, sim_day: int, calving_interval: int | float) -> bool: # noqa | |
| new_born = False | ||
| self.days_born += 1 | ||
|
|
||
| if self.days_in_preg > 0 and self.days_in_preg == self.gestation_length: | ||
| if self.days_in_preg > 0 and self.days_in_preg >= self.gestation_length: | ||
| self._repro_state_manager.reset() | ||
| self.calves += 1 | ||
| self.milking = True | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| """ | ||
| This script simply checks the runtimes for all simulations that have been run. | ||
| Useful for benchmarking when running large batches of simulations, especially sensitivity analyses. | ||
| """ | ||
|
|
||
| import json | ||
| import os | ||
|
|
||
| import numpy as np | ||
|
|
||
| logs_dir = "output/logs/" | ||
|
|
||
| logs_files = [log_file for log_file in os.listdir(logs_dir) if "logs" in log_file and "benchmark" in log_file] | ||
|
|
||
| run_times = [] | ||
|
|
||
| for log_file in logs_files: | ||
| with open(logs_dir + log_file) as log_fp: | ||
| log_dict = json.load(log_fp) | ||
| run_times.append(float(log_dict["SimulationEngine.simulate.total_simulation_time"]["values"][0].split(": ")[1])) | ||
|
|
||
| print(np.mean(run_times)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| { | ||
| "herd_information": { | ||
| "calf_num": 800, | ||
| "heiferI_num": 4400, | ||
| "heiferII_num": 3800, | ||
| "heiferIII_num_springers": 500, | ||
| "cow_num": 10000, | ||
| "replace_num": 50000, | ||
| "herd_num": 10000, | ||
| "breed": "HO", | ||
| "parity_fractions": { | ||
| "1": 0.386, | ||
| "2": 0.281, | ||
| "3": 0.333 | ||
| }, | ||
| "annual_milk_yield": null | ||
| }, | ||
| "herd_initialization": { | ||
| "initial_animal_num": 10000, | ||
| "simulation_days": 5000 | ||
| }, | ||
| "animal_config": { | ||
| "management_decisions": { | ||
| "breeding_start_day_h": 380, | ||
| "heifer_repro_method": "ED", | ||
| "cow_repro_method": "ED-TAI", | ||
| "semen_type": "conventional", | ||
| "days_in_preg_when_dry": 218, | ||
| "heifer_repro_cull_time": 500, | ||
| "do_not_breed_time": 185, | ||
| "cull_milk_production": 30, | ||
| "cow_times_milked_per_day": 3, | ||
| "milk_fat_percent": 4, | ||
| "milk_protein_percent": 3.2 | ||
| }, | ||
| "farm_level": { | ||
| "calf": { | ||
| "male_calf_rate_sexed_semen": 0.1, | ||
| "male_calf_rate_conventional_semen": 0.53, | ||
| "keep_female_calf_rate": 1, | ||
| "wean_day": 60, | ||
| "wean_length": 7, | ||
| "milk_type": "whole" | ||
| }, | ||
| "repro": { | ||
| "voluntary_waiting_period": 50, | ||
| "conception_rate_decrease": 0.026, | ||
| "decrease_conception_rate_in_rebreeding": false, | ||
| "decrease_conception_rate_by_parity": false, | ||
| "avg_gestation_len": 276, | ||
| "std_gestation_len": 6, | ||
| "prefresh_day": 21, | ||
| "calving_interval": 400, | ||
| "heifers": { | ||
| "estrus_detection_rate": 0.9, | ||
| "estrus_conception_rate": 0.6, | ||
| "repro_sub_protocol": "5dCG2P", | ||
| "repro_sub_properties": { | ||
| "conception_rate": 0.6, | ||
| "estrus_detection_rate": 0.9 | ||
| } | ||
| }, | ||
| "cows": { | ||
| "estrus_detection_rate": 0.6, | ||
| "ED_conception_rate": 0.5, | ||
| "presynch_program": "Double OvSynch", | ||
| "presynch_program_start_day": 50, | ||
| "ovsynch_program": "OvSynch 56", | ||
| "ovsynch_program_start_day": 64, | ||
| "ovsynch_program_conception_rate": 0.6, | ||
| "resynch_program": "TAIafterPD" | ||
| } | ||
| }, | ||
| "bodyweight": { | ||
| "birth_weight_avg_ho": 43.9, | ||
| "birth_weight_std_ho": 1, | ||
| "birth_weight_avg_je": 27.2, | ||
| "birth_weight_std_je": 1, | ||
| "target_heifer_preg_day": 399, | ||
| "mature_body_weight_avg": 740.1, | ||
| "mature_body_weight_std": 73.5 | ||
| } | ||
| }, | ||
| "from_literature": { | ||
| "repro": { | ||
| "preg_check_day_1": 32, | ||
| "preg_loss_rate_1": 0.02, | ||
| "preg_check_day_2": 60, | ||
| "preg_loss_rate_2": 0.096, | ||
| "preg_check_day_3": 200, | ||
| "preg_loss_rate_3": 0.017, | ||
| "avg_estrus_cycle_return": 23, | ||
| "std_estrus_cycle_return": 6, | ||
| "avg_estrus_cycle_heifer": 21, | ||
| "std_estrus_cycle_heifer": 2.5, | ||
| "avg_estrus_cycle_cow": 21, | ||
| "std_estrus_cycle_cow": 4, | ||
| "avg_estrus_cycle_after_pgf": 5, | ||
| "std_estrus_cycle_after_pgf": 2 | ||
| }, | ||
| "culling": { | ||
| "cull_day_count": [0, 5, 15, 45, 90, 135, 180, 225, 270, 330, 380, 430, 480, 530], | ||
| "feet_leg_cull": { | ||
| "probability": 0.1633, | ||
| "cull_day_prob": [0, 0.03, 0.08, 0.16, 0.25, 0.36, 0.48, 0.59, 0.69, 0.78, 0.85, 0.90, 0.95, 1] | ||
| }, | ||
| "injury_cull": { | ||
| "probability": 0.2883, | ||
| "cull_day_prob": [0, 0.08, 0.18, 0.28, 0.38, 0.47, 0.56, 0.64, 0.71, 0.78, 0.85, 0.90, 0.95, 1] | ||
| }, | ||
| "mastitis_cull": { | ||
| "probability": 0.2439, | ||
| "cull_day_prob": [0, 0.06, 0.12, 0.19, 0.30, 0.43, 0.56, 0.68, 0.78, 0.85, 0.90, 0.94, 0.97, 1] | ||
| }, | ||
| "disease_cull": { | ||
| "probability": 0.1391, | ||
| "cull_day_prob": [0, 0.04, 0.12, 0.24, 0.34, 0.42, 0.50, 0.57, 0.64, 0.72, 0.81, 0.89, 0.95, 1] | ||
| }, | ||
| "udder_cull": { | ||
| "probability": 0.0645, | ||
| "cull_day_prob": [0, 0.12, 0.24, 0.33, 0.41, 0.48, 0.55, 0.62, 0.68, 0.76, 0.82, 0.89, 0.95, 1] | ||
| }, | ||
| "unknown_cull": { | ||
| "probability": 0.1009, | ||
| "cull_day_prob": [0, 0.05, 0.11, 0.18, 0.27, 0.37, 0.45, 0.54, 0.62, 0.70, 0.77, 0.84, 0.92, 1] | ||
| }, | ||
| "parity_death_prob": [0.039,0.056,0.085,0.117], | ||
| "parity_cull_prob": [0.169, 0.233, 0.301, 0.408], | ||
| "death_day_prob": [0, 0.18, 0.32, 0.42, 0.48, 0.54, 0.60, 0.65, 0.70, 0.77, 0.83, 0.89, 0.95, 1] | ||
| }, | ||
| "life_cycle": { | ||
| "still_birth_rate": 0.065 | ||
| } | ||
| } | ||
| }, | ||
| "methane_mitigation": { | ||
| "methane_mitigation_method": "None", | ||
| "methane_mitigation_additive_amount": 0, | ||
| "3-NOP_additive_amount": 70, | ||
| "monensin_additive_amount": 24, | ||
| "essential_oils_additive_amount": 0, | ||
| "seaweed_additive_amount": 0 | ||
| }, | ||
| "housing": "barn", | ||
| "pasture_concentrate": 0, | ||
| "methane_model": "IPCC", | ||
| "ration": { | ||
| "phosphorus_requirement_buffer": 0, | ||
| "user_input": false, | ||
| "formulation_interval": 30 | ||
| }, | ||
| "pen_information": [ | ||
| { | ||
| "id": 0, | ||
| "pen_name": "", | ||
| "animal_combination": "CALF", | ||
| "vertical_dist_to_milking_parlor": 0.1, | ||
| "horizontal_dist_to_milking_parlor": 10, | ||
| "number_of_stalls": 3000, | ||
| "housing_type": "open air barn", | ||
| "pen_type": "freestall", | ||
| "max_stocking_density": 1.2, | ||
| "manure_management_scenario_id": 0 | ||
| }, | ||
| { | ||
| "id": 1, | ||
| "pen_name": "", | ||
| "animal_combination": "GROWING", | ||
| "vertical_dist_to_milking_parlor": 0.1, | ||
| "horizontal_dist_to_milking_parlor": 10, | ||
| "number_of_stalls": 12500, | ||
| "housing_type": "open air barn", | ||
| "pen_type": "freestall", | ||
| "max_stocking_density": 1.2, | ||
| "manure_management_scenario_id": 1 | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "pen_name": "", | ||
| "animal_combination": "CLOSE_UP", | ||
| "vertical_dist_to_milking_parlor": 0.1, | ||
| "horizontal_dist_to_milking_parlor": 10, | ||
| "number_of_stalls": 6000, | ||
| "housing_type": "open air barn", | ||
| "pen_type": "freestall", | ||
| "max_stocking_density": 1.2, | ||
| "manure_management_scenario_id": 2 | ||
| }, | ||
| { | ||
| "id": 3, | ||
| "pen_name": "", | ||
| "animal_combination": "LAC_COW", | ||
| "vertical_dist_to_milking_parlor": 0.1, | ||
| "horizontal_dist_to_milking_parlor": 10, | ||
| "number_of_stalls": 15000, | ||
| "housing_type": "open air barn", | ||
| "pen_type": "freestall", | ||
| "max_stocking_density": 1.2, | ||
| "manure_management_scenario_id": 5 | ||
| } | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's no linked issue to this, either the issue should be created or the comment should be deleted.