Skip to content

Commit 0cba07b

Browse files
sumnybe-marc
andauthored
feat: bbotk async compatibility (#146)
* draft * fix: add start time * refactor: remove rush debug * fix: add callback * fix: transformation * fix: xdomain * refactor: kill workers * feat: cache archive * chore: debug * chore: import rush * feat: add logging * refactor: use optimize_decentralized() * feat: add exponential decay * feat: add min-max imputation * feat: add n_worker parameter * draft * draft * refactor: remove stage * fix: description * feat: add n_worker argument * fix: imports * fix: tests * ci: add redis * drop ADBO for now * do not include partial update changes made to SurrogateLearner * .. --------- Co-authored-by: be-marc <marcbecker@posteo.de>
1 parent cc45e7b commit 0cba07b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+179
-163
lines changed

.github/workflows/dev-cmd-check.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ jobs:
3838
with:
3939
r-version: ${{ matrix.config.r }}
4040

41+
- uses: supercharge/redis-github-action@1.7.0
42+
with:
43+
redis-version: 7
44+
4145
- uses: r-lib/actions/setup-r-dependencies@v2
4246
with:
4347
extra-packages: any::rcmdcheck
@@ -48,3 +52,6 @@ jobs:
4852
shell: Rscript {0}
4953

5054
- uses: r-lib/actions/check-r-package@v2
55+
with:
56+
args: 'c("--no-manual")' # "--as-cran" prevents to start external processes
57+

.github/workflows/r-cmd-check.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ jobs:
3636
with:
3737
r-version: ${{ matrix.config.r }}
3838

39+
- uses: supercharge/redis-github-action@1.7.0
40+
with:
41+
redis-version: 7
42+
3943
- uses: r-lib/actions/setup-r-dependencies@v2
4044
with:
4145
extra-packages: any::rcmdcheck
4246
needs: check
4347

4448
- uses: r-lib/actions/check-r-package@v2
49+
with:
50+
args: 'c("--no-manual")' # "--as-cran" prevents to start external processes

DESCRIPTION

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ BugReports: https://github.com/mlr-org/mlr3mbo/issues
4141
Depends:
4242
R (>= 3.1.0)
4343
Imports:
44-
bbotk (>= 0.5.4),
44+
bbotk (>= 0.8.0.9000),
4545
checkmate (>= 2.0.0),
4646
data.table,
4747
lgr (>= 0.3.4),
4848
mlr3 (>= 0.14.0),
4949
mlr3misc (>= 0.11.0),
50-
mlr3tuning (>= 0.14.0),
50+
mlr3tuning (>= 0.20.0.9000),
5151
paradox (>= 0.10.0),
5252
spacefillr,
5353
R6 (>= 2.4.1)
@@ -65,7 +65,10 @@ Suggests:
6565
rmarkdown,
6666
rpart,
6767
stringi,
68-
testthat (>= 3.0.0),
68+
testthat (>= 3.0.0)
69+
Remotes:
70+
mlr-org/bbotk,
71+
mlr-org/mlr3tuning,
6972
ByteCompile: no
7073
Encoding: UTF-8
7174
Config/testthat/edition: 3

R/AcqFunction.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ AcqFunction = R6Class("AcqFunction",
176176
stopf("Acquisition function '%s' requires the surrogate to have `\"se\"` as `$predict_type`.", format(self))
177177
}
178178
private$.surrogate = rhs
179-
private$.archive = assert_r6(rhs$archive, classes = "Archive")
179+
private$.archive = assert_archive(rhs$archive)
180180
codomain = generate_acq_codomain(rhs, id = self$id, direction = self$direction)
181181
self$surrogate_max_to_min = surrogate_mult_max_to_min(rhs)
182182
domain = generate_acq_domain(rhs)

R/AcqFunctionAEI.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#' codomain = codomain,
4141
#' properties = "noisy")
4242
#'
43-
#' instance = OptimInstanceSingleCrit$new(
43+
#' instance = OptimInstanceBatchSingleCrit$new(
4444
#' objective = objective,
4545
#' terminator = trm("evals", n_evals = 5))
4646
#'

R/AcqFunctionCB.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#' codomain = ps(y = p_dbl(tags = "minimize"))
3636
#' objective = ObjectiveRFun$new(fun = fun, domain = domain, codomain = codomain)
3737
#'
38-
#' instance = OptimInstanceSingleCrit$new(
38+
#' instance = OptimInstanceBatchSingleCrit$new(
3939
#' objective = objective,
4040
#' terminator = trm("evals", n_evals = 5))
4141
#'

R/AcqFunctionEHVI.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#' codomain = ps(y1 = p_dbl(tags = "minimize"), y2 = p_dbl(tags = "minimize"))
3131
#' objective = ObjectiveRFun$new(fun = fun, domain = domain, codomain = codomain)
3232
#'
33-
#' instance = OptimInstanceMultiCrit$new(
33+
#' instance = OptimInstanceBatchMultiCrit$new(
3434
#' objective = objective,
3535
#' terminator = trm("evals", n_evals = 5))
3636
#'
@@ -117,7 +117,7 @@ AcqFunctionEHVI = R6Class("AcqFunctionEHVI",
117117
}
118118

119119
columns = colnames(self$ys_front_augmented)
120-
120+
121121
ps = self$surrogate$predict(xdt)
122122
means = map_dtc(ps, "mean")
123123

R/AcqFunctionEHVIGH.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#' codomain = ps(y1 = p_dbl(tags = "minimize"), y2 = p_dbl(tags = "minimize"))
4242
#' objective = ObjectiveRFun$new(fun = fun, domain = domain, codomain = codomain)
4343
#'
44-
#' instance = OptimInstanceMultiCrit$new(
44+
#' instance = OptimInstanceBatchMultiCrit$new(
4545
#' objective = objective,
4646
#' terminator = trm("evals", n_evals = 5))
4747
#'
@@ -175,20 +175,20 @@ adjust_gh_data = function(gh_data, mu, sigma, r) {
175175
idx = as.matrix(expand.grid(rep(list(1:n), n_obj)))
176176
nodes = matrix(gh_data[idx, 1L], nrow = nrow(idx), ncol = n_obj)
177177
weights = apply(matrix(gh_data[idx, 2L], nrow = nrow(idx), ncol = n_obj), MARGIN = 1L, FUN = prod)
178-
179-
# pruning with pruning rate r
178+
179+
# pruning with pruning rate r
180180
if (r > 0) {
181181
weights_quantile = quantile(weights, probs = r)
182182
nodes = nodes[weights > weights_quantile, ]
183183
weights = weights[weights > weights_quantile]
184184
}
185-
185+
186186
# rotate, scale, translate nodes with error catching
187187
# rotation will not have an effect unless we support surrogate models modelling correlated objectives
188188
# for now we still support this more general case and scaling is useful anyways
189189
nodes = tryCatch(
190190
{
191-
eigen_decomp = eigen(sigma)
191+
eigen_decomp = eigen(sigma)
192192
rotation = eigen_decomp$vectors %*% diag(sqrt(eigen_decomp$values))
193193
nodes = t(rotation %*% t(nodes) + mu)
194194
}, error = function(ec) nodes

R/AcqFunctionEI.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#' codomain = ps(y = p_dbl(tags = "minimize"))
3131
#' objective = ObjectiveRFun$new(fun = fun, domain = domain, codomain = codomain)
3232
#'
33-
#' instance = OptimInstanceSingleCrit$new(
33+
#' instance = OptimInstanceBatchSingleCrit$new(
3434
#' objective = objective,
3535
#' terminator = trm("evals", n_evals = 5))
3636
#'

R/AcqFunctionEIPS.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#' @description
1010
#' Expected Improvement per Second.
1111
#'
12-
#' It is assumed that calculations are performed on an [bbotk::OptimInstanceSingleCrit].
12+
#' It is assumed that calculations are performed on an [bbotk::OptimInstanceBatchSingleCrit].
1313
#' Additionally to target values of the codomain that should be minimized or maximized, the
14-
#' [bbotk::Objective] of the [bbotk::OptimInstanceSingleCrit] should return time values.
14+
#' [bbotk::Objective] of the [bbotk::OptimInstanceBatchSingleCrit] should return time values.
1515
#' The column names of the target variable and time variable must be passed as `cols_y` in the
1616
#' order `(target, time)` when constructing the [SurrogateLearnerCollection] that is being used as a
1717
#' surrogate.
@@ -37,7 +37,7 @@
3737
#' codomain = ps(y = p_dbl(tags = "minimize"), time = p_dbl(tags = "time"))
3838
#' objective = ObjectiveRFun$new(fun = fun, domain = domain, codomain = codomain)
3939
#'
40-
#' instance = OptimInstanceSingleCrit$new(
40+
#' instance = OptimInstanceBatchSingleCrit$new(
4141
#' objective = objective,
4242
#' terminator = trm("evals", n_evals = 5))
4343
#'

0 commit comments

Comments
 (0)