# NOT RUN {
# Load the 1970-1999 version of the North Sea model supplied with the package and generate a
# quick test data object with only 8 iterations and running the model for only 3 years
# optimising activity rates to the database of observed indices of the state of the ecosystem.
# In this example, the final parameter values are not saved back to the model Param folder.
# More realistic would be at least 500 iterations and running for 50 years.
# Even so this example will take a few minutes to run:
model<-e2e_read(model.name="North_Sea",
model.variant="1970-1999",
model.ident="test")
# This model is already optimized to the observed ecosystem data supplied with the package.
# Here, so as to illustrate the optimization process in action, here we perturb the temperature
# driving data to knock the model away from its maximum likelihood state relative to the
# target data:
# add 3 degC to upper layer offshore temperatures:
model$data$physics.drivers$so_temp <- model$data$physics.drivers$so_temp+3
# add 3 degC to inshore temperatures:
model$data$physics.drivers$si_temp <- model$data$physics.drivers$si_temp+3
# add 3 degC to lower layer offshore temperatures:
model$data$physics.drivers$d_temp <- model$data$physics.drivers$d_temp+3
test_run <- e2e_optimize_act(model, selection="ECO", n_iter=8, start_temperature=0.4,
cooling=0.975, csv.output=FALSE, nyears=3 )
# View the structure of the returned list:
str(test_run,max.level=1)
# View the structure of the returned list element containing parameter objects:
str(test_run$new_parameter_data,max.level=1)
# View the new, final accepted parameter data:
test_run$new_parameter_data
# }
# NOT RUN {
# --------------------------------------------------------------------------
# This is a dummy example to illustrate a realistic run in which optimised
# parameters are written back to the model Param folder. To try it out substitute
# your own relative folder path in place of \Folder in the e2e_copy() function...
# WARNING - this will take about 26 hours to run...
# Copy the 1970-1999 version of the North Sea model supplied with the package into a
# user workspace relative to the current working directory (../Folder):
# e2e_copy("North_Sea", "1970-1999",
# dest.path="Folder")
# Load the copied version of the North Sea/1970-1999 model from the user workspace
# and assign a path for results data:
# (REPLACE "Folder/Models" and "Folder/results" with your own paths before running)
# model<-e2e_read(model.name="North_Sea",
# model.variant="1970-1999",
# models.path="Folder/Models",
# results.path="Folder/results",
# model.ident="fittingrun")
# Launch the fitting process
# fitting_data<-e2e_optimize_act(model, selection="ECO", n_iter=500,
# start_temperature=0.5, cooling=0.975, csv.output=TRUE, nyears=50)
# --------------------------------------------------------------------------
# }
# NOT RUN {
# Examples of using the function for optimizing to given zonal harvest ratios
model<-e2e_read(model.name="North_Sea",
model.variant="1970-1999",
model.ident="test")
# Activity rates in this model are already optimized to the target harvest ratios supplied with
# the package but we woud not expect to recover these values in this very short demonstration run
test_run <- e2e_optimize_act(model, selection="HR", n_iter=30, start_temperature=1.0,
cooling=0.985, csv.output=FALSE, n_traj=5)
# View the structure of the returned list:
str(test_run,max.level=1)
# View the structure of the returned list element containing parameter objects:
str(test_run$new_parameter_data,max.level=1)
# View the new, final accepted parameter data:
test_run$new_parameter_data
# }
# NOT RUN {
# --------------------------------------------------------------------------
# This is a dummy example to illustrate a realistic run in which optimised
# parameters are written back to the model Param folder. To try it out substitute
# your own relative folder path in place of \Folder in the e2e_copy() function...
# WARNING - this will take about 14 hours to run...
# Copy the 1970-1999 version of the North Sea model supplied with the package into a
# user workspace relative to the current working directory (../Folder):
# e2e_copy("North_Sea", "1970-1999",
# dest.path="Folder")
# Load the copied version of the North Sea/1970-1999 model from the user workspace
# and assign a path for results data:
# (REPLACE "Folder/Models" and "Folder/results" with your own paths before running)
# model<-e2e_read(model.name="North_Sea",
# model.variant="1970-1999",
# models.path="Folder/Models",
# results.path="Folder/results",
# model.ident="fittingrun")
# Launch the fitting process
# fitting_data<-e2e_optimize_act(model, selection="HR", n_iter=3000, start_temperature=1.0,
# cooling=0.985, csv.output=TRUE, n_traj=100 )
# --------------------------------------------------------------------------
# }
Run the code above in your browser using DataLab