Skip to content

Commit 35bf7e6

Browse files
Merge pull request #180 from SciML/Vaibhavdixit02-patch-1
Use the minimum with save_best in flux optimiser
2 parents 1767144 + 1e6f030 commit 35bf7e6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/solve/flux.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ function __solve(prob::OptimizationProblem, opt::AbstractFluxOptimiser, data = D
2828
θ = copy(prob.u0)
2929
G = copy(θ)
3030

31-
local x, min_err, _loss
31+
local x, min_err, min_θ
3232
min_err = typemax(eltype(prob.u0)) #dummy variables
3333
min_opt = 1
34+
min_θ = prob.u0
3435

3536
f = instantiate_function(prob.f,prob.u0,prob.f.adtype,prob.p)
3637

@@ -53,10 +54,13 @@ function __solve(prob::OptimizationProblem, opt::AbstractFluxOptimiser, data = D
5354
if first(x) < first(min_err) #found a better solution
5455
min_opt = opt
5556
min_err = x
57+
min_θ = copy(θ)
5658
end
5759
if i == maxiters #Last iteration, revert to best.
5860
opt = min_opt
59-
cb(θ,min_err...)
61+
x = min_err
62+
θ = min_θ
63+
cb(θ,x...)
6064
end
6165
end
6266
end

0 commit comments

Comments
 (0)