This function performs local optimization of a MODFLOW model.

rmf_optimize(
  path,
  code = "2005",
  start = NULL,
  lower = -Inf,
  upper = Inf,
  include = NULL,
  transform = NULL,
  cost = "ssq",
  backup = TRUE,
  restore = FALSE,
  visualize = interactive(),
  export = NULL,
  continue = FALSE,
  iterate = 50,
  tolerate = 1e-04,
  ...
)

Arguments

path

Path to the NAM file. Typically with extension .nam.

code

Name of the MODFLOW variant to use, or path to the executable.

start, lower, upper

Vectors of PVAL file parameter values to start the optimization, and corresponding lower and upper limits. These should be named vectors if not all parameters are provided in their order of occurrence, where the names (can be regular expressions to) match the parameter names. Parameters that are not mentioned take the starting value from the PVAL file, and/or have no constraints. If NULL (default), no values are changed in the original PVAL file, and/or no constraints are imposed. lower and upper also take named lists of functions and/or numeric values, where the functions are then applied to the start or original PVAL values. Note support for lower and upper limits is achieved with the Nelder and Mead method by pretending the model cannot be evaluated when violating them.

include

Character vector indicating which PVAL file parameters should be included. Regular expressions can be used to include multiple parameters at once. Parameters that are not mentioned are not included. If NULL (default), all parameters are included.

transform

Character vector of transformations. This should be a named vector if not all parameters are transformed, and listed in their order of occurrence, where the names (can be regular expressions to) match the parameter names. Parameters that are not mentioned are not transformed. If NULL (default), no transformations are done. Currently only "log" is supported.

cost

Character. The performance measure that should be used as the cost function. Possible values are those supported by rmf_performance(). Defaults to "ssq".

backup

Logical. Should a backup (with .old suffix) of the original PVAL file be created? Defaults to FALSE.

restore

Logical. Should the original PVAL file be restored? Defaults to FALSE.

visualize

Logical. Should the results be visualized during the analysis? Defaults to TRUE in an interactive session; FALSE otherwise.

export

Optional file path to export intermediate results to after each iteration.

continue

To continue from the last parameter set recorded in the export file, or not. Defaults to FALSE.

iterate

Integer. Maximum number of iterations.

tolerate

Double. Relative convergence tolerance.

...

Optional arguments passed to rmf_execute().

Value

Invisible list with optim() results and the full parameter list.

Details

Only works with models using MODFLOW parameters and having a head predictions output file as defined in the HOB object The only method currently available is "Nelder-Mead". See optim

See also

rmf_execute() for executing a MODFLOW model.
rmf_analyze() for analyzing a MODFLOW model.