-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_AcqFunctionStochasticEI.R
83 lines (65 loc) · 2.41 KB
/
test_AcqFunctionStochasticEI.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
test_that("AcqFunctionStochasticEI works in defaults", {
skip_on_cran()
skip_if_not_installed("rush")
skip_if_not(redis_available())
flush_redis()
rush::rush_plan(n_workers = 1L)
instance = oi_async(
objective = OBJ_2D,
search_space = PS_2D,
terminator = trm("evals", n_evals = 10L),
)
acq_function = acqf("stochastic_ei")
optimizer = opt("async_mbo",
design_function = "sobol",
design_size = 5L,
acq_function = acq_function)
expect_data_table(optimizer$optimize(instance), nrows = 1L)
expect_data_table(instance$archive$data, min.rows = 10L)
expect_names(names(instance$archive$data), must.include = c(".already_evaluated", "acq_ei", "acq_epsilon_0", "acq_epsilon"))
expect_numeric(-instance$archive$data$acq_epsilon, sorted = TRUE)
expect_rush_reset(instance$rush)
})
test_that("AcqFunctionStochasticEI works with multiple workers", {
skip_on_cran()
skip_if_not_installed("rush")
skip_if_not(redis_available())
flush_redis()
rush::rush_plan(n_workers = 2L)
instance = oi_async(
objective = OBJ_2D,
search_space = PS_2D,
terminator = trm("evals", n_evals = 20L),
)
acq_function = acqf("stochastic_ei")
optimizer = opt("async_mbo",
design_function = "sobol",
design_size = 5L,
acq_function = acq_function)
expect_data_table(optimizer$optimize(instance), nrows = 1L)
expect_data_table(instance$archive$data, min.rows = 10L)
expect_names(names(instance$archive$data), must.include = c(".already_evaluated", "acq_ei", "acq_epsilon_0", "acq_epsilon"))
expect_rush_reset(instance$rush)
})
test_that("AcqFunctionStochasticEI works with periodic epsilon decay", {
skip_on_cran()
skip_if_not_installed("rush")
skip_if_not(redis_available())
flush_redis()
rush::rush_plan(n_workers = 1L)
instance = oi_async(
objective = OBJ_2D,
search_space = PS_2D,
terminator = trm("evals", n_evals = 10L),
)
acq_function = acqf("stochastic_ei", rate = 0.5, period = 2)
optimizer = opt("async_mbo",
design_function = "sobol",
design_size = 5L,
acq_function = acq_function)
expect_data_table(optimizer$optimize(instance), nrows = 1L)
expect_data_table(instance$archive$data, min.rows = 10L)
expect_names(names(instance$archive$data), must.include = c(".already_evaluated", "acq_ei", "acq_epsilon_0", "acq_epsilon"))
expect_numeric(unique(instance$archive$data$acq_epsilon), len = 3L)
expect_rush_reset(instance$rush)
})