Skip to content

Commit ddbb5ef

Browse files
authored
refactor: pass extra information of the result in the extra parameter (#168)
* refactor: pass extra information of the result in the extra parameter * remove remotes
1 parent c249a51 commit ddbb5ef

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ BugReports: https://github.com/mlr-org/mlr3mbo/issues
4141
Depends:
4242
R (>= 3.1.0)
4343
Imports:
44-
bbotk (>= 1.1.1),
44+
bbotk (>= 1.2.0),
4545
checkmate (>= 2.0.0),
4646
data.table,
4747
lgr (>= 0.3.4),

R/ResultAssignerArchive.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,19 @@ ResultAssignerArchive = R6Class("ResultAssignerArchive",
3030
#' The [bbotk::OptimInstance] the final result should be assigned to.
3131
assign_result = function(instance) {
3232
xydt = instance$archive$best()
33-
xdt = xydt[, instance$search_space$ids(), with = FALSE]
33+
cols_x = instance$archive$cols_x
34+
cols_y = instance$archive$cols_y
35+
36+
xdt = xydt[, cols_x, with = FALSE]
37+
extra = xydt[, !c(cols_x, cols_y), with = FALSE]
38+
3439
if (inherits(instance, "OptimInstanceBatchMultiCrit")) {
35-
ydt = xydt[, instance$archive$cols_y, with = FALSE]
36-
instance$assign_result(xdt, ydt, xydt = xydt)
40+
ydt = xydt[, cols_y, with = FALSE]
41+
instance$assign_result(xdt, ydt, extra = extra)
3742
}
3843
else {
39-
y = unlist(xydt[, instance$archive$cols_y, with = FALSE])
40-
instance$assign_result(xdt, y, xydt = xydt)
44+
y = unlist(xydt[, cols_y, with = FALSE])
45+
instance$assign_result(xdt, y, extra = extra)
4146
}
4247
}
4348
),

R/ResultAssignerSurrogate.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ResultAssignerSurrogate = R6Class("ResultAssignerSurrogate",
6060
archive_tmp = archive$clone(deep = TRUE)
6161
archive_tmp$data[, self$surrogate$cols_y := means]
6262
xydt = archive_tmp$best()
63+
extra = xydt[, !c(archive_tmp$cols_x, archive_tmp$cols_y), with = FALSE]
6364
best = xydt[, archive_tmp$cols_x, with = FALSE]
6465

6566
# ys are still the ones originally evaluated
@@ -68,7 +69,7 @@ ResultAssignerSurrogate = R6Class("ResultAssignerSurrogate",
6869
} else if (inherits(instance, "OptimInstanceBatchMultiCrit")) {
6970
archive$data[best, on = archive$cols_x][, archive$cols_y, with = FALSE]
7071
}
71-
instance$assign_result(xdt = best, best_y, xydt = xydt)
72+
instance$assign_result(xdt = best, best_y, extra = extra)
7273
}
7374
),
7475

0 commit comments

Comments
 (0)