loggedExperiment | R Documentation |
This function performs optimization experiments (described by the expression expr), where the objective function evaluations are logged as prescribed by the given arguments.
loggedExperiment(expr, fun, seeds, freq = 1, logx = FALSE)
expr |
this R expression will be run (with |
fun |
the actual objective function ( |
seeds |
the random number seeds to be set before each experiment. expr will be called as often as length(seeds). Each call is preceded by a call to set.seed, with the respective element of this vector. |
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). |
a data.frame containing the logged results: column 'it' gives iteration numbers, 'y' gives observations, 'cy' is the cumulated minimum of the observations over iterations, and 'seed' gives the rng seed of the corresponding experiment.
lower <- -1
upper <- 1
require(nloptr)
expr <- expression(
res <- lbfgs(x0=runif(1,lower,upper),
fn = fnlog, #important: use this same variable name 'fnlog'
lower=lower,upper=upper)
)
res <- loggedExperiment(expr, function(x)sqrt(abs(x)), 1:20)
plot(res[,c(1,3)],col=res$seed)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.