From 1e4f34e847cbedae5b807efd721f5fd0ab613771 Mon Sep 17 00:00:00 2001 From: Lennart Schneider Date: Mon, 12 Aug 2024 13:51:32 +0200 Subject: [PATCH 1/2] fix: opimizer batch on_optimzation_end callback --- R/OptimizerBatch.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/OptimizerBatch.R b/R/OptimizerBatch.R index 30c7d87d..22b74253 100644 --- a/R/OptimizerBatch.R +++ b/R/OptimizerBatch.R @@ -67,6 +67,7 @@ optimize_batch_default = function(instance, optimizer) { lg$info("Result:") lg$info(capture.output(print( instance$result, lass = FALSE, row.names = FALSE, print.keys = FALSE))) + call_back("on_optimization_end", instance$objective$callbacks, instance$objective$context) return(instance$result) } From ec5d04500eb3899c0ff89a32d910e5da8f108913 Mon Sep 17 00:00:00 2001 From: Lennart Schneider Date: Mon, 12 Aug 2024 14:30:10 +0200 Subject: [PATCH 2/2] test: fix callback test for after optim end which was wrong from the start --- tests/testthat/test_Callback.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test_Callback.R b/tests/testthat/test_Callback.R index 7b64c906..a163b839 100644 --- a/tests/testthat/test_Callback.R +++ b/tests/testthat/test_Callback.R @@ -35,7 +35,7 @@ test_that("on_optimization_end works", { optimizer = opt("random_search") optimizer$optimize(instance) expect_class(instance$objective$context, "ContextBatch") - expect_equal(instance$terminator$param_set$values$n_evals, 10) + expect_equal(instance$terminator$param_set$values$n_evals, 20) }) test_that("on_result in OptimInstanceBatchSingleCrit works", {