optimization - R - nolptr - Find the 50 better solutions, not only the best one -
i'm using nerldermead()
function of nolptr
package , find, instance, 50 solutions. in example :
opti= function(x){x-12} x0=c(0) lower=c(0) upper=c(100) solution=neldermead(x0,opti,lower,upper,control=list(maxeval = 1000,stopval = -inf))
i obtain solution=12
, obtain best solution , 49 other around. there way extract information of nerldermead()
function ?
thanks lot !
the simplex local algorithm won't allow find different local optima, 1 optimum value (being global or local). can iterate simplex optimisation multi-level single linkage algorithm find different starting points simplex, depending on results of previous simplex. here example function:
require(nloptr) table <- null opti <- function(x){ res <- x-12 table <<- rbind(table, c(x, res)) res } lower <- c(0) upper <- c(100) local_opts <- list( "algorithm" = "nlopt_ln_neldermead", maxeval=15, "xtol_abs"=1.0e-4) opts <- list("algorithm" = "nlopt_gn_mlsl_lds", "local_opts" = local_opts, maxeval=50*15, print_level=3) opt <- nloptr( x0 = runif(1, min=lower, max=upper), # random starting point eval_f=opti, lb = lower, ub = upper, eval_grad_f=null, opts=opts ) table <- table[order(table[,2]),] table[1:50,]
as function simple, 50 results same rougher surface may expect interesting results. knowledge nloptr not allow trace of optim path have write in evaluation function. here number of iteration low: have 50-random starting 15-iteration simplex, don't forget change that.
Comments
Post a Comment