## Not run:
# set.seed(123)
# #####################################################
# ### 4 ITERATIONS OF EGO ON THE BRANIN FUNCTION, ###
# ### STARTING FROM A 9-POINTS FACTORIAL DESIGN ###
# #####################################################
#
# # a 9-points factorial design, and the corresponding response
# d <- 2
# n <- 9
# design.fact <- expand.grid(seq(0,1,length=3), seq(0,1,length=3))
# names(design.fact)<-c("x1", "x2")
# design.fact <- data.frame(design.fact)
# names(design.fact)<-c("x1", "x2")
# response.branin <- apply(design.fact, 1, branin)
# response.branin <- data.frame(response.branin)
# names(response.branin) <- "y"
#
# # model identification
# fitted.model1 <- km(~1, design=design.fact, response=response.branin,
# covtype="gauss", control=list(pop.size=50,trace=FALSE), parinit=c(0.5, 0.5))
#
# # EGO n steps
# library(rgenoud)
# nsteps <- 4 # Was 10, reduced to 4 for speeding up execution
# lower <- rep(0,d)
# upper <- rep(1,d)
# npoints <- 3 # The batchsize
# oEGO <- qEGO.nsteps(model = fitted.model1, branin, npoints = npoints, nsteps = nsteps,
# crit="exact", lower, upper, optimcontrol = NULL)
# print(oEGO$par)
# print(oEGO$value)
# plot(c(1:nsteps),oEGO$history,xlab='step',ylab='Current known minimum')
#
# # graphics
# n.grid <- 15 # Was 20, reduced to 15 for speeding up compilation
# x.grid <- y.grid <- seq(0,1,length=n.grid)
# design.grid <- expand.grid(x.grid, y.grid)
# response.grid <- apply(design.grid, 1, branin)
# z.grid <- matrix(response.grid, n.grid, n.grid)
# contour(x.grid, y.grid, z.grid, 40)
# title("Branin function")
# points(design.fact[,1], design.fact[,2], pch=17, col="blue")
# points(oEGO$par, pch=19, col="red")
# text(oEGO$par[,1], oEGO$par[,2], labels=c(tcrossprod(rep(1,npoints),1:nsteps)), pos=3)
# ## End(Not run)
Run the code above in your browser using DataLab