@@ -139,16 +139,17 @@ function SciMLBase.__solve(cache::OptimizationCache{
139
139
error (" Use OptimizationFunction to pass the derivatives or automatically generate them with one of the autodiff backends" )
140
140
141
141
function _cb (trace)
142
- metadata = decompose_trace (trace). metadata
142
+ trace_state = decompose_trace (trace)
143
+ metadata = trace_state. metadata
143
144
θ = metadata[cache. opt isa Optim. NelderMead ? " centroid" : " x" ]
144
- opt_state = Optimization. OptimizationState (iter = trace . iteration,
145
+ opt_state = Optimization. OptimizationState (iter = trace_state . iteration,
145
146
u = θ,
146
147
p = cache. p,
147
- objective = trace . value,
148
+ objective = trace_state . value,
148
149
grad = get (metadata, " g(x)" , nothing ),
149
150
hess = get (metadata, " h(x)" , nothing ),
150
151
original = trace)
151
- cb_call = cache. callback (opt_state, trace . value)
152
+ cb_call = cache. callback (opt_state, trace_state . value)
152
153
if ! (cb_call isa Bool)
153
154
error (" The callback should return a boolean `halt` for whether to stop the optimization process." )
154
155
end
@@ -257,18 +258,19 @@ function SciMLBase.__solve(cache::OptimizationCache{
257
258
local x, cur, state
258
259
259
260
function _cb (trace)
260
- metadata = decompose_trace (trace). metadata
261
+ trace_state = decompose_trace (trace)
262
+ metadata = trace_state. metadata
261
263
θ = ! (cache. opt isa Optim. SAMIN) && cache. opt. method == Optim. NelderMead () ?
262
264
metadata[" centroid" ] :
263
265
metadata[" x" ]
264
- opt_state = Optimization. OptimizationState (iter = trace . iteration,
266
+ opt_state = Optimization. OptimizationState (iter = trace_state . iteration,
265
267
u = θ,
266
268
p = cache. p,
267
- objective = trace . value,
269
+ objective = trace_state . value,
268
270
grad = get (metadata, " g(x)" , nothing ),
269
271
hess = get (metadata, " h(x)" , nothing ),
270
272
original = trace)
271
- cb_call = cache. callback (opt_state, trace . value)
273
+ cb_call = cache. callback (opt_state, trace_state . value)
272
274
if ! (cb_call isa Bool)
273
275
error (" The callback should return a boolean `halt` for whether to stop the optimization process." )
274
276
end
0 commit comments