calibrate_DDS: Calibrate DDS

View source: R/do_calibration.R

calibrate_DDSR Documentation

Calibrate DDS

Description

Calibrate via dynamically dimensioned search (DDS)

Usage

calibrate_DDS(
  params_df,
  objective_function,
  ...,
  r = 0.2,
  m = 10,
  best_only = TRUE,
  print_progress = "none",
  save_path = NULL
)

Arguments

params_df

A data.frame containing parameterinfo (see details)

objective_function

Objective function to be minimized (see details)

...

Additional inputs to objective_function

r

Variables are updated with a normal distribution and sd = r * N(1,0)

m

Number of iterations over which to calibrate

best_only

Boolean, indicates whether to filter output (see Return)

print_progress

Either "none", "bar" for txtProgressBar, "iter" to print iteration, or "iter_dt" to include datetime

save_path

If used, path to directory to save output as "calibrate_dds_outcomes.csv"

Details

This function executes the Dynamically dimensioned search algorithm by Tolson and Shoemaker (2007), which uses a random approach to variable selection and updates for calibration purposes. A random selection of parameters are varied for each calibration step. At the beginning of the algorithm, most parameters are varied whereas when the algorithm approaches the upper bound, fewer parameters are updated.

Input param_df contains the necessary information to run the DDS calibration algorithm. It contains columns:

  • param_name

  • min

  • max

  • values: Initial values for calibration

The objective_function should take as inputs a data.frame containing columns for param_names, which identify the parameters and values, which contain the updated values. Additional arguments will be passed through ... and the data.frame will contain all of the original columns.

Note that only parameters with params_df$max > params_df$min will be calibrated, meaning that it is possible to inclue parameters that will be skipped by the algorithm.

Tolson, B.A. and Shoemaker, C.A., 2007. Dynamically dimensioned search algorithm for computationally efficient watershed model calibration. Water Resources Research, 43(1).

Value

Returns a tibble with parameter values for each calibration step. If best_only is TRUE, only rows where the calibration improved are returned.

Examples

library(tibble)
# note: calibrate x, y, z. parameter n is not calibrated as min == max
params_df <- tibble(param_names = c("x","y","z","n"),
                    values = c(1.1, 1.2, 3.4, 4.1),
                    min = c(0.5, 1, 2.5, 4.1), max = c(1.5, 3, 3.5, 4.1))
example_objective_function <- function(params_df, vals) {
  return(1 - get_NSE(params_df$values, vals))
}
example_objective_function(params_df, vals = 1:4)

set.seed(100)
dds_output <- calibrate_DDS(params_df, example_objective_function, vals = 1:4, m = 100)
View(dds_output)

gopalpenny/goSWATplus documentation built on Nov. 8, 2022, 9:27 p.m.