5454# ' @rdname infillcrits
5555makeMBOInfillCritMeanResponse = function () {
5656 makeMBOInfillCrit(
57- fun = function (points , models , control , par.set , design , iter , progress , attributes = FALSE ) {
57+ fun = function (points , models , control , par.set , designs , iter , progress , attributes = FALSE ) {
5858 ifelse(control $ minimize , 1 , - 1 ) * predict(models [[1L ]], newdata = points )$ data $ response
5959 },
6060 name = " Mean response" ,
@@ -67,7 +67,7 @@ makeMBOInfillCritMeanResponse = function() {
6767# ' @rdname infillcrits
6868makeMBOInfillCritStandardError = function () {
6969 makeMBOInfillCrit(
70- fun = function (points , models , control , par.set , design , iter , progress , attributes = FALSE ) {
70+ fun = function (points , models , control , par.set , designs , iter , progress , attributes = FALSE ) {
7171 - predict(models [[1L ]], newdata = points )$ data $ se
7272 },
7373 name = " Standard error" ,
@@ -83,10 +83,13 @@ makeMBOInfillCritEI = function(se.threshold = 1e-6) {
8383 assertNumber(se.threshold , lower = 1e-20 )
8484 force(se.threshold )
8585 makeMBOInfillCrit(
86- fun = function (points , models , control , par.set , design , iter , progress , attributes = FALSE ) {
86+ fun = function (points , models , control , par.set , designs , iter , progress , attributes = FALSE ) {
8787 model = models [[1L ]]
88- maximize.mult = ifelse(control $ minimize , 1 , - 1 )
88+ design = designs [[1 ]]
89+ maximize.mult = if (control $ minimize ) 1 else - 1
90+ assertString(control $ y.name )
8991 y = maximize.mult * design [, control $ y.name ]
92+ assertNumeric(y , any.missing = FALSE )
9093 p = predict(model , newdata = points )$ data
9194 p.mu = maximize.mult * p $ response
9295 p.se = p $ se
@@ -117,9 +120,9 @@ makeMBOInfillCritCB = function(cb.lambda = NULL) {
117120 assertNumber(cb.lambda , lower = 0 , null.ok = TRUE )
118121 force(cb.lambda )
119122 makeMBOInfillCrit(
120- fun = function (points , models , control , par.set , design , iter , progress , attributes = FALSE ) {
123+ fun = function (points , models , control , par.set , designs , iter , progress , attributes = FALSE ) {
121124 model = models [[1L ]]
122- maximize.mult = ifelse (control $ minimize , 1 , - 1 )
125+ maximize.mult = if (control $ minimize ) 1 else - 1
123126 p = predict(model , newdata = points )$ data
124127 # FIXME: removed cb.inflate.se for now (see issue #309)
125128 # if (cb.inflate.se) {
@@ -159,9 +162,10 @@ makeMBOInfillCritAEI = function(aei.use.nugget = FALSE, se.threshold = 1e-6) {
159162 force(se.threshold )
160163
161164 makeMBOInfillCrit(
162- fun = function (points , models , control , par.set , design , iter , progress , attributes = FALSE ) {
165+ fun = function (points , models , control , par.set , designs , iter , progress , attributes = FALSE ) {
163166 model = models [[1L ]]
164- maximize.mult = ifelse(control $ minimize , 1 , - 1 )
167+ design = designs [[1L ]]
168+ maximize.mult = if (control $ minimize ) 1 else - 1
165169 p = predict(model , newdata = points )$ data
166170 p.mu = maximize.mult * p $ response
167171 p.se = p $ se
@@ -205,9 +209,10 @@ makeMBOInfillCritEQI = function(eqi.beta = 0.75, se.threshold = 1e-6) {
205209 force(se.threshold )
206210
207211 makeMBOInfillCrit(
208- fun = function (points , models , control , par.set , design , iter , progress , attributes = FALSE ) {
212+ fun = function (points , models , control , par.set , designs , iter , progress , attributes = FALSE ) {
209213 model = models [[1L ]]
210- maximize.mult = ifelse(control $ minimize , 1 , - 1 )
214+ design = designs [[1L ]]
215+ maximize.mult = if (control $ minimize ) 1 else - 1
211216 # compute q.min
212217 design_x = design [, (colnames(design ) %nin % control $ y.name ), drop = FALSE ]
213218 p.current.model = predict(object = model , newdata = design_x )$ data
@@ -258,10 +263,11 @@ makeMBOInfillCritDIB = function(cb.lambda = 1, sms.eps = NULL) {
258263 if (! is.null(sms.eps ))
259264 assertNumber(sms.eps , lower = 0 , finite = TRUE )
260265 makeMBOInfillCrit(
261- fun = function (points , models , control , par.set , design , iter , progress , attributes = FALSE ) {
266+ fun = function (points , models , control , par.set , designs , iter , progress , attributes = FALSE ) {
262267 # get ys and cb-value-matrix for new points, minimize version
263268 maximize.mult = ifelse(control $ minimize , 1 , - 1 )
264- ys = as.matrix(design [, control $ y.name ]) %*% diag(maximize.mult )
269+ ys = Map(function (i , y.name ) designs [[i ]][, y.name ], i = seq_along(control $ y.name ), y.name = control $ y.name )
270+ ys = do.call(cbind , ys ) %*% diag(maximize.mult )
265271
266272 ps = lapply(models , predict , newdata = points )
267273 means = extractSubList(ps , c(" data" , " response" ), simplify = " cols" )
0 commit comments