# NOT RUN {
# The examples provided here are illustration of how to merge results from parallel
# sets of sensitivity or Monte Carlo analysis runs. Even though they are stripped-down
# minimalist examples they each still take a very long time to run.
# --------------------------------------------------------------------------
# Example of parallelizing the sensitivity analysis process.
# Here the model is only run for a 1 year each time and for 3 trajectories
# on each processor in order to illustrate the approach. A meaningful simulation
# would require many more years per run and more trajectories. Even so this
# example will be very time consuming.
# In the illustration here csv output is directed to a temporary folder since
# results.path is unspecified. To explore further, set up your own results folder and
# define results.path as relative to the current working directory.
# Launch two (or more) runs separately on different processors...
# Launch batch 1 (on processor 1):
model1 <- e2e_read("North_Sea", "1970-1999", model.ident="BATCH1")
sens_results <- e2e_run_sens(model1, nyears=1, n_traj=3, coldstart=TRUE,
postprocess=FALSE, csv.output=TRUE)
# Note that coldstart=TRUE for the first batch only.
# Launch batch 2 (on processor 2):
model2 <- e2e_read("North_Sea", "1970-1999", model.ident="BATCH2")
sens_results <- e2e_run_sens(model2, nyears=1, n_traj=3, coldstart=FALSE,
postprocess=FALSE, csv.output=TRUE)
# Note that these two runs return only raw data since postprocess=FALSE
#
# Then, afterwards, merge the two raw results files with text-tags BATCH1 and BATCH2,
# and post process the combined file:
model3 <- e2e_read("North_Sea", "1970-1999", model.ident="COMBINED")
processed_data <- e2e_merge_sens_mc(model3, selection="SENS",
ident.list<-c("BATCH1","BATCH2"), postprocess=TRUE, csv.output=TRUE)
# or...
combined_data <- e2e_merge_sens_mc(model3, selection="SENS",
ident.list<-c("BATCH1","BATCH2"), postprocess=FALSE, csv.output=TRUE)
processed_data <- e2e_process_sens_mc(model3, selection="SENS",
use.example=FALSE,csv.output=TRUE)
# }
# NOT RUN {
# --------------------------------------------------------------------------
# }
# NOT RUN {
# Example of parallelizing the Monte Carlo process:
# Here the model is only run for a 2 year each time and for a 5 (or 6) trajectories
# on each processor in order to illustrate the approach. A meaningful simulation
# would require many more years per run and more trajectories. Even so this
# example will be time consuming.
# In the illustration here csv output is directed to a temporary folder since
# results.path is unspecified. To explore further, set up your own results folder and
# define results.path as relative to the current working directory.
# Launch two (or more) runs separately on different processors...
# Launch batch 1 (on processor 1)
model1 <- e2e_read("North_Sea", "1970-1999", model.ident="BATCH1")
results1 <- e2e_run_mc(model1,nyears=2,baseline.mode=TRUE,
n_iter=5,csv.output=TRUE,postprocess=FALSE)
# Launch batch 2 (on processor 2):
model2 <- e2e_read("North_Sea", "1970-1999", model.ident="BATCH2")
results2 <- e2e_run_mc(model2,nyears=2,baseline.mode=TRUE,
n_iter=6,csv.output=TRUE,postprocess=FALSE)
# Note that these two runs return only raw data since postprocess=FALSE
# Note 6 iterations in batch 2 - the first iteration wil be stripped off at merging so the
# combined data should include only 10 iterations.
# Then, afterwards, merge the two raw results files with text-tags BATCH1 and BATCH2,
# and post process the combined file:
model3 <- e2e_read("North_Sea", "1970-1999", model.ident="COMBINED")
processed_data <- e2e_merge_sens_mc(model3, selection="MC",
ident.list<-c("BATCH1","BATCH2"), postprocess=TRUE, csv.output=TRUE)
# or...
combined_data <- e2e_merge_sens_mc(model3, selection="MC",
ident.list<-c("BATCH1","BATCH2"), postprocess=FALSE, csv.output=TRUE)
processed_data<-e2e_process_sens_mc(model3, selection="MC",use.example=FALSE,csv.output=TRUE)
# --------------------------------------------------------------------------
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab