A10 <- structure(c(0.674716681991817, -0.441716621026635, 0.622713571882636, 2.12459319704959, -2.2200164111581, -3.61488000399049, 0.253305195789315, 0.0766313802382238, -0.990373523500256, -0.886289788805003), .Names = c("MMM", "ACE", "ABT", "ANF", "ADBE", "AMD", "AES", "AET", "AFL", "A")) A10s <- structure(c(-0.361488000399049, -0.22200164111581, -0.875330227135, 0.0674716681991817, 0.153262760476448, -0.0990373523500256, -0.0886289788805003, 0.212459319704959, 0.355828337897336, 0.462271357188264), .Names = c("MMM", "ACE", "ABT", "ANF", "ADBE", "AMD", "AES", "AET", "AFL", "A")) Fit10 <- function (x, full=FALSE) { n <- length(x) / 2 ord <- order(x[1:n]) w <- x[1:n + n] w[ord <= 5] <- 0 if(full) { list(weights=w/sum(w), objective=U10(w)) } else { U10(w) } } Nfit10 <- function (x, full=FALSE) { n <- length(x) / 2 ord <- order(x[1:n]) w <- x[1:n + n] w[ord <= 5] <- 0 w[w < 0] <- 0 if(all(w <= 0)) return( Inf ) if(full) { list(weights=w/sum(w), objective=-U10(w)) } else { -U10(w) } } Nfit10s <- function (x, full=FALSE) { n <- length(x) / 2 ord <- order(x[1:n]) w <- x[1:n + n] w[ord <= 5] <- 0 w[w < 0] <- 0 if(all(w <= 0)) return( Inf ) if(full) { list(weights=w/sum(w), objective=-U10s(w)) } else { -U10s(w) } } P.lacking10a <- function (filename = "lacking10a.png") { if(length(filename)) { png(file=filename, width=512) par(mar=c(5,4.5, 0, 2) + .1) } lack <- list(genopt=testres.genopt.10a[,2] - testres.pprobe.10a[1,2], ga=testres.ga.10a[,2] - testres.pprobe.10a[1,2], TAopt=testres.taopt.10a[,2] - testres.pprobe.10a[1,2], LSopt=testres.lsopt.10a[,2] - testres.pprobe.10a[1,2], DEopt=testres.deopt.10a[,2] - testres.pprobe.10a[1,2], SANN=testres.sann.10a[,2] - testres.pprobe.10a[1,2], GenSA=testres.gensa.10a[,2] - testres.pprobe.10a[1,2], genoud=testres.genoud.10a[,2] - testres.pprobe.10a[1,2], soma=testres.soma.10a[,2] - testres.pprobe.10a[1,2], malsch=testres.malsch.10a[,2] - testres.pprobe.10a[1,2], DEoptim=testres.deoptim.10a[,2] - testres.pprobe.10a[1,2]) lord <- order(sapply(lack, median)) boxplot(lack[lord], col="gold", xlab="Deficiency", horizontal=TRUE, las=1) if(length(filename)) { dev.off() } } pp.denplot <- function (..., col=c("black", "steelblue", "gold", "forestgreen", "red", "gray")) { dots <- list(...) dens <- lapply(dots, density) dx <- do.call("cbind", lapply(dens, function(z) z$x)) dy <- do.call("cbind", lapply(dens, function(z) z$y)) matplot(dx, dy, type="l", lty=1, col=col, lwd=2) } test.deopt10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- DEopt(Nfit10, algo=list( printDetail=FALSE, printBar=FALSE, min=rep(0,20), max=rep(1, 20) ))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$OFvalue } cbind(time=time, objective=objective) } test.deopt10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- DEopt(Nfit10s, algo=list( printDetail=FALSE, printBar=FALSE, min=rep(0,20), max=rep(1, 20) ))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$OFvalue } cbind(time=time, objective=objective) } test.deoptim10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- DEoptim(fn = Nfit10, lower = rep(0, 20), upper = rep(1, 20), control=DEoptim.control(trace=FALSE, itermax=100))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$optim$bestval } cbind(time=time, objective=objective) } test.deoptim10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- DEoptim(fn = Nfit10s, lower = rep(0, 20), upper = rep(1, 20), control=DEoptim.control(trace=FALSE, itermax=100))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$optim$bestval } cbind(time=time, objective=objective) } test.ga10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- ga(type = "real", fitness = Fit10, min = rep(0, 20), max = rep(1, 20), monitor = NULL)) time[i] <- sum(ttim[1:2]) objective[i] <- tres@fitnessValue } cbind(time=time, objective=objective) } test.ga10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- ga(type = "real", fitness = Fit10s, min = rep(0, 20), max = rep(1, 20), monitor = NULL)) time[i] <- sum(ttim[1:2]) objective[i] <- tres@fitnessValue } cbind(time=time, objective=objective) } test.genopt10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- genopt(fun = Nfit10, population = matrix(runif(20 * 20), 20), lower = 0, upper = 1, births = 2500, trace=FALSE)) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$objective[1] } cbind(time=time, objective=objective) } test.genopt10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- genopt(fun = Nfit10s, population = matrix(runif(20 * 20), 20), lower = 0, upper = 1, births = 2500, trace=FALSE)) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$objective[1] } cbind(time=time, objective=objective) } test.genoud10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- genoud(fn = Nfit10, nvar = 20, print.level=0, pop.size=20, max.generations=20, Domain=cbind(rep(0,20), 1), boundary.enforce=2)) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$value } cbind(time=time, objective=objective) } test.genoud10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- genoud(fn = Nfit10s, nvar = 20, print.level=0, pop.size=20, max.generations=20, Domain=cbind(rep(0,20), 1), boundary.enforce=2)) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$value } cbind(time=time, objective=objective) } test.gensa10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- GenSA(fn = Nfit10, lower=rep(0,20), upper=rep(1,20), control=list(maxit=300))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$value } cbind(time=time, objective=objective) } test.gensa10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- GenSA(fn = Nfit10s, lower=rep(0,20), upper=rep(1,20), control=list(maxit=300))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$value } cbind(time=time, objective=objective) } test.lsopt10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- LSopt(Nfit10, algo=list( x0=runif(20), printDetail=FALSE, printBar=FALSE, nS=15000, neighbour=function(x) x + runif(length(x)) ))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$OFvalue } cbind(time=time, objective=objective) } test.lsopt10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- LSopt(Nfit10s, algo=list( x0=runif(20), printDetail=FALSE, printBar=FALSE, nS=15000, neighbour=function(x) x + runif(length(x)) ))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$OFvalue } cbind(time=time, objective=objective) } test.malsch10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- malschains(fn = Nfit10, lower = rep(0, 20), upper = rep(1,20), maxEvals=1.5e4, trace=FALSE)) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$fitness } cbind(time=time, objective=objective) } test.malsch10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- malschains(fn = Nfit10s, lower = rep(0, 20), upper = rep(1,20), maxEvals=1.5e4, trace=FALSE)) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$fitness } cbind(time=time, objective=objective) } test.pprobe10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- trade.optimizer(prices = jjprice, variance = V10, expected.return = A10, gross = 1e+06 + c(-0.5, 0.5), long.only = TRUE, port.size = 5, utility = "mean-variance", seed=NULL)) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$results["objective"] } cbind(time=time, objective=objective) } test.pprobe10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- trade.optimizer(prices = jjprice, variance = V10, expected.return = A10s, gross = 1e+06 + c(-0.5, 0.5), long.only = TRUE, port.size = 5, utility = "mean-variance", seed=NULL)) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$results["objective"] } cbind(time=time, objective=objective) } test.sann10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- optim(fn = Nfit10, par = runif(20), method="SANN", control=list(maxit=2e4))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$value[1] } cbind(time=time, objective=objective) } test.sann10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- optim(fn = Nfit10s, par = runif(20), method="SANN", control=list(maxit=2e4))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$value[1] } cbind(time=time, objective=objective) } test.soma10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- soma(cost = Nfit10, bounds=list(min=rep(0,20), max=rep(1,20)), options=list(nMigrations=60))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$cost[tres$leader] } cbind(time=time, objective=objective) } test.soma10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- soma(cost = Nfit10s, bounds=list(min=rep(0,20), max=rep(1,20)), options=list(nMigrations=60))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$cost[tres$leader] } cbind(time=time, objective=objective) } test.taopt10a <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- TAopt(Nfit10, algo=list( x0=runif(20), printDetail=FALSE, printBar=FALSE, nS=1500, neighbour=function(x) x + runif(length(x)) ))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$OFvalue } cbind(time=time, objective=objective) } test.taopt10s <- function (trials=100) { time <- objective <- rep(NA, trials) for(i in 1:trials) { ttim <- system.time(tres <- TAopt(Nfit10s, algo=list( x0=runif(20), printDetail=FALSE, printBar=FALSE, nS=1500, neighbour=function(x) x + runif(length(x)) ))) time[i] <- sum(ttim[1:2]) objective[i] <- -tres$OFvalue } cbind(time=time, objective=objective) } U10 <- function (w) { w <- w / sum(w) sum(w * A10) - drop(w %*% V10 %*% w) } U10s <- function (w) { w <- w / sum(w) sum(w * A10s) - drop(w %*% V10 %*% w) } V10 <- structure(c(2.10971431256697, 0.897757948573287, 0.566181049143755, 1.50011719304549, 1.12044478464688, 1.69082908434874, 1.58090578300758, 0.956865349017686, 1.76730730102965, 1.47174850522898, 0.897757948573287, 1.93792106877032, 0.520542508238327, 1.4303621745831, 1.32683106568222, 1.47938005758826, 1.40000278777414, 0.966550472224708, 1.54829237465794, 1.26892130401874, 0.566181049143755, 0.520542508238327, 1.35629703931921, 0.989376767113976, 0.716523791725757, 0.905374661305781, 0.949722918242164, 0.703360008379208, 0.98741751248164, 0.852191745248497, 1.50011719304549, 1.4303621745831, 0.989376767113976, 7.93518261961667, 2.93460873539754, 3.27240520099923, 2.71773139243512, 1.66476650440305, 3.06729241197499, 2.44671724214915, 1.12044478464688, 1.32683106568222, 0.716523791725757, 2.93460873539754, 6.61357359514527, 2.21566247402706, 2.26330312256283, 1.58144128846032, 2.36393995337297, 2.12210071189485, 1.69082908434874, 1.47938005758826, 0.905374661305781, 3.27240520099923, 2.21566247402706, 7.44642407634864, 3.02434819939931, 1.83447744928282, 3.23887963009818, 3.03178327058812, 1.58090578300758, 1.40000278777414, 0.949722918242164, 2.71773139243512, 2.26330312256283, 3.02434819939931, 4.95410681125333, 1.70345589181136, 2.95271338981022, 2.46065981456743, 0.956865349017686, 0.966550472224708, 0.703360008379208, 1.66476650440305, 1.58144128846032, 1.83447744928282, 1.70345589181136, 3.0090503854516, 1.80662227565109, 1.6560255511543, 1.76730730102965, 1.54829237465794, 0.98741751248164, 3.06729241197499, 2.36393995337297, 3.23887963009818, 2.95271338981022, 1.80662227565109, 4.76524713449497, 2.5398661728646, 1.47174850522898, 1.26892130401874, 0.852191745248497, 2.44671724214915, 2.12210071189485, 3.03178327058812, 2.46065981456743, 1.6560255511543, 2.5398661728646, 3.90812971764787), .Dim = c(10L, 10L), .Dimnames = list(c("MMM", "ACE", "ABT", "ANF", "ADBE", "AMD", "AES", "AET", "AFL", "A"), c("MMM", "ACE", "ABT", "ANF", "ADBE", "AMD", "AES", "AET", "AFL", "A")))