David-Michael Lincke
2012-Jun-15 08:24 UTC
[R] DEoptim example illustrating use of fnMap parameter for enforcement of cardinality constraints
Function DEoptim in package DEoptim for differential evolution defines an optional parameter fnMap: fnMap "an optional function that will be run after each population is created, but before the population is passed to the objective function. This allows the user to impose integer/cardinality constriants." Unfortunately, there is no further documentation decribing the kind of parameters being passed to this function on invocation or the structure of the return value expected. I would very much appreciate it if somebody familiar with this package could provide an example illustrating how this interface is meant to be used to enforce cardinality constraints. Thanks, David [[alternative HTML version deleted]]
Joshua Ulrich
2012-Jun-16 01:29 UTC
[R] DEoptim example illustrating use of fnMap parameter for enforcement of cardinality constraints
Hi David, I apologize for the lack of documentation. I added it quickly and didn't have adequate time to document it. The function below works with the objective function in the "Large-scale portfolio optimization with DEoptim" vignette. Also, I just committed the full example (pkg/DEoptim/sandbox/slimLargeN_map.R) to the DEoptim repository on R-forge: https://r-forge.r-project.org/projects/deoptim/ mappingFun <- function(x) { x[which(order(x) < 6)] <- 0 x <- round(x,2) # produce some dups x/sum(x) } set.seed(1234) out <- DEoptim(fn=obj, lower=lower, upper=upper, control=controlDE, fnMap=mappingFun) Best, -- Joshua Ulrich ?| ?FOSS Trading: www.fosstrading.com On Fri, Jun 15, 2012 at 3:24 AM, David-Michael Lincke <dlincke at lincke.com> wrote:> Function DEoptim in package DEoptim for differential evolution defines an optional parameter fnMap: > > fnMap > > "an optional function that will be run after each population is created, but before the population is passed to the objective function. This allows the user to impose integer/cardinality constriants." > > Unfortunately, there is no further documentation decribing the kind of parameters being passed to this function on invocation or the structure of the return value expected. I would very much appreciate it if somebody familiar with this package could provide an example illustrating how this interface is meant to be used to enforce cardinality constraints. > > Thanks, > David > > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.