Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noisy Optimization: OCBA and Incumbent #430

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6a6db9b
handle multiple noisy instances
jakob-r Feb 1, 2018
6f0a537
fix tests
jakob-r Feb 5, 2018
d8dc631
error handling
jakob-r Feb 6, 2018
b1a79a3
initial test
ja-thomas Jun 21, 2018
06c7a7d
resolved merge conflicts master
juliambr Jun 22, 2018
ab6fa36
implementation of ocba and incumbent
juliambr Jun 25, 2018
2dd3c91
modified noisy control object
juliambr Jun 25, 2018
ab9cb52
added aggregation functionality
juliambr Jun 25, 2018
2190a10
corrected typos
juliambr Jun 25, 2018
2772d12
added ocba and incumbent replication plus tests
juliambr Jun 25, 2018
1e973fd
printing control object in noisy case
juliambr Jun 25, 2018
3cc45eb
make noisy function to make smoof function noisy
juliambr Jun 25, 2018
02dd45d
remove makenoisy function
juliambr Jun 26, 2018
cbfaffe
fixed test for incumbent
juliambr Jun 27, 2018
3067bef
more documentation
juliambr Jun 27, 2018
b9be9ba
fixed test for incumbent
juliambr Jun 27, 2018
773c4ef
bug usage data.table
juliambr Jun 27, 2018
7ac3f6c
fixed tests
juliambr Jun 27, 2018
677d211
Merge branch 'master' into feature_noisy
jakob-r Jun 28, 2018
34b9fdc
error handling
juliambr Jun 28, 2018
6e35606
smbo noisy fix
jakob-r Jun 29, 2018
17d33d0
Merge branch 'master' of https://github.com/mlr-org/mlrMBO into featu…
juliambr Jul 20, 2018
e820fe0
Merge branch 'feature_noisy' of https://github.com/mlr-org/mlrMBO int…
juliambr Jul 20, 2018
3755cd4
fixed OCBA divide by 0 bug
juliambr Jul 20, 2018
ae2fd31
correct for numerical error in OCBA
juliambr Sep 3, 2018
4009dbc
adding second stage identification for mlrMBO
juliambr Sep 4, 2018
f5e6a40
identification phase bugs
juliambr Sep 5, 2018
af13fc3
tests for identification
juliambr Sep 5, 2018
507431f
fixing bug in identification
juliambr Sep 6, 2018
1fcc40d
documentation of identification method
juliambr Sep 7, 2018
da0a514
adapt identification strategy
juliambr Sep 12, 2018
901e4c4
identification termination by max evals
juliambr Sep 24, 2018
0337c31
merge master
juliambr Dec 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added ocba and incumbent replication plus tests
juliambr committed Jun 25, 2018
commit 2772d1266d69178adc266d3b7c0d9344bc50ba3c
1 change: 0 additions & 1 deletion R/intensifyOptState.R
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ intensifyOptState = function(opt.state) {
)
}


intensifyIncumbent = function(opt.state) {

# some intialization
93 changes: 93 additions & 0 deletions tests/testthat/test_intensify.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# setwd(dir = "C:/Users/jumoo/Desktop/repos/mlrMBO")

# load_all() # load everything

context("mbo intensification")

test_that("mbo works with incumbent strategy", {
ps = makeNumericParamSet("x", 1L, -3, 3)
fun = smoof::makeSingleObjectiveFunction(
fn = function(x) (x + 0.5)^2 + 5 * sin(3 * (x + 0.5)) + rnorm(1, sd = 2),
par.set = ps,
noisy = TRUE
)

ctrl = makeMBOControl()
ctrl = setMBOControlTermination(ctrl, iters = 5L)
ctrl = setMBOControlNoisy(ctrl, method = "incumbent", incumbent.nchallengers = 2L)
or = mbo(fun, control = ctrl)
opdf = as.data.frame(or$opt.path)

# incumbent and proposed point are evaluated once in each iteration
expect_true(all(table(opdf$prop.type)[c("incumbent", "infill_cb")] == 5L))
# exactly 3 challengers are evaluated in each iteration (1 new point + 2 old points)
expect_true(all(setDT(opdf)[opdf$prop.type == "challenger", .(length(unique(x))), by = "dob"]$V1 == 3L))

# incumbent of iteration i + 1 should be the best point of iteration i
opdfs = setDT(opdf)[, .(ymean = cumsum(y) / (1:.N), dob = dob), by = x]
best = opdfs[, .(xmin = x[which.min(ymean)]), by = .(dob)]
expect_true(all(best$xmin[1:5] == opdf[opdf$prop.type == "incumbent", ]$x))
})


test_that("mbo works with ocba replication strategy", {
ps = makeNumericParamSet("x", 1L, -3, 3)
fun = makeSingleObjectiveFunction(
fn = function(x) (x + 0.5)^2 + 5 * sin(3 * (x + 0.5)) + rnorm(1, sd = 2),
par.set = ps,
noisy = TRUE
)

ctrl = makeMBOControl()
ctrl = setMBOControlTermination(ctrl, iters = 5L)
ctrl = setMBOControlNoisy(ctrl, method = "ocba", ocba.budget = 12L, ocba.initial = 3L)

or = mbo(fun, control = ctrl)
opdf = as.data.frame(or$opt.path)

# in each iteration we do 12L replications
opdfs = setDT(opdf)[, .(N = sum(prop.type == "OCBA")), by = dob]
expect_true(all(opdfs[opdfs$dob > 0, "N"] == 12L))

# each point is evaluated 3L times at least
opdfs = setDT(opdf)[, .N, by = "x"]
expect_true(all(opdfs$N >= 3L))

})


test_that("mbo with replication works in multidimensional case", {

fun = makeNoisy(smoof::makeAckleyFunction(5L), noise = function(x) x^2)

ctrl = makeMBOControl()
ctrl = setMBOControlTermination(ctrl, iters = 3L)
ctrl = setMBOControlNoisy(ctrl, method = "ocba", ocba.budget = 12L, ocba.initial = 3L)

or = mbo(fun, control = ctrl)
opdf = as.data.frame(or$opt.path)

# in each iteration we do 12L replications
opdfs = setDT(opdf)[, .(N = sum(prop.type == "OCBA")), by = dob]
expect_true(all(opdfs[opdfs$dob > 0, "N"] == 12L))

# each point is evaluated 3L times at least
opdfs = setDT(opdf)[, .N, by = eval(paste("x", 1:5, sep = ""))]
expect_true(all(opdfs$N >= 3L))

})


test_that("per instance aggregation works for different functions", {

fun = makeNoisy(smoof::makeAckleyFunction(1L), noise = function(x) x^2)

ctrl = makeMBOControl()
ctrl = setMBOControlTermination(ctrl, iters = 3L)
ctrl = setMBOControlNoisy(ctrl, method = "incumbent", instance.aggregation = median)

or = mbo(fun, control = ctrl)
opdf = as.data.frame(or$opt.path)

expect_true(all(length(or$models[[1]]$subset) == length(unique(opdf$x))))
})