Skip to content

Commit f8f4a4a

Browse files
committed
allow for empty error history when TGLFNN fails
1 parent e4bd43b commit f8f4a4a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/actors/transport/flux_matcher_actor.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,18 @@ function _step(actor::ActorFluxMatcher{D,P}) where {D<:Real,P<:Real}
283283
# NonlinearSolve returns the first value if the optimization was not successful
284284
# but we want it to return the best solution, even if the optimization did not
285285
# reach the desired tolerance
286-
if norm(err_history[end]) == norm(err_history[1])
286+
if !isempty(err_history) && length(err_history) > 1 && norm(err_history[end]) == norm(err_history[1])
287287
pop!(err_history)
288288
pop!(z_scaled_history)
289289
end
290290

291291
# Extract the solution vector
292-
k = argmin(map(norm, err_history))
293-
res = (zero=z_scaled_history[k],)
292+
if !isempty(err_history)
293+
k = argmin(map(norm, err_history))
294+
res = (zero=z_scaled_history[k],)
295+
else
296+
res = (zero=opt_parameters,)
297+
end
294298
end
295299

296300
finally

0 commit comments

Comments
 (0)