Camarda, Carlo Giovanni
2006-May-16 19:08 UTC
[R] optim with specific constraints on possible values
Dear R-users, I am working with some grid-search optimization for 13 values of an object function. At glance one may compute the object function for each possible combination of set of parameters, but in my case would not be feasible: taking for example 13 possible values for each parameters like, in logarithm scale, 10^seq(-3,3,.5) will lead to 13^13 combinations of results. As a second trial I use the general-purpose function "optim" both without and with constraints from the candidate values (of course the latter is fast and fine with me), but I am wondering whether there is kind of optim-function which optimize using only a series of values to give as additional arguments. Just inventing, something like: possible1 <- 10^seq(-3,3,0.5) possible2 <- 10^seq(-3,3,0.5) ... possible13 <- 10^seq(-3,3,0.5) new.optim(par=rep(median(possible1), 13), fn=my.object.function, from=cbind(possible1, possible2,..., possible13)) Instead of just: optim(par=rep(median(possible1), 13), fn=my.object.function, method=c("L-BFGS-B"), lower=rep(min(possible1), 13), upper=rep(min(possible1), 13)) Thanks in advance, Carlo Giovanni Camarda ==========================================Camarda Carlo Giovanni PhD-Student Max Planck Institute for Demographic Research Konrad-Zuse-Strasse 1 18057 Rostock, Germany Tel: +49 (0)381 2081 172 Fax: +49 (0)381 2081 472 camarda@demogr.mpg.de ========================================== ---------- This mail has been sent through the MPI for Demographic Rese...{{dropped}}
Spencer Graves
2006-May-19 16:31 UTC
[R] optim with specific constraints on possible values
Searching over a finite set of possible values sounds like a variant of integer programming. If the finite number is small, then the most efficient algorithm may be just to compute them all. However, if it's a number like 13^13, then that's not feasible. If the objective function is sufficiently smooth and well defined over all real numbers (at least in some convex set, preferably rectangular), then a good "integer programming algorithm" may be to find the optimum ignoring the integer constraint first, then search all integer combinations in an appropriate region of the non-integer optimum. Have you tried RSiteSearch("integer programming")? This just produced 205 hits for me. Some were relevant, some weren't. Google also seemed to produce some potentially useful hits. What problem are you trying to solve? If a grid search is used just to simplify the problem, I think that's wise if the objective function is known to have multiple local optima, discontinuities, etc. If, however, the objective function is smooth, then I think 'optim' or 'nlminb' might work better for you, especially if your "finite set" is merely an attempt to reduce the compute time. Hope this helps, Spencer Graves Camarda, Carlo Giovanni wrote:> Dear R-users, > > I am working with some grid-search optimization for 13 values of an > object function. > > At glance one may compute the object function for each possible > combination of set of parameters, but in my case would not be feasible: > taking for example 13 possible values for each parameters like, in > logarithm scale, 10^seq(-3,3,.5) will lead to 13^13 combinations of > results. > > As a second trial I use the general-purpose function "optim" both > without and with constraints from the candidate values (of course the > latter is fast and fine with me), but I am wondering whether there is > kind of optim-function which optimize using only a series of values to > give as additional arguments. Just inventing, something like: > > possible1 <- 10^seq(-3,3,0.5) > possible2 <- 10^seq(-3,3,0.5) > ... > possible13 <- 10^seq(-3,3,0.5) > > new.optim(par=rep(median(possible1), 13), > fn=my.object.function, > from=cbind(possible1, possible2,..., possible13)) > > Instead of just: > optim(par=rep(median(possible1), 13), > fn=my.object.function, > method=c("L-BFGS-B"), > lower=rep(min(possible1), 13), > upper=rep(min(possible1), 13)) > > > Thanks in advance, > Carlo Giovanni Camarda > > ==========================================> Camarda Carlo Giovanni > PhD-Student > Max Planck Institute for Demographic Research > Konrad-Zuse-Strasse 1 > 18057 Rostock, Germany > Tel: +49 (0)381 2081 172 > Fax: +49 (0)381 2081 472 > camarda at demogr.mpg.de > ==========================================> > > ---------- > This mail has been sent through the MPI for Demographic Rese...{{dropped}} > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html