Skip to content

Commit

Permalink
Throw error from callback true in NLopt
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhavdixit02 committed Aug 7, 2023
1 parent 600e73d commit 0f32755
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/OptimizationNLopt/src/OptimizationNLopt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ function SciMLBase.__solve(cache::OptimizationCache{

_loss = function (θ)
x = cache.f(θ, cache.p)
cache.callback(θ, x...)
if cache.callback(θ, x...)
error("Optimization halted by callback.")
end
return x[1]
end

Expand Down

0 comments on commit 0f32755

Please sign in to comment.