From 40b7e192810e6a03ea8b91a8e94e7a124534825d Mon Sep 17 00:00:00 2001 From: Jakob Richter Date: Wed, 24 Mar 2021 11:25:45 +0100 Subject: [PATCH] fix #508 and add tests --- R/makeProposal.R | 8 +++++--- tests/testthat/test_multipoint_moimbo.R | 11 ++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/R/makeProposal.R b/R/makeProposal.R index f898a8b97..0ba28c678 100644 --- a/R/makeProposal.R +++ b/R/makeProposal.R @@ -21,13 +21,15 @@ makeProposal = function(control, prop.points, propose.time = NULL, prop.type, cr propose.time = rep(NA_real_, n.points) } - if (is.null(crit.vals)) { - if (control$n.objectives > 1L && control$multiobj.method == "mspot") + if (control$n.objectives > 1L && control$multiobj.method == "mspot") { # mspot is the special kid, that needs multiple crit vals ncol = control$n.objectives + 1 - else + } else if (control$multipoint.method == "moimbo") { + ncol = control$propose.points - 1 + } else { ncol = 1 + } crit.vals = matrix(NA_real_, nrow = n.points, ncol = ncol) } diff --git a/tests/testthat/test_multipoint_moimbo.R b/tests/testthat/test_multipoint_moimbo.R index 4a0bc11d1..2db2f71b6 100644 --- a/tests/testthat/test_multipoint_moimbo.R +++ b/tests/testthat/test_multipoint_moimbo.R @@ -3,7 +3,7 @@ context("multipoint multi-objective") test_that("multipoint multi-objective", { f = makeBraninFunction() f = setAttribute(f, "par.set", makeNumericParamSet(len = 2L, lower = 0, upper = 1)) - + #FIXME: how can we test this better? for (obj in c("ei.dist", "mean.se", "mean.se.dist")) { for (dist in c("nearest.better", "nearest.neighbor")) { @@ -11,7 +11,7 @@ test_that("multipoint multi-objective", { des = generateTestDesign(10L, getParamSet(f)) ctrl = makeMBOControl(propose.points = 4L) - ctrl = setMBOControlTermination(ctrl, iters = 1L) + ctrl = setMBOControlTermination(ctrl, iters = 2L) ctrl = setMBOControlMultiPoint(ctrl, method = "moimbo", moimbo.objective = obj, @@ -28,13 +28,14 @@ test_that("multipoint multi-objective", { } } } - + #test that infill crit is ignored crits = list(makeMBOInfillCritCB(), makeMBOInfillCritEI(), makeMBOInfillCritMeanResponse()) for (i in seq_along(crits)) { - ctrl = setMBOControlInfill(ctrl, crit = crits[[i]]) + for (interleave.points in 0:2) { #test thath random interleave works (Issue #508) + ctrl = setMBOControlInfill(ctrl, crit = crits[[i]], interleave.random.points=interleave.points) + } res = mbo(f, control = ctrl) expect_output(print(res), "Recommended parameters") } - })