# NOT RUN {
# The examples provided here are illustration of how to set up and run sensitivity
# analyses. Even though they are stripped-down minimalist examples, they each still
# take about 45 min to run.
# --------------------------------------------------------------------------
# }
# NOT RUN {
# Load the 2003-2013 version of the North Sea model supplied with the package:
model <- e2e_read("North_Sea", "1970-1999")
#
# Run the sensitivity analysis process (a quick demonstration):
# WARNING - Running a full sensitivity analysis takes days of computer time on a single
# machine/processor because it involves a huge number of model runs.
# The example below is just a (relatively) quick minimalist demonstration and should NOT
# be taken as the basis for any analysis or conclusions.
# Even so, this minimalist demonstration run could take 45 min to complete because it
# involves 1353 model runs.
# This examples uses the likelihood of observed target data as the criterion for assessing
# model sensitivity (i.e. outID is not set and so assumes the default value of 0).
sens_results <- e2e_run_sens(model, nyears=1, n_traj=3, csv.output=FALSE)
# View the top few rows of the results dataframe:
head(sens_results)
# }
# NOT RUN {
# --------------------------------------------------------------------------
# To view the list of available criteria for use as the basis for the sensitivity analysis:
e2e_get_senscrit()
# --------------------------------------------------------------------------
# }
# NOT RUN {
# This examples uses the annual average mass of planktivorous fish as the criterion for
assessing model sensitivity (i.e. outID = 24).
sens_results <- e2e_run_sens(model, nyears=1, n_traj=3, csv.output=FALSE, outID=24)
# View the top few rows of the results dataframe:
head(sens_results)
# }
# NOT RUN {
# --------------------------------------------------------------------------
# This is a dummy example to illustrate a more realistic sensitivity analysis:
# sens_results <- e2e_run_sens(model, nyears=50, n_traj=16, postprocess=TRUE,csv.output=TRUE)
# DO NOT launch this configuration unless you are prepared to wait many days for the results
# --------------------------------------------------------------------------
# }
# NOT RUN {
# Example of parallelizing the process:
# Launch two (or more) runs separately on different processors, with results directed to a
# temporary folder. Set results.path="Yourfolder" to run operataionally.
# Launch batch 1 (on processor 1):
model1 <- e2e_read("North_Sea", "1970-1999", model.ident="BATCH1")
sens_results1 <- 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_results1 <- 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)
# Plot a diagram of parameter sensitivities from the combined data
e2e_plot_sens_mc(model3, selection="SENS", use.example=FALSE)
# }
# NOT RUN {
# --------------------------------------------------------------------------
# }
Run the code above in your browser using DataLab