Skip to contents

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. The x_domain column is unnested to separate columns.

See also

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

Inherited 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.

Usage

ArchiveAsyncFrozen$push_points(xss)

Arguments

xss

(list of named list())
List of named lists of point values.


Method pop_point()

Pop a point from the queue.

Usage

ArchiveAsyncFrozen$pop_point()


Method push_running_point()

Push running point to the archive.

Usage

ArchiveAsyncFrozen$push_running_point(xs, extra = NULL)

Arguments

xs

(named list)
Named list of point values.

extra

(list())
Named list of additional information.


Method push_result()

Push result to the archive.

Usage

ArchiveAsyncFrozen$push_result(key, ys, x_domain, extra = NULL)

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.

Usage

ArchiveAsyncFrozen$push_failed_point(key, message)

Arguments

key

(character())
Key of the point.

message

(character())
Error message.


Method data_with_state()

Fetch points with a specific state.

Usage

ArchiveAsyncFrozen$data_with_state(
  fields = c("xs", "ys", "xs_extra", "worker_extra", "ys_extra", "condition"),
  states = c("queued", "running", "finished", "failed"),
  reset_cache = FALSE
)

Arguments

fields

(character())
Fields to fetch. Defaults to c("xs", "ys", "xs_extra", "worker_extra", "ys_extra").

states

(character())
States of the tasks to be fetched. Defaults to c("queued", "running", "finished", "failed").

reset_cache

(logical(1))
Whether to reset the cache of the finished points.


Method clear()

Clear all evaluation results from archive.

Usage

ArchiveAsyncFrozen$clear()


Method clone()

The objects of this class are cloneable with this method.

Usage

ArchiveAsyncFrozen$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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:28:36  8766
#>  2: finished -5.2465150  1.685353492  -64.4645163 2025-10-24 13:28:36  8766
#>  3: finished -1.6100269  1.692733854  -25.0540453 2025-10-24 13:28:36  8766
#>  4: finished -9.6485851  2.074896538 -151.4441090 2025-10-24 13:28:36  8766
#>  5: finished  9.1534135  0.636737862  -54.3971877 2025-10-24 13:28:36  8766
#>  6: finished -0.9507994 -4.878603549   -2.2363683 2025-10-24 13:28:36  8766
#>  7: finished  2.7997505 -1.921276769    8.1967553 2025-10-24 13:28:36  8766
#>  8: finished  7.9367603  3.130829856  -62.8321976 2025-10-24 13:28:36  8766
#>  9: finished -5.3535132  0.132857377  -53.8889510 2025-10-24 13:28:36  8766
#> 10: finished -1.1703927  1.581480915  -21.0413571 2025-10-24 13:28:36  8766
#> 11: finished  5.5692991  1.671339287  -24.5613067 2025-10-24 13:28:36  8766
#> 12: finished  9.4659255 -4.325706593  -47.4975413 2025-10-24 13:28:36  8766
#> 13: finished -4.5022012 -3.621611151  -32.6650205 2025-10-24 13:28:36  8766
#> 14: finished  6.4919932  0.400897277  -21.7441056 2025-10-24 13:28:36  8766
#> 15: finished -1.5261497 -0.002130552  -11.4209531 2025-10-24 13:28:36  8766
#> 16: finished  5.2346110 -2.546360991   -0.6684964 2025-10-24 13:28:36  8766
#> 17: finished -8.1469277 -2.532682236  -93.1785285 2025-10-24 13:28:36  8766
#> 18: finished  7.9586287 -3.273955223  -25.5803070 2025-10-24 13:28:36  8766
#> 19: finished  5.3650967 -2.241232399   -1.8996043 2025-10-24 13:28:36  8766
#> 20: finished  4.8743111  3.778382706  -44.2081363 2025-10-24 13:28:36  8766
#>        state         x1           x2            y        timestamp_xs   pid
#>            worker_id        timestamp_ys                                 keys
#>               <char>              <POSc>                               <char>
#>  1: limestone_drever 2025-10-24 13:28:36 680992e1-71bb-4ce9-9c59-b6033b522ea5
#>  2: limestone_drever 2025-10-24 13:28:36 571d6c71-ffca-4801-9a21-532f6a318adf
#>  3: limestone_drever 2025-10-24 13:28:36 8871e129-20d2-4e46-807f-aa2541712e36
#>  4: limestone_drever 2025-10-24 13:28:36 22fd5eed-27d5-48d9-bb73-40a18cf96b76
#>  5: limestone_drever 2025-10-24 13:28:36 f7b7487b-a328-4314-8de6-9544deadefc7
#>  6: limestone_drever 2025-10-24 13:28:36 d63d9e47-b12e-4649-9416-6982fbcdb341
#>  7: limestone_drever 2025-10-24 13:28:36 46348883-4c07-44a3-b985-79bf3d3796fc
#>  8: limestone_drever 2025-10-24 13:28:36 07f4201c-c3b8-4a33-8652-111cf96f7506
#>  9: limestone_drever 2025-10-24 13:28:36 bf3ad838-e96f-4c1f-9247-e9351f75bb70
#> 10: limestone_drever 2025-10-24 13:28:36 2177bb20-b050-47d9-a80d-675cb345c86a
#> 11: limestone_drever 2025-10-24 13:28:36 5a123b32-a853-42aa-b03f-c2acd011827e
#> 12: limestone_drever 2025-10-24 13:28:36 51a519d1-c9a4-4f3f-973d-434e0ec900e1
#> 13: limestone_drever 2025-10-24 13:28:36 9c8dd922-50c6-4708-901e-e3bcdd846490
#> 14: limestone_drever 2025-10-24 13:28:36 59cb6736-bf9a-4608-afd1-595f05c9908f
#> 15: limestone_drever 2025-10-24 13:28:36 f4fe9af7-51cb-4324-ae53-f4a0c1cc9a46
#> 16: limestone_drever 2025-10-24 13:28:36 f500d672-2753-4af6-8e25-a96319f4e1db
#> 17: limestone_drever 2025-10-24 13:28:36 ecc11aac-3024-4772-bcd8-112724c030a7
#> 18: limestone_drever 2025-10-24 13:28:36 99e2087a-553e-4852-96ed-823f9d788461
#> 19: limestone_drever 2025-10-24 13:28:36 5a465d38-565a-43a5-a910-a4b133b96382
#> 20: limestone_drever 2025-10-24 13:28:36 4aeeae4b-db24-46e8-8ab0-8a52147e4e3d
#>            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