[R] DEoptim example illustrating use of fnMap parameter for enforcement of cardinality constraints
Joshua Ulrich
josh.m.ulrich at gmail.com
Sat Jun 16 03:29:06 CEST 2012
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.
More information about the R-help
mailing list