Skip to content

Commit d029b85

Browse files
committed
refactor(OptimizationBBO): simplify loss function
the loss function returns a vector or tuple in the multi-objective case and a scalar in the single objective case. no need for global variables
1 parent b5c38d7 commit d029b85

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

lib/OptimizationBBO/src/OptimizationBBO.jl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{
116116
P,
117117
C
118118
}
119-
local x, cur, state
120119

121120
function _cb(trace)
122121
if cache.callback === Optimization.DEFAULT_CALLBACK
@@ -147,13 +146,7 @@ function SciMLBase.__solve(cache::Optimization.OptimizationCache{
147146
maxtime = Optimization._check_and_convert_maxtime(cache.solver_args.maxtime)
148147

149148
_loss = function (θ)
150-
if isa(cache.f, MultiObjectiveOptimizationFunction)
151-
x = (cache.f(θ, cache.p),)
152-
return x[1]
153-
else
154-
x = cache.f(θ, cache.p)
155-
return first(x)
156-
end
149+
cache.f(θ, cache.p)
157150
end
158151

159152
opt_args = __map_optimizer_args(cache, cache.opt;

0 commit comments

Comments
 (0)