# NOT RUN {
library(parallel)
library(DiceOptim)
set.seed(123)
#########################################################
### 10 ITERATIONS OF TREGO ON THE BRANIN FUNCTION, ####
### STARTING FROM A 9-POINTS FACTORIAL DESIGN ####
########################################################
# a 9-points factorial design, and the corresponding response
ylim=NULL
fun <- branin; d <- 2
budget <- 5*d
lower <- rep(0,d)
upper <- rep(1,d)
n.init <- 2*d
control <- list(n.init=2*d, TR=TRUE, nugget=1e-5, trcontrol=list(algo="TREGO"), multistart=1)
res1 <- easyEGO(fun=fun, budget=budget, lower=lower, upper=upper, control=control, n.cores=1)
par(mfrow=c(3,1))
y <- res1$history$y
steps <- res1$res$all.steps
success <- res1$res$all.success
sigma <- res1$res$all.sigma
ymin <- cummin(y)
pch <- rep(1, length(sigma))
col <- rep("red", length(sigma))
pch[which(!steps)] <- 2
col[which(success)] <- "darkgreen"
pch2 <- c(rep(3, n.init), pch)
col2 <- c(rep("black", n.init), col)
plot(y, col=col2, ylim=ylim, pch=pch2, lwd=2, xlim=c(0, budget))
lines(ymin, col="darkgreen")
abline(v=n.init+.5)
plot(n.init + (1:length(sigma)), sigma, xlim=c(0, budget), ylim=c(0, max(sigma)),
pch=pch, col=col, lwd=2, main="TR size")
lines(n.init + (1:length(sigma)), sigma, xlim=c(0, budget))
abline(v=n.init+.5)
plot(NA, xlim=c(0, budget), ylim=c(0, 1), main="x0 (coordinates)")
for (i in 1:d) {
lines(n.init + (1:nrow(res1$res$all.x0)), res1$res$all.x0[,i])
points(n.init + (1:nrow(res1$res$all.x0)), res1$res$all.x0[,i], pch=pch, col=col, lwd=2)
}
abline(v=n.init+.5)
par(mfrow=c(1,1))
pairs(res1$model@X, pch=pch2, col=col2)
# }
Run the code above in your browser using DataLab