Skip to content

Commit

Permalink
change to avoid division by 0
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgiddyaboutgit committed Dec 12, 2023
1 parent ec4224a commit 101983c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data/factor_chart.tsv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
experimental_unit factor_name factor_description role_in_simulation min_level max_level other_constraints
realm initial_ proportion_not_desert This is the initial proportion of ecoregions within the realm which are currently within a biome of “Deserts & Xeric Shrublands” but were historically within a different biome. This accounts for desertification. The map used is based on current biomes. However, the simulation starts with some of the ecoregions currently within desert biomes possibly being any kind of grassland, “Temperate Broadleaf & Mixed Forests” or “Temperate Conifer Forests”. As the simulation progresses, these can switch to present-day desert. 0 1 none
realm initial_proportion_not_desert This is the initial proportion of ecoregions within the realm which are currently within a biome of “Deserts & Xeric Shrublands” but were historically within a different biome. This accounts for desertification. The map used is based on current biomes. However, the simulation starts with some of the ecoregions currently within desert biomes possibly being any kind of grassland, “Temperate Broadleaf & Mixed Forests” or “Temperate Conifer Forests”. As the simulation progresses, these can switch to present-day desert. 0 1 none
realm initial_pop_density_of_desert This is the initial population density per square mile in deserts within the realm. These densities are later converted to actual numbers of people. 0 0.3
realm initial_pop_density_of_tundra This is the initial population density per square mile in tundra within the realm. These densities are later converted to actual numbers of people. 0 0.3
realm/biome combo initial_pop_density_ratio This is the ratio of the initial population density per square mile in a biome within the realm to the mean of initial_pop_density_of_desert and initial_pop_density_of_tundra. This is used to set the initial_pop_density for each biome/realm combination (with the exception of combinations containing desert or tundra). 1 1000
Expand Down
2 changes: 1 addition & 1 deletion data/planning_matrix.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"earth" "location" "REALM" "BIOME_NAME" "ECO_NAME" "initial_agricultural_tech_level_in_use" "initial_healthcare_tech_level_in_use" "initial_housing_tech_level_in_use" "initial_transportation_tech_level_in_use" "initial_unaided_d_max_pop_density" "initial_unaided_not_dt_max_pop_density" "initial_unaided_t_max_pop_density" "initial_warfare_tech_level_in_use" "relevance_of_dist_based_on_transportation_tech_level" "initial_ proportion_not_desert" "initial_pop_density_of_desert" "initial_pop_density_of_tundra" "initial_pop_density_ratio" "initial_transition_probability_to_desert"
"earth" "location" "REALM" "BIOME_NAME" "ECO_NAME" "initial_agricultural_tech_level_in_use" "initial_healthcare_tech_level_in_use" "initial_housing_tech_level_in_use" "initial_transportation_tech_level_in_use" "initial_unaided_d_max_pop_density" "initial_unaided_not_dt_max_pop_density" "initial_unaided_t_max_pop_density" "initial_warfare_tech_level_in_use" "relevance_of_dist_based_on_transportation_tech_level" "initial_proportion_not_desert" "initial_pop_density_of_desert" "initial_pop_density_of_tundra" "initial_pop_density_ratio" "initial_transition_probability_to_desert"
1 0 "Afrotropic" "Deserts & Xeric Shrublands" "Aldabra Island xeric scrub" 0.126710341015072 0.0256497364983143 0.00381482871869235 0.228069580194573 0.22121591571063 9.34871423966954 0.213750523128646 0.060993416566427 8.77072102617198 0.796054549237499 0.3 0.165705089524733 62.4162049928453 0.0022325486817456
1 1 "Afrotropic" "Deserts & Xeric Shrublands" "Djibouti xeric shrublands" 0.34604 0.054555 0.064225 0.380625 0.0977975 9.597675 0.0573715 0.020765 -7.837 0.796054549237499 0.3 0.165705089524733 62.4162049928453 0.0022325486817456
1 2 "Afrotropic" "Deserts & Xeric Shrublands" "Eritrean coastal desert" 0.13156 0.022495 0.010395 0.148425 0.0138715 2.716825 0.2614735 0.077325 -1.721 0.796054549237499 0.3 0.165705089524733 62.4162049928453 0.0022325486817456
Expand Down
3 changes: 3 additions & 0 deletions src/sim_world_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from scipy import stats

def logistic_growth(previous_pop, r, carrying_cap):
if carrying_cap == 0:
carrying_cap = 0.1
return round(previous_pop + r * previous_pop * (1 - previous_pop / carrying_cap))


Expand Down Expand Up @@ -126,3 +128,4 @@ def prior_biomes_before_desertification(n, rng:np.random.Generator):
).tolist()

return past_biomes

0 comments on commit 101983c

Please sign in to comment.