Skip to content

Commit 110b804

Browse files
Merge pull request #109 from JuliaDiffEq/ChrisRackauckas-patch-1
better retcode handling
2 parents 99bf1cc + e9fb8a1 commit 110b804

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cost_functions.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function (f::L2Loss)(sol::DiffEqBase.DESolution)
3939
colloc_grad = f.colloc_grad
4040
dudt = f.dudt
4141

42-
if sol.retcode != :Success
42+
if any((s.retcode != :Success for s in sol)) && any((s.retcode != :Terminated for s in sol))
4343
return Inf
4444
end
4545

@@ -124,7 +124,7 @@ LogLikeLoss(t,data_distributions,diff_distributions) = LogLikeLoss(t,matrixize(d
124124

125125
function (f::LogLikeLoss)(sol::DESolution)
126126
distributions = f.data_distributions
127-
if sol.retcode != :Success
127+
if any((s.retcode != :Success for s in sol)) && any((s.retcode != :Terminated for s in sol))
128128
return Inf
129129
end
130130
ll = 0.0
@@ -170,7 +170,7 @@ end
170170

171171
function (f::LogLikeLoss)(sol::DiffEqBase.AbstractMonteCarloSolution)
172172
distributions = f.data_distributions
173-
if any((s.retcode != :Success for s in sol))
173+
if any((s.retcode != :Success for s in sol)) && any((s.retcode != :Terminated for s in sol))
174174
return Inf
175175
end
176176
ll = 0.0

0 commit comments

Comments
 (0)