Skip to content

Commit

Permalink
Update loss function in OptimizationBBO.jl
Browse files Browse the repository at this point in the history
Updated the __loss function to handle MOOFunction results.
  • Loading branch information
ParasPuneetSingh authored Jul 26, 2024
1 parent 49ba1c1 commit 0bce2a8
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions lib/OptimizationBBO/src/OptimizationBBO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,32 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{
maxtime = Optimization._check_and_convert_maxtime(cache.solver_args.maxtime)

_loss = function (θ)
if cache.callback === Optimization.DEFAULT_CALLBACK &&
cache.data === Optimization.DEFAULT_DATA
return first(cache.f(θ, cache.p))
elseif cache.callback === Optimization.DEFAULT_CALLBACK
return first(cache.f(θ, cache.p, cur...))
elseif cache.data !== Optimization.DEFAULT_DATA
x = cache.f(θ, cache.p)
return first(x)
if isa(f, MultiObjectiveOptimizationFunction)
if cache.callback === Optimization.DEFAULT_CALLBACK &&
cache.data === Optimization.DEFAULT_DATA
return cache.f(θ, cache.p)
elseif cache.callback === Optimization.DEFAULT_CALLBACK
return cache.f(θ, cache.p, cur...)
elseif cache.data !== Optimization.DEFAULT_DATA
x = cache.f(θ, cache.p)
return x
else
x = cache.f(θ, cache.p, cur...)
return first(x)
end
else
x = cache.f(θ, cache.p, cur...)
return first(x)
if cache.callback === Optimization.DEFAULT_CALLBACK &&
cache.data === Optimization.DEFAULT_DATA
return first(cache.f(θ, cache.p))
elseif cache.callback === Optimization.DEFAULT_CALLBACK
return first(cache.f(θ, cache.p, cur...))
elseif cache.data !== Optimization.DEFAULT_DATA
x = cache.f(θ, cache.p)
return first(x)
else
x = cache.f(θ, cache.p, cur...)
return first(x)
end
end
end

Expand Down

0 comments on commit 0bce2a8

Please sign in to comment.