View source: R/function_CreateOptpar.R
CreateOptpar | R Documentation |
CreateOptpar
creates a list representing a HYPE optpar.txt file from an imported par.txt file
and a selection of parameters.
CreateOptpar(
x,
pars,
tasks = data.frame(character(), character()),
comment = "",
fun.ival = NULL
)
x |
a list with named vector elements, as an object returned from |
pars |
Character vector with HYPE parameter names to be included in optpar list. Parameters must
exist in |
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 |
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.
The function returns a list with elements as described in ReadOptpar
.
ReadOptpar
WriteOptpar
OptimisedClasses
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.