Learn R Programming

kernDeepStackNet (version 2.0.2)

optimize1dMulti: One dimensional optimization of multivariate loss functions

Description

Applies a stepwise one dimensional algorithm conditional on the previous best parameter values. The one dimensional algorithm is a combination of golden search and linear interpolation.

Usage

optimize1dMulti(f_input, lower, upper, maxRuns=3, repetitions=5, 
tol_input=.Machine$double.eps^0.25, x_0=NULL, addInfo=TRUE,
nCores=1, envir=parent.frame(), directUse=TRUE, OptTypePar="")

Arguments

f_input

General loss function with multiple inputs and one numeric outcome value. The function must have a x as first argument, e.g. f(x).

lower

Gives the lower bounds of the input parameters (numeric vector). Each variable corresponds to one element of the vector.

upper

Gives the upper bounds of the input parameters (numeric vector). Each variable corresponds to one element of the vector.

maxRuns

Maximal number of iterations in the conditional optimization. Default is three.

repetitions

Maximal number of random starting values to avoid local optima. Default is five.

tol_input

Convergence criteria of each one dimensional sub-optimization. Higher values will be more accurate, but require much more function evaluations. Default is the fourth root of the machine double accuracy.

x_0

Intitial parameter values. If not supplied, a random number is drawn between the given bounds.

addInfo

Should the optimization print additional information? (logical value) Default is TRUE. The information consists of printing, which parameters have been optimized, which iteration and repetition the optimization process just finished.

nCores

Specifies how many cores are used in tuning (integer scalar). Default=1 is serial processing.

envir

Internal variable to store environments. Default is to look up the next higher level environment. Modification is unnecessary.

directUse

Specifies if the optimization is carried out inside a higher level function (see ) or directly (logical scalar). Only relevant in parallel mode initialization.

OptTypePar

Internal variable to store, which higher level function was called previously. Modification has no effect.

Value

  • List with following components:

    • minimum: Best parameter values

    • objective: Minimum of function evaluated at the best parameter values

Details

First the supplied initional value x_0 is used. If not present a random intitialisation is used. Then each parameter is optimized, conditional on the other starting values. An iteration is finished, if all parameters have been optimized once. The procedure is repeated until convergence or maxRuns is reached. If repetitions is higher than 1, new starting values are generated and the process starts new. In the end the best parameter values according the lowest function value are returned.

References

R. Brent, (1973), Algorithms for Minimization without Derivatives, Englewood Cliffs N.J.: Prentice-Hall

See Also

tuneMboLevelCvKDSN, tuneMboLevelGcvKDSN, tuneMboSharedCvKDSN

Examples

Run this code
library(globalOptTests)
# Two dimensional task
getDefaultBounds("AluffiPentini")
oneDres <- optimize1dMulti (f_input=function (x) 
goTest (x, fnName="AluffiPentini", checkDim=TRUE), 
maxRuns=3, repetitions=5, lower=rep(-12, 2), upper=rep(10, 2),
tol_input=.Machine$double.eps^0.25)
abs(oneDres$objective-getGlobalOpt("AluffiPentini"))

# Four dimensional optimization task
getDefaultBounds("CosMix4")
oneDres <- optimize1dMulti (f_input=function (x) 
goTest (x, fnName="CosMix4", checkDim=TRUE), 
maxRuns=3, repetitions=5, lower=rep(-2, 4), upper=rep(1, 4),
tol_input=.Machine$double.eps^0.25)
abs(oneDres$objective-getGlobalOpt("CosMix4"))

# Ten dimensional optimization task
getDefaultBounds("Rastrigin")
oneDres <- optimize1dMulti (f_input=function (x) 
goTest (x, fnName="Rastrigin", checkDim=TRUE), 
maxRuns=3, repetitions=5, lower=rep(-525, 10), upper=rep(512, 10),
tol_input=.Machine$double.eps^0.25)
abs(oneDres$objective-getGlobalOpt("Rastrigin"))

# Ten dimensional optimization task with higher accuracy
getDefaultBounds("Rastrigin")
oneDres <- optimize1dMulti (f_input=function (x) 
goTest (x, fnName="Rastrigin", checkDim=TRUE), 
maxRuns=3, repetitions=5, lower=rep(-525, 10), upper=rep(512, 10),
tol_input=.Machine$double.eps^0.5)
abs(oneDres$objective-getGlobalOpt("Rastrigin"))

Run the code above in your browser using DataLab