Freezes the Redis data base of an ArchiveAsync to a data.table::data.table().
No further points can be added to the archive but the data can be accessed and analyzed.
Useful when the Redis data base is not permanently available.
Use the callback bbotk.async_freeze_archive to freeze the archive after the optimization has finished.
S3 Methods
as.data.table(archive)
ArchiveAsync ->data.table::data.table()
Returns a tabular view of all performed function calls of the Objective. Thex_domaincolumn is unnested to separate columns.
Super classes
bbotk::Archive -> bbotk::ArchiveAsync -> ArchiveAsyncFrozen
Active bindings
data(data.table::data.table)
Data table with all finished points.queued_data(data.table::data.table)
Data table with all queued points.running_data(data.table::data.table)
Data table with all running points.finished_data(data.table::data.table)
Data table with all finished points.failed_data(data.table::data.table)
Data table with all failed points.n_queued(
integer(1))
Number of queued points.n_running(
integer(1))
Number of running points.n_finished(
integer(1))
Number of finished points.n_failed(
integer(1))
Number of failed points.n_evals(
integer(1))
Number of evaluations stored in the archive.
Methods
Method new()
Creates a new instance of this R6 class.
Usage
ArchiveAsyncFrozen$new(archive)Arguments
archive(ArchiveAsync)
The archive to freeze.
Method push_points()
Push queued points to the archive.
Arguments
xss(list of named
list())
List of named lists of point values.
Method push_running_point()
Push running point to the archive.
Arguments
xs(named
list)
Named list of point values.extra(
list())
Named list of additional information.
Method push_result()
Push result to the archive.
Arguments
key(
character())
Key of the point.ys(
list())
Named list of results.x_domain(
list())
Named list of transformed point values.extra(
list())
Named list of additional information.
Method push_failed_point()
Push failed point to the archive.
Arguments
key(
character())
Key of the point.message(
character())
Error message.
Method data_with_state()
Fetch points with a specific state.
Arguments
fields(
character())
Fields to fetch. Defaults toc("xs", "ys", "xs_extra", "worker_extra", "ys_extra").states(
character())
States of the tasks to be fetched. Defaults toc("queued", "running", "finished", "failed").reset_cache(
logical(1))
Whether to reset the cache of the finished points.
Examples
# example only runs if a Redis server is available
if (mlr3misc::require_namespaces(c("rush", "redux", "mirai"), quietly = TRUE) &&
redux::redis_available()) {
# define the objective function
fun = function(xs) {
list(y = - (xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10)
}
# set domain
domain = ps(
x1 = p_dbl(-10, 10),
x2 = p_dbl(-5, 5)
)
# set codomain
codomain = ps(
y = p_dbl(tags = "maximize")
)
# create objective
objective = ObjectiveRFun$new(
fun = fun,
domain = domain,
codomain = codomain,
properties = "deterministic"
)
# start workers
rush::rush_plan(worker_type = "remote")
mirai::daemons(1)
# initialize instance
instance = oi_async(
objective = objective,
terminator = trm("evals", n_evals = 20),
callback = clbk("bbotk.async_freeze_archive")
)
# load optimizer
optimizer = opt("async_random_search")
# trigger optimization
optimizer$optimize(instance)
# frozen archive
instance$archive
# best performing configuration
instance$archive$best()
# covert to data.table
as.data.table(instance$archive)
}
#> state x1 x2 y timestamp_xs pid
#> <char> <num> <num> <num> <POSc> <int>
#> 1: finished 0.7355865 4.436809312 -46.9048744 2025-10-24 13:34:04 8861
#> 2: finished -5.2465150 1.685353492 -64.4645163 2025-10-24 13:34:04 8861
#> 3: finished -1.6100269 1.692733854 -25.0540453 2025-10-24 13:34:04 8861
#> 4: finished -9.6485851 2.074896538 -151.4441090 2025-10-24 13:34:04 8861
#> 5: finished 9.1534135 0.636737862 -54.3971877 2025-10-24 13:34:04 8861
#> 6: finished -0.9507994 -4.878603549 -2.2363683 2025-10-24 13:34:04 8861
#> 7: finished 2.7997505 -1.921276769 8.1967553 2025-10-24 13:34:04 8861
#> 8: finished 7.9367603 3.130829856 -62.8321976 2025-10-24 13:34:04 8861
#> 9: finished -5.3535132 0.132857377 -53.8889510 2025-10-24 13:34:04 8861
#> 10: finished -1.1703927 1.581480915 -21.0413571 2025-10-24 13:34:05 8861
#> 11: finished 5.5692991 1.671339287 -24.5613067 2025-10-24 13:34:05 8861
#> 12: finished 9.4659255 -4.325706593 -47.4975413 2025-10-24 13:34:05 8861
#> 13: finished -4.5022012 -3.621611151 -32.6650205 2025-10-24 13:34:05 8861
#> 14: finished 6.4919932 0.400897277 -21.7441056 2025-10-24 13:34:05 8861
#> 15: finished -1.5261497 -0.002130552 -11.4209531 2025-10-24 13:34:05 8861
#> 16: finished 5.2346110 -2.546360991 -0.6684964 2025-10-24 13:34:05 8861
#> 17: finished -8.1469277 -2.532682236 -93.1785285 2025-10-24 13:34:05 8861
#> 18: finished 7.9586287 -3.273955223 -25.5803070 2025-10-24 13:34:05 8861
#> 19: finished 5.3650967 -2.241232399 -1.8996043 2025-10-24 13:34:05 8861
#> 20: finished 4.8743111 3.778382706 -44.2081363 2025-10-24 13:34:05 8861
#> state x1 x2 y timestamp_xs pid
#> worker_id timestamp_ys keys
#> <char> <POSc> <char>
#> 1: limestone_drever 2025-10-24 13:34:04 4a471030-1281-48af-bef9-97289f1f2a50
#> 2: limestone_drever 2025-10-24 13:34:04 e400b10c-c971-497d-b77b-d24a0a889e9f
#> 3: limestone_drever 2025-10-24 13:34:04 15c9c83e-7f3f-4ef9-a25f-b0b61580016f
#> 4: limestone_drever 2025-10-24 13:34:04 17a84b50-f7cc-47fb-b344-b9971cb6f805
#> 5: limestone_drever 2025-10-24 13:34:04 2f463dbd-e8e4-40d9-b88a-ed226efd8c31
#> 6: limestone_drever 2025-10-24 13:34:04 b5bfcd35-863e-4151-b029-3417db76ba6f
#> 7: limestone_drever 2025-10-24 13:34:04 db7a8d3f-ea9e-4c20-b3df-f1792a901950
#> 8: limestone_drever 2025-10-24 13:34:04 57bf78ac-989c-4b0e-b6a1-5169078b85f0
#> 9: limestone_drever 2025-10-24 13:34:05 dc311952-4a35-4805-8121-65e0b73ef3db
#> 10: limestone_drever 2025-10-24 13:34:05 64df2fa8-11f6-4eef-915c-9f8ee4092fa1
#> 11: limestone_drever 2025-10-24 13:34:05 ed6f5141-0247-4ad3-a3f0-8f3d3b491c29
#> 12: limestone_drever 2025-10-24 13:34:05 28d9eeb0-6042-4d1e-b054-0e82a3a449e8
#> 13: limestone_drever 2025-10-24 13:34:05 985817d7-268a-4ae2-b523-7f4645845a42
#> 14: limestone_drever 2025-10-24 13:34:05 42d99345-1037-4210-a667-643aacc14107
#> 15: limestone_drever 2025-10-24 13:34:05 ec187022-ce89-4b75-b20f-55b1011ab05c
#> 16: limestone_drever 2025-10-24 13:34:05 084f268c-83d9-4111-a530-c031ae23713d
#> 17: limestone_drever 2025-10-24 13:34:05 739b5b86-1020-45d7-8446-8b69ac576329
#> 18: limestone_drever 2025-10-24 13:34:05 a4bd20fb-816f-405b-b3cd-2659640c44d0
#> 19: limestone_drever 2025-10-24 13:34:05 699140c0-5dfd-48a1-9715-ed1f611d2e65
#> 20: limestone_drever 2025-10-24 13:34:05 0993545a-af34-4369-8855-2d2fb5c75726
#> worker_id timestamp_ys keys
#> x_domain_x1 x_domain_x2
#> <num> <num>
#> 1: 0.7355865 4.436809312
#> 2: -5.2465150 1.685353492
#> 3: -1.6100269 1.692733854
#> 4: -9.6485851 2.074896538
#> 5: 9.1534135 0.636737862
#> 6: -0.9507994 -4.878603549
#> 7: 2.7997505 -1.921276769
#> 8: 7.9367603 3.130829856
#> 9: -5.3535132 0.132857377
#> 10: -1.1703927 1.581480915
#> 11: 5.5692991 1.671339287
#> 12: 9.4659255 -4.325706593
#> 13: -4.5022012 -3.621611151
#> 14: 6.4919932 0.400897277
#> 15: -1.5261497 -0.002130552
#> 16: 5.2346110 -2.546360991
#> 17: -8.1469277 -2.532682236
#> 18: 7.9586287 -3.273955223
#> 19: 5.3650967 -2.241232399
#> 20: 4.8743111 3.778382706
#> x_domain_x1 x_domain_x2