CreateOptpar {HYPEtools}R Documentation

Create an optpar list

Description

CreateOptpar creates a list representing a HYPE optpar.txt file from an imported par.txt file and a selection of parameters.

Usage

CreateOptpar(
  x,
  pars,
  tasks = data.frame(character(), character()),
  comment = "",
  fun.ival = NULL
)

Arguments

x

a list with named vector elements, as an object returned from ReadPar.

pars

Character vector with HYPE parameter names to be included in optpar list. Parameters must exist in x. Not case-sensitive. For a complete list of HYPE parameters, see the par.txt online documentation.

tasks

Data frame with two columns providing optimization tasks and settings (key-value pairs) as described in the optpar.txt online documentation. Defaults to an empty task section.

comment

Character string, comment (first row in optpar.txt file).

fun.ival

Either NULL (default), or a function with a single argument. See Details.

Details

CreateOptpar makes it a bit more convenient to compose a HYPE optimization file. The function creates a template with all parameters to be included in an optimization run.

Parameter boundaries for individual classes have to be adapted after creation of the template, the function takes the existing parameter value(s) in x as upper and lower boundaries.

Parameter step width intervals (third parameter rows in optpar.txt files) are calculated with an internal function which per default returns the nearest single 1/1000th of the parameter value, with conditional replacement of '0' intervals:

function(x) {
  res <- 10^floor(log10(x/1000))
  ifelse(res == 0, .1, res)
}

Alternative functions can be passed to CreateOptpar using argument fun.ival. Such functions must have a single argument x, which represents the parameter value taken from argument x. The function is applied to all parameters in the resulting optpar list.

Value

The function returns a list with elements as described in ReadOptpar.

See Also

ReadOptpar WriteOptpar OptimisedClasses

Examples

# Import a HYPE parameter file
te1 <- ReadPar(filename = system.file("demo_model", "par.txt", package = "HYPEtools"))
# Create optimization parameters for a Monte Carlo run with 1000 iterations
te2 <- data.frame(key = c("task", "num_mc", "task"), value = c("MC", 1000, "WS"))
# Create an optpar file structure for HYPE recession coefficients
te3 <- CreateOptpar(x = te1, pars = c("rrcs1", "rrcs2"), tasks = te2)
te3


[Package HYPEtools version 1.6.2 Index]