Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into adbo
Browse files Browse the repository at this point in the history
  • Loading branch information
sumny committed Nov 15, 2024
2 parents 86f2e28 + ddbb5ef commit dd2fb9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
13 changes: 8 additions & 5 deletions R/ResultAssignerArchive.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ ResultAssignerArchive = R6Class("ResultAssignerArchive",
#' The [bbotk::OptimInstance] the final result should be assigned to.
assign_result = function(instance) {
xydt = instance$archive$best()
xdt = xydt[, instance$search_space$ids(), with = FALSE]
cols_x = instance$archive$cols_x
cols_y = instance$archive$cols_y
xdt = xydt[, cols_x, with = FALSE]
extra = xydt[, !c(cols_x, cols_y), with = FALSE]
if (inherits(instance, c("OptimInstanceBatchMultiCrit", "OptimInstanceAsyncMultiCrit"))) {
ydt = xydt[, instance$archive$cols_y, with = FALSE]
instance$assign_result(xdt, ydt, xydt = xydt)
ydt = xydt[, cols_y, with = FALSE]
instance$assign_result(xdt, ydt, extra = extra)
}
else {
y = unlist(xydt[, instance$archive$cols_y, with = FALSE])
instance$assign_result(xdt, y, xydt = xydt)
y = unlist(xydt[, cols_y, with = FALSE])
instance$assign_result(xdt = xdt, y = y, extra = extra)
}
}
),
Expand Down
11 changes: 7 additions & 4 deletions R/ResultAssignerSurrogate.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@ ResultAssignerSurrogate = R6Class("ResultAssignerSurrogate",
archive_tmp = archive$clone(deep = TRUE)
archive_tmp$data[, self$surrogate$cols_y := means]
xydt = archive_tmp$best()
best = xydt[, archive_tmp$cols_x, with = FALSE]
cols_x = archive_tmp$cols_x
cols_y = archive_tmp$cols_y
best = xydt[, cols_x, with = FALSE]
extra = xydt[, !c(cols_x, cols_y), with = FALSE]

# ys are still the ones originally evaluated
best_y = if (inherits(instance, c("OptimInstanceBatchSingleCrit", "OptimInstanceAsyncSingleCrit"))) {
unlist(archive$data[best, on = archive$cols_x][, archive$cols_y, with = FALSE])
unlist(archive$data[best, on = cols_x][, cols_y, with = FALSE])
} else if (inherits(instance, c("OptimInstanceBatchMultiCrit", "OptimInstanceAsyncMultiCrit"))) {
archive$data[best, on = archive$cols_x][, archive$cols_y, with = FALSE]
archive$data[best, on = cols_x][, cols_y, with = FALSE]
}
instance$assign_result(xdt = best, best_y, xydt = xydt)
instance$assign_result(xdt = best, y = best_y, extra = extra)
}
),

Expand Down

0 comments on commit dd2fb9b

Please sign in to comment.