Skip to content

Commit

Permalink
fix #508 and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakob-r committed Mar 24, 2021
1 parent 801cee3 commit 40b7e19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 5 additions & 3 deletions R/makeProposal.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
11 changes: 6 additions & 5 deletions tests/testthat/test_multipoint_moimbo.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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")) {
for (sel in c("hypervolume", "crowdingdist", "first", "last")) {

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,
Expand All @@ -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")
}

})

0 comments on commit 40b7e19

Please sign in to comment.