Fixed simulation count error

This commit is contained in:
Alex Gebben Work 2025-12-15 11:53:31 -07:00
parent 9f0f3f9407
commit 80b23d6b3a
5 changed files with 37 additions and 18 deletions

View File

@ -167,7 +167,7 @@ SINGLE_SIM <- function(DEMO,BIRTH_DATA,ST_YEAR,YEARS_AHEAD,MIGRATION_ARIMA_MODEL
NCORES <- detectCores()-1 NCORES <- detectCores()-1
BATCH_SIZE <- NCORES*10 BATCH_SIZE <- NCORES*10
TOTAL_SIMULATIONS <- 10^6 TOTAL_SIMULATIONS <- 10^5
N_RUNS <-ceiling(TOTAL_SIMULATIONS/BATCH_SIZE ) N_RUNS <-ceiling(TOTAL_SIMULATIONS/BATCH_SIZE )
SIM_RES_FILE <- paste0(RES_SIM_DIR,"Kemmerer_2024_Upper_Bound_With_Data_Center_Simulation.csv") SIM_RES_FILE <- paste0(RES_SIM_DIR,"Kemmerer_2024_Upper_Bound_With_Data_Center_Simulation.csv")

View File

@ -167,10 +167,10 @@ SINGLE_SIM <- function(DEMO,BIRTH_DATA,ST_YEAR,YEARS_AHEAD,MIGRATION_ARIMA_MODEL
NCORES <- detectCores()-1 NCORES <- detectCores()-1
BATCH_SIZE <- NCORES*10 BATCH_SIZE <- NCORES*10
TOTAL_SIMULATIONS <- 10^6 TOTAL_SIMULATIONS <- 10^5
N_RUNS <-ceiling(TOTAL_SIMULATIONS/BATCH_SIZE ) N_RUNS <-ceiling(TOTAL_SIMULATIONS/BATCH_SIZE )
SIM_RES_FILE <- paste0(RES_SIM_DIR,"Kemmerer_2024_With_Lower_Bound_With_Data_Center_Simulation.csv") SIM_RES_FILE <- paste0(RES_SIM_DIR,"Kemmerer_2024_Lower_Bound_With_Data_Center_Simulation.csv")
NEW_RES_FILE <- !file.exists(SIM_RES_FILE) NEW_RES_FILE <- !file.exists(SIM_RES_FILE)
OPERATOR_LIN_MIGRATION <- OPERATORS %>% pull("Operator_Emp_Migrated") OPERATOR_LIN_MIGRATION <- OPERATORS %>% pull("Operator_Emp_Migrated")
CONSTRUCTION_LIN_MIGRATION <- CONSTRUCTION %>% pull("Construction_Emp_Migrated") CONSTRUCTION_LIN_MIGRATION <- CONSTRUCTION %>% pull("Construction_Emp_Migrated")

View File

@ -6,7 +6,7 @@ source("Scripts/Load_Custom_Functions/Fan_Chart_Creation_Functions.r") #Function
###Process the simulations and save the main percentile results by year ###Process the simulations and save the main percentile results by year
RES <- read_csv("Results/Simulations/Kemmerer_2024_With_Lower_Bound_With_Data_Center_Simulation.csv") RES <- read_csv("Results/Simulations/Kemmerer_2024_Lower_Bound_With_Data_Center_Simulation.csv")
RES[,"Year"] <- RES[,"Year"] RES[,"Year"] <- RES[,"Year"]
RES<- RES %>% filter(!is.na(Year)) RES<- RES %>% filter(!is.na(Year))
RES <- RES %>% filter(!is.na(Population)) RES <- RES %>% filter(!is.na(Population))

View File

@ -0,0 +1,5 @@
library(tidyverse)
read_csv("Kemmerer_2016_Simulation.csv") %>% filter(!is.na(Population),!is.na(Sim_UUID),!is.na(Year)) %>% pull(Sim_UUID) %>% unique %>% length()/10^5
read_csv("Kemmerer_2024_Upper_Bound_With_Data_Center_Simulation.csv") %>% filter(!is.na(Population),!is.na(Sim_UUID),!is.na(Year)) %>% pull(Sim_UUID) %>% unique %>% length()/10^5
read_csv("Kemmerer_2024_With_Lower_Bound_With_Data_Center_Simulation.csv") %>% filter(!is.na(Population),!is.na(Sim_UUID),!is.na(Year)) %>% pull(Sim_UUID) %>% unique %>% length()/10^5
read_csv("Kemmerer_2024_With_Data_Center_Simulation.csv") %>% filter(!is.na(Population),!is.na(Sim_UUID),!is.na(Year)) %>% pull(Sim_UUID) %>% unique %>% length()/10^5

View File

@ -1,21 +1,9 @@
#Run all simulations as needed. Comment out to skip any. All but the primary results have 10^5 simulations #Run all simulations as needed. Comment out to skip any. All but the primary results have 10^5 simulations
echo "Starting all model Simulations. This will take a while!!" echo "Starting all model Simulations. This will take a while!!"
#start_time=$(date +%s)
#Rscript 1A_Run_Full_Simulation_2016.r
#echo "Pre-2016 data simulations for benchmark complete! 100k simulations total"
# Your command or script here
#end_time=$(date +%s)
#elapsed_seconds=$((end_time - start_time))
#hours=$((elapsed_seconds / 3600))
#minutes=$(( (elapsed_seconds % 3600) / 60 ))
#seconds=$(( elapsed_seconds % 60 ))
#printf "Execution time: %02d hours, %02d minutes, %02d seconds\n" "$hours" "$minutes" "$seconds"
start_time=$(date +%s) start_time=$(date +%s)
Rscript 1C_Run_Simulation_Upper_Bound.r Rscript 1A_Run_Full_Simulation_2016.r
echo "Upper bound migration with county average migration rates complete! 100k simulations total" echo "Pre-2016 data simulations for benchmark complete! 100k simulations total"
end_time=$(date +%s) end_time=$(date +%s)
elapsed_seconds=$((end_time - start_time)) elapsed_seconds=$((end_time - start_time))
hours=$((elapsed_seconds / 3600)) hours=$((elapsed_seconds / 3600))
@ -24,6 +12,17 @@ seconds=$(( elapsed_seconds % 60 ))
printf "Execution time: %02d hours, %02d minutes, %02d seconds\n" "$hours" "$minutes" "$seconds" printf "Execution time: %02d hours, %02d minutes, %02d seconds\n" "$hours" "$minutes" "$seconds"
#start_time=$(date +%s)
#Rscript 1C_Run_Simulation_Upper_Bound.r
#echo "Upper bound migration with county average migration rates complete! 100k simulations total"
#end_time=$(date +%s)
#elapsed_seconds=$((end_time - start_time))
#hours=$((elapsed_seconds / 3600))
#minutes=$(( (elapsed_seconds % 3600) / 60 ))
#seconds=$(( elapsed_seconds % 60 ))
#printf "Execution time: %02d hours, %02d minutes, %02d seconds\n" "$hours" "$minutes" "$seconds"
start_time=$(date +%s) start_time=$(date +%s)
Rscript 1D_Run_Simulation_Lower_Bound.r Rscript 1D_Run_Simulation_Lower_Bound.r
echo "Lower bound migration with Kemmerere average migration rates complete! 100k simulations total" echo "Lower bound migration with Kemmerere average migration rates complete! 100k simulations total"
@ -46,3 +45,18 @@ minutes=$(( (elapsed_seconds % 3600) / 60 ))
seconds=$(( elapsed_seconds % 60 )) seconds=$(( elapsed_seconds % 60 ))
printf "Execution time: %02d hours, %02d minutes, %02d seconds\n" "$hours" "$minutes" "$seconds" printf "Execution time: %02d hours, %02d minutes, %02d seconds\n" "$hours" "$minutes" "$seconds"
start_time=$(date +%s)
Rscript 1D_Run_Simulation_Lower_Bound.r
Rscript 1D_Run_Simulation_Lower_Bound.r
Rscript 1A_Run_Full_Simulation_2016.r
Rscript 1A_Run_Full_Simulation_2016.r
Rscript 1D_Run_Simulation_Lower_Bound.r
Rscript 1A_Run_Full_Simulation_2016.r
echo "Extra simulations complete! 600k simulations total"
end_time=$(date +%s)
elapsed_seconds=$((end_time - start_time))
hours=$((elapsed_seconds / 3600))
minutes=$(( (elapsed_seconds % 3600) / 60 ))
seconds=$(( elapsed_seconds % 60 ))
printf "Execution time: %02d hours, %02d minutes, %02d seconds\n" "$hours" "$minutes" "$seconds"