logger | R Documentation |
Wraps your objective function, to Log each function evaluation during an optimization experiment.
logger(fn, id, freq = 1, logx = FALSE, envir = .GlobalEnv)
fn |
the function to be monitored by the logger (an objective function, following the schema y=f(x)). |
id |
an ID that will be part of the names of the variables that store the logging information |
freq |
a positive integer, giving the frequency of the logging: the history of y (and possibly x) values is permanently recorded every freq evaluations. Note: the best observed value is updated in every evaluation, regardless of this value. Default: 1 (every iteration is stored by the logger). |
logx |
boolean, specifying whether x values will be logged as well (default: FALSE). |
envir |
the environment in which the logger variables are stored (default: .GlobalEnv) |
A function which takes the same arguments as fn, and returns the same values. In addition, it writes some variables to the specified environment.
lower <- -1
upper <- 3
fun <- function(x)sqrt(abs(x-1))
require(nloptr)
lbfgs(x0=-1,
fn = logger(fun,"mytest",1),
lower=lower,
upper=upper)
## see the logged minimum value:
logger.min.mytest
## plot the progress over time
plot(logger.y.mytest[,c(1,2)])
plot(logger.y.mytest[,c(1,3)])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.