@@ -65,6 +65,7 @@ function ___solve(prob::OptimizationProblem, opt::Optim.AbstractOptimizer,
65
65
reltol:: Union{Number,Nothing} = nothing ,
66
66
progress= false ,
67
67
kwargs... )
68
+
68
69
local x, cur, state
69
70
70
71
if data != GalacticOptim. DEFAULT_DATA
@@ -78,8 +79,13 @@ function ___solve(prob::OptimizationProblem, opt::Optim.AbstractOptimizer,
78
79
if ! (typeof (cb_call) <: Bool )
79
80
error (" The callback should return a boolean `halt` for whether to stop the optimization process." )
80
81
end
81
- cur, state = iterate (data, state)
82
- cb_call
82
+ nx_itr = iterate (data, state)
83
+ if isnothing (nx_itr)
84
+ true
85
+ else
86
+ cur, state = nx_itr
87
+ cb_call
88
+ end
83
89
end
84
90
85
91
maxiters = GalacticOptim. _check_and_convert_maxiters (maxiters)
@@ -163,8 +169,13 @@ function ___solve(prob::OptimizationProblem, opt::Union{Optim.Fminbox,Optim.SAMI
163
169
if ! (typeof (cb_call) <: Bool )
164
170
error (" The callback should return a boolean `halt` for whether to stop the optimization process." )
165
171
end
166
- cur, state = iterate (data, state)
167
- cb_call
172
+ nx_itr = iterate (data, state)
173
+ if isnothing (nx_itr)
174
+ true
175
+ else
176
+ cur, state = nx_itr
177
+ cb_call
178
+ end
168
179
end
169
180
170
181
maxiters = GalacticOptim. _check_and_convert_maxiters (maxiters)
@@ -231,8 +242,13 @@ function ___solve(prob::OptimizationProblem, opt::Optim.ConstrainedOptimizer,
231
242
if ! (typeof (cb_call) <: Bool )
232
243
error (" The callback should return a boolean `halt` for whether to stop the optimization process." )
233
244
end
234
- cur, state = iterate (data, state)
235
- cb_call
245
+ nx_itr = iterate (data, state)
246
+ if isnothing (nx_itr)
247
+ true
248
+ else
249
+ cur, state = nx_itr
250
+ cb_call
251
+ end
236
252
end
237
253
238
254
maxiters = GalacticOptim. _check_and_convert_maxiters (maxiters)
0 commit comments