Skip to content

Commit 87a042d

Browse files
committed
support optimizer-specific stopping checks
1 parent 46b745a commit 87a042d

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/opt_controller.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ function check_stop_condition(ctrl::OptRunController)
201201
return "Max number of steps ($(ctrl.max_steps)) reached"
202202
end
203203

204-
return check_stop_condition(ctrl.evaluator, ctrl)
204+
eval_check = check_stop_condition(ctrl.evaluator, ctrl)
205+
isempty(eval_check) || return eval_check
206+
207+
optimizer_check = check_stop_condition(ctrl.optimizer, ctrl)
208+
return optimizer_check
205209

206210
return "" # empty string, no termination
207211
end

src/optimizer.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Base abstract class for black-box optimization algorithms.
33
"""
44
abstract type Optimizer end
55

6+
# by default optimizer doesn't check for stopping conditions
7+
check_stop_condition(o::Optimizer, ctrl) = ""
8+
69
"""
710
Optimizers derived from `SteppingOptimizer` implement classical iterative optimization scheme
811
`step!()` → `step!()` → …

0 commit comments

Comments
 (0)