genoud_cache | R Documentation |
genoud
Optimization Function with a Cached
GradientRun the genoud
function from
the rgenoud package with the objective and the gradient
defined in one function. The result is global
minimization of a real-valued function of a numeric vector
with length d to be provided by fn
. The R
function fn
must provide the values of the objective
and its gradient.
The formal arguments of this function and their default values
are those of gthe genoud
function at
the time when this function is written, based on
version 5.8.3.0
of rgenoud.
genoud_cache( fn, nvars, max = FALSE, pop.size = 1000, max.generations = 100, wait.generations = 10, hard.generation.limit = TRUE, starting.values = NULL, MemoryMatrix = TRUE, Domains = NULL, default.domains = 10, solution.tolerance = 0.001, gr = NULL, boundary.enforcement = 0, lexical = FALSE, gradient.check = TRUE, BFGS = TRUE, data.type.int = FALSE, hessian = FALSE, unif.seed = round(runif(1, 1, 2147483647L)), int.seed = round(runif(1, 1, 2147483647L)), print.level = 2, share.type = 0, instance.number = 0, output.path = "stdout", output.append = FALSE, project.path = NULL, P1 = 50, P2 = 50, P3 = 50, P4 = 50, P5 = 50, P6 = 50, P7 = 50, P8 = 50, P9 = 0, P9mix = NULL, BFGSburnin = 0, BFGSfn = NULL, BFGShelp = NULL, control = list(), optim.method = ifelse(boundary.enforcement < 2, "BFGS", "L-BFGS-B"), transform = FALSE, debug = FALSE, cluster = FALSE, balance = FALSE, ... )
fn |
A function to be minimized. This function should return
a list with two named numeric elements |
nvars, max, pop.size, max.generations |
See |
wait.generations, hard.generation.limit |
See |
starting.values |
See |
MemoryMatrix |
See |
Domains |
See |
default.domains |
See |
solution.tolerance |
See |
gr |
Can not be used. This argument is for compatibility |
boundary.enforcement |
See |
lexical |
See |
gradient.check |
See |
BFGS |
See |
data.type.int |
See |
hessian |
See |
unif.seed |
See |
int.seed |
See |
print.level |
See |
share.type |
See |
instance.number |
See |
output.path |
See |
output.append |
See |
project.path |
See |
P1, P2, P3, P4, P5, P6 |
See |
P7, P8, P9, P9mix |
See |
BFGSburnin |
See |
BFGSfn |
See |
BFGShelp |
See |
control |
See |
optim.method |
See |
transform |
See |
debug |
See |
cluster |
See |
balance |
See |
... |
Further arguments to be passed to the function given in
|
The result of a call to genoud
.
This function is hightly experimental and has
not been tested enough yet. It should be refactored on the
basis of optim_cache
which is more achieved.
The optimization is expected to be faster than
genoud
if the function and its gradient
are costly to evaluate separately. However this may not be the
case for quite simple functions, due to the cost of setting
the "cache" mechanism.
## Not run: ## Note that in this example, gradient caching would not be worth it. dom <- cbind(lower = rep(0.0, 2), upper = rep(1.0, 2)) library(rgenoud) ## emulate a costly-to-evaluate-alone gradient ## =========================================== braninDer <- function(x) { Sys.sleep(0.01) branin_with_grad(x)$gradient } ## separate objective and gradient functions ## ========================================= te <- system.time(res <- genoud(fn = branin, nvars = 2, unif.seed = 123, int.seed = 456, Domains = dom, gr = braninDer)) ## gradient "cached" ## ================ teCache <- system.time(resCache <- genoud_cache(fn = branin_with_grad, nvars = 2, unif.seed = 123, int.seed = 456, Domains = dom)) rbind("genoud" = te, "genoud_cache" = teCache) c("genoud" = res$value, "genoud_cache" = resCache$value) ## Check the use of ... ## ==================== braninShift <- function(x, shift = 0) { res <- branin_with_grad(x) res$objective <- res$objective + shift res } resShifted <- genoud_cache(fn = braninShift, nvars = 2, unif.seed = 123, int.seed = 456, Domains = dom, shift = 100) c("genoud_cache" = resCache$value, "genoudShifted" = resShifted$value - 100) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.