Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0f0f0fb
feat: add OptimizerBatchSMAC
be-marc Feb 2, 2026
46ea8fe
...
be-marc Feb 3, 2026
92e0f28
...
be-marc Feb 3, 2026
cf4c33c
...
be-marc Feb 3, 2026
9a9c100
Merge branch 'main' into smac
be-marc Feb 28, 2026
3760093
...
be-marc Mar 4, 2026
93f4460
...
be-marc Mar 4, 2026
500aa4e
Merge remote-tracking branch 'origin/smac' into hebo
awinterstetter Mar 20, 2026
4a8fece
first implementation of optimize function
awinterstetter Apr 13, 2026
99a461e
hebo fixes and comments
awinterstetter Apr 14, 2026
75cc400
HEBO further draft
awinterstetter Apr 21, 2026
e31f542
moved HEBO to R-folder and added unit tests
awinterstetter Apr 26, 2026
54571d0
add assert to hebo helper
awinterstetter Apr 26, 2026
a3ab359
added new files to collate
awinterstetter Apr 26, 2026
9945572
updated documentation
awinterstetter Apr 27, 2026
02f2bb4
Merge remote-tracking branch 'origin/main' into hebo
awinterstetter Apr 30, 2026
9975531
fixed rush error
awinterstetter Apr 30, 2026
6d8d657
logger in line with smac branch
awinterstetter Apr 30, 2026
2fe7b44
fix for HEBO install fail in GitHub checks
awinterstetter May 1, 2026
72a3509
further teardown.R fix
awinterstetter May 3, 2026
0001ddf
made setup and teardown in line with smac branch
awinterstetter May 4, 2026
608a58f
align teardown with smac branch
awinterstetter May 4, 2026
1047b76
tests managed in separate environments
awinterstetter May 4, 2026
f37ab23
added py_require to zzz.R
awinterstetter May 4, 2026
59af8e7
reverted files to smac branch
awinterstetter May 5, 2026
481e1dc
adjustments to github workflow
awinterstetter May 14, 2026
98f2fe9
manage smac and hebo in separate environments
awinterstetter May 14, 2026
4aa083e
further fixes
awinterstetter May 14, 2026
6fda7a9
changed to Sys.setenv
awinterstetter May 17, 2026
de029c7
implementation of Optuna optimizer
awinterstetter May 21, 2026
38332fa
removed callr-wrapping
awinterstetter May 21, 2026
6e9ebaa
Revert "removed callr-wrapping"
awinterstetter May 21, 2026
48f9a02
added library("checkmate")
awinterstetter May 21, 2026
f3f192c
set environment to "managed"
awinterstetter May 21, 2026
61ebee3
remove paradox from remotes
awinterstetter May 21, 2026
de9ffff
introduce virtual environment
awinterstetter May 21, 2026
9ac8d54
added paradox to remote-packages
awinterstetter May 24, 2026
93af230
fix VE for hebo tests
awinterstetter May 24, 2026
51d5aaf
avoid NOTE regarding torchinductor_runner
awinterstetter May 24, 2026
38eeb6e
removed withr
awinterstetter May 24, 2026
9aeaf34
add withr to description
awinterstetter May 24, 2026
034eacb
added nolint
awinterstetter May 24, 2026
13cc189
update directory
awinterstetter May 24, 2026
25b4f0b
add withr
awinterstetter May 24, 2026
2a5329e
Merge branch 'hebo' into optuna_new
awinterstetter May 24, 2026
fc640ee
created optuna tests
awinterstetter May 24, 2026
6989861
added default optimizer
awinterstetter May 25, 2026
2b74fab
add fallback for default
awinterstetter May 28, 2026
dc19f41
suppress trial-level INFO
awinterstetter May 28, 2026
37e6e74
...
awinterstetter May 28, 2026
56f5ab1
raw implementation Ax optimizer + doc update
awinterstetter May 28, 2026
a6ab471
fix n_sobol via choose_generation_strategy_kwargs
awinterstetter May 28, 2026
e2ce153
fix Ax n_sobol and HEBO mixed types test
awinterstetter May 29, 2026
5dbd2e7
move private methods to helper files
awinterstetter May 29, 2026
1008ccb
add helper files to collate
awinterstetter May 29, 2026
ff7a5e1
remove unnecessary attic file
awinterstetter May 29, 2026
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
21 changes: 21 additions & 0 deletions .github/workflows/r-cmd-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,32 @@ jobs:
with:
r-version: ${{ matrix.config.r }}

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- name: Create Python virtual environments
run: |
python3 -m venv ~/.virtualenvs/r-hebo
~/.virtualenvs/r-hebo/bin/pip install --upgrade pip --quiet
~/.virtualenvs/r-hebo/bin/pip install torch --index-url https://download.pytorch.org/whl/cpu --quiet
~/.virtualenvs/r-hebo/bin/pip install hebo --quiet
python3 -m venv ~/.virtualenvs/r-smac
~/.virtualenvs/r-smac/bin/pip install --upgrade pip --quiet
~/.virtualenvs/r-smac/bin/pip install smac ConfigSpace --quiet
python3 -m venv ~/.virtualenvs/r-optuna
~/.virtualenvs/r-optuna/bin/pip install --upgrade pip --quiet
~/.virtualenvs/r-optuna/bin/pip install optuna --quiet
python3 -m venv ~/.virtualenvs/r-ax
~/.virtualenvs/r-ax/bin/pip install --upgrade pip --quiet
~/.virtualenvs/r-ax/bin/pip install torch --index-url https://download.pytorch.org/whl/cpu --quiet
~/.virtualenvs/r-ax/bin/pip install ax-platform --quiet

- uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
Expand Down
18 changes: 16 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Authors@R: c(
person("Bernd", "Bischl", , "bernd_bischl@gmx.net", role = "aut",
comment = c(ORCID = "0000-0001-6002-6980")),
person("Martin", "Binder", , "martin.binder@mail.com", role = "aut"),
person("Olaf", "Mersmann", , "olafm@statistik.tu-dortmund.de", role = "ctb")
person("Olaf", "Mersmann", , "olafm@statistik.tu-dortmund.de", role = "ctb"),
person("Alexander", "Winterstetter", "alexanderwinterstetter@gmail.de", role = "ctb")
)
Description: Features highly configurable search spaces via the 'paradox'
package and optimizes every user-defined objective function. The
Expand All @@ -35,18 +36,24 @@ Imports:
R6
Suggests:
adagio,
callr,
emoa,
GenSA,
reticulate,
irace (>= 4.0.0),
knitr,
mirai,
nloptr,
processx,
progressr,
redux,
reticulate,
RhpcBLASctl,
rush (>= 1.0.0),
testthat (>= 3.0.0)
testthat (>= 3.0.0),
withr
Remotes:
mlr-org/paradox
Config/testthat/edition: 3
Config/testthat/parallel: false
Encoding: UTF-8
Expand Down Expand Up @@ -85,16 +92,20 @@ Collate:
'OptimizerAsyncGridSearch.R'
'OptimizerAsyncRandomSearch.R'
'OptimizerBatch.R'
'OptimizerBatchAx.R'
'OptimizerBatchChain.R'
'OptimizerBatchCmaes.R'
'OptimizerBatchDesignPoints.R'
'OptimizerBatchFocusSearch.R'
'OptimizerBatchGenSA.R'
'OptimizerBatchGridSearch.R'
'OptimizerBatchHEBO.R'
'OptimizerBatchIrace.R'
'OptimizerBatchLocalSearch.R'
'OptimizerBatchNLoptr.R'
'OptimizerBatchOptuna.R'
'OptimizerBatchRandomSearch.R'
'OptimizerBatchSmac3.R'
'Progressor.R'
'mlr_terminators.R'
'Terminator.R'
Expand All @@ -114,6 +125,9 @@ Collate:
'bibentries.R'
'conditions.R'
'helper.R'
'helper_ax.R'
'helper_hebo.R'
'helper_optuna.R'
'local_search.R'
'mlr_callbacks.R'
'mlr_test_functions.R'
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,20 @@ export(OptimizerAsyncDesignPoints)
export(OptimizerAsyncGridSearch)
export(OptimizerAsyncRandomSearch)
export(OptimizerBatch)
export(OptimizerBatchAx)
export(OptimizerBatchChain)
export(OptimizerBatchCmaes)
export(OptimizerBatchDesignPoints)
export(OptimizerBatchFocusSearch)
export(OptimizerBatchGenSA)
export(OptimizerBatchGridSearch)
export(OptimizerBatchHEBO)
export(OptimizerBatchIrace)
export(OptimizerBatchLocalSearch)
export(OptimizerBatchNLoptr)
export(OptimizerBatchOptuna)
export(OptimizerBatchRandomSearch)
export(OptimizerBatchSmac3)
export(Terminator)
export(TerminatorClockTime)
export(TerminatorCombo)
Expand Down
6 changes: 3 additions & 3 deletions R/OptimizerAsync.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
#' There are three types of workers:
#'
#' - "mirai": Workers are started with \CRANpkg{mirai} on local or remote machines.
#' See `$start_workers()` in [Rush] for more details.
#' See `$start_workers()` in [rush::Rush] for more details.
#' [mirai::daemons()] must be created before starting the optimization.
#' - "processx": Workers are started as local processes with \CRANpkg{processx}.

#' See `$start_local_workers()` in [Rush] for more details.
#' See `$start_local_workers()` in [rush::Rush] for more details.
#' - "script": Workers are started by the user with a custom script.
#' See `$create_worker_script()` in [Rush] for more details.
#' See `$create_worker_script()` in [rush::Rush] for more details.
#'
#' The workers are started when the `$optimize()` method is called.
#' The main process waits until at least one worker is running.
Expand Down
129 changes: 129 additions & 0 deletions R/OptimizerBatchAx.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#' @title Optimization via Ax (Adaptive Experimentation Platform)
#'
#' @include Optimizer.R
#' @name mlr_optimizers_ax
#'
#' @description
#' `OptimizerBatchAx` class that implements optimization via the Python
#' Ax framework. Calls Ax via \CRANpkg{reticulate}.
#'
#' @templateVar id ax
#' @template section_dictionary_optimizers
#'
#' @section Parameters:
#' \describe{
#' \item{`n_sobol`}{`integer(1)`\cr
#' Number of quasi-random (Sobol) initialization trials before Bayesian optimization starts.
#' If `NULL` (default), Ax determines the number automatically based on the search space.}
#' \item{`seed`}{`integer(1)`\cr
#' Random seed passed to the `AxClient` for reproducibility.
#' Default is `NULL` (no fixed seed).}
#' }
#'
#' @template section_progress_bars
#'
#' @export
OptimizerBatchAx = R6Class(
"OptimizerBatchAx",
inherit = OptimizerBatch,
public = list(
#' @description
#' Creates a new instance of this [R6][R6::R6Class] class.
initialize = function() {
param_set = ps(
n_sobol = p_int(lower = 1L, special_vals = list(NULL)),
seed = p_int(lower = 1L, special_vals = list(NULL))
)

super$initialize(
id = "ax",
param_set = param_set,
param_classes = c("ParamDbl", "ParamInt", "ParamFct", "ParamLgl"),
properties = c("single-crit", "multi-crit"),
packages = "reticulate",
label = "Ax",
man = "bbotk::mlr_optimizers_ax"
)
}
),

private = list(
.optimize = function(inst) {
assert_python_packages("ax")
ax_service = reticulate::import("ax.service.ax_client")

pv = self$param_set$values
search_space = inst$search_space
codomain = inst$archive$codomain

# Build Ax parameter definitions from paradox search space
parameters = paramset_to_ax_params(search_space)

# Build objectives dict from codomain
objective_ids = codomain$ids()
objectives = setNames(
lapply(objective_ids, function(id) {
minimize = !("maximize" %in% codomain$params[[id]]$tags)
ax_service$ObjectiveProperties(minimize = minimize)
}),
objective_ids
)

# Build AxClient args; optionally set seed and custom generation strategy
client_args = list(verbose_logging = FALSE)
if (!is.null(pv$seed)) {
client_args$random_seed = as.integer(pv$seed)
}
if (!is.null(pv$n_sobol)) {
ax_gs = reticulate::import("ax.modelbridge.generation_strategy")
ax_models = reticulate::import("ax.modelbridge.registry")
client_args$generation_strategy = ax_gs$GenerationStrategy(
steps = list(
# initial data points
ax_gs$GenerationStep(
model = ax_models$Models$SOBOL,
num_trials = pv$n_sobol
),

ax_gs$GenerationStep(
model = ax_models$Models$BOTORCH_MODULAR,
num_trials = -1L
)
)
)
}

ax_client = invoke(ax_service$AxClient, .args = client_args)

ax_client$create_experiment(
name = "bbotk_experiment",
parameters = parameters,
objectives = objectives
)

# Ask-and-tell loop
repeat {
result = tryCatch(
ax_client$get_next_trial(),
error = function(e) NULL
)
if (is.null(result)) {
break
}

params = reticulate::py_to_r(result[[1L]])
trial_index = result[[2L]]

xdt = ax_params_to_xdt(params, search_space)
inst$eval_batch(xdt)

n = nrow(inst$archive$data)
y_vals = unlist(inst$archive$data[n, inst$archive$cols_y, with = FALSE])

ax_client$complete_trial(trial_index = trial_index, raw_data = as.list(y_vals))
}
}
)
)

mlr_optimizers$add("ax", OptimizerBatchAx)
Loading
Loading