Skip to contents padding-top: 70px;

These functions return optimizers that meet requirements for the optim_fun input argument of fit_c3_aci, fit_c3_variable_j, fit_c4_aci, and fit_c4_aci_hyperbola. Essentially, they are wrappers for optimizers from other libraries that serve to standardize their inputs and outputs.

Usage

optimizer_deoptim(itermax, VTR = -Inf)

  optimizer_hjkb(tol, maxfeval = Inf, target = Inf)

  optimizer_nlminb(rel.tol, eval.max = 200, iter.max = 200, abs.tol = 0)

  optimizer_nmkb(tol, maxfeval = 2000, restarts.max = 10)

  optimizer_null()

Arguments

tol

A convergence tolerance value; to be passed to nmkb or hjkb via their control input arguments. A typical value is 1e-7.

maxfeval

A maximum value for the number of function evaluations to allow during optimization; to be passed to nmkb or hjkb via their control input arguments.

target

A real number restricting the absolute function value; to be passed to hjkb via its control input argument.

rel.tol

A relative convergence tolerance value; to be passed to nlminb via its control input argument. A typical value is 1e-10.

eval.max

A maximum value for the number of function evaluations; to be passed to nlminb via its control input argument.

iter.max

A maximum value for the number of iterations; to be passed to nlminb via its control input argument.

abs.tol

An absolute convergence tolerance value; to be passed to nlminb via its control input argument.

restarts.max

A maximum value for the number of restarts allowed during optimization; to be passed to nmkb via its control input argument.

itermax

The maximum number of generations to be used; to be passed to DEoptim via its control input argument. Note that when VTR is -Inf, the optimizer will always use the maximum number of generations. A typical value is 200.

VTR

The value to be reached; to be passed to DEoptim via its control input argument.

Details

optimizer_deoptim is a wrapper for DEoptim.

optimizer_hjkb is a wrapper for hjkb.

optimizer_nlminb is a wrapper for nlminb.

optimizer_nmkb is a wrapper for nmkb.

optimizer_null simply returns the initial guess without doing any optimization; it can be useful for viewing initial guesses.

See the documentation for those functions for more information about how the optimizers work.

Value

Each of these functions returns an optimizer function optim_fun. The returned optim_fun function has four input arguments: an initial guess (guess), an error function (fun), lower bounds (lower), and upper bounds (upper). It returns a list with four named elements: par, convergence, feval, and convergence_msg.

Examples

# Here we just show examples of the optim_fun results. Other examples using the
# optimizers can be found throughout PhotoGEA, such as in the user guides and
# the documentation for fit_c3_aci, fit_c4_aci, etc.

optimizer_deoptim(200)
#> function (guess, fun, lower, upper) 
#> {
#>     NP <- 10 * length(guess)
#>     initialpop <- matrix(nrow = NP, ncol = length(guess))
#>     initialpop[1, ] <- guess
#>     varsize <- 0.25
#>     for (i in seq(2, NP)) {
#>         tmp <- guess * (1 + stats::runif(length(guess), -varsize, 
#>             varsize))
#>         initialpop[i, ] <- constrain_guess(tmp, lower, upper, 
#>             0)
#>     }
#>     res <- DEoptim::DEoptim(fun, lower, upper, control = list(VTR = VTR, 
#>         itermax = itermax, NP = NP, initialpop = initialpop, 
#>         trace = FALSE))
#>     list(convergence = NA, convergence_msg = NA, feval = res[["optim"]][["nfeval"]], 
#>         par = res[["optim"]][["bestmem"]], optimizer = "optimizer_deoptim")
#> }
#> <bytecode: 0x557b9ed3c730>
#> <environment: 0x557b9af278f0>

optimizer_hjkb(1e-7)
#> function (guess, fun, lower, upper) 
#> {
#>     guess <- constrain_guess(guess, lower, upper, 0.01)
#>     res <- dfoptim::hjkb(guess, fun, lower, upper, control = list(tol = tol, 
#>         maxfeval = maxfeval, target = target))
#>     list(convergence = res[["convergence"]], convergence_msg = NA, 
#>         feval = res[["feval"]], par = res[["par"]], optimizer = "optimizer_hjkb")
#> }
#> <bytecode: 0x557b9ade1620>
#> <environment: 0x557b9adde7e8>

optimizer_nlminb(1e-7)
#> function (guess, fun, lower, upper) 
#> {
#>     guess <- constrain_guess(guess, lower, upper, 0.01)
#>     res <- stats::nlminb(guess, fun, lower = lower, upper = upper, 
#>         control = list(rel.tol = rel.tol, eval.max = eval.max, 
#>             iter.max = iter.max, abs.tol = abs.tol))
#>     list(convergence = res[["convergence"]], convergence_msg = res[["message"]], 
#>         feval = res[["evaluations"]][1], par = res[["par"]], 
#>         optimizer = "optimizer_nlminb")
#> }
#> <bytecode: 0x557b9abb4cc8>
#> <environment: 0x557b9abb0280>

optimizer_nmkb(1e-7)
#> function (guess, fun, lower, upper) 
#> {
#>     guess <- constrain_guess(guess, lower, upper, 0.01)
#>     res <- dfoptim::nmkb(guess, fun, lower, upper, control = list(tol = tol, 
#>         maxfeval = maxfeval, restarts.max = restarts.max))
#>     list(convergence = res[["convergence"]], convergence_msg = res[["message"]], 
#>         feval = res[["feval"]], par = res[["par"]], optimizer = "optimizer_nmkb")
#> }
#> <bytecode: 0x557b9d239c28>
#> <environment: 0x557b9aabbe50>

optimizer_null()
#> function (guess, fun, lower, upper) 
#> {
#>     list(convergence = NA, convergence_msg = NA, feval = 0, par = guess, 
#>         optimizer = "optimizer_null")
#> }
#> <bytecode: 0x557b9ee39be8>
#> <environment: 0x557b9aa20e38>