Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update retcode handling #184

Merged
merged 1 commit into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/cost_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ function (f::L2Loss)(sol::DiffEqBase.AbstractNoTimeSolution)
dudt = f.dudt

if sol isa DiffEqBase.AbstractEnsembleSolution
failure = any(s.retcode !== :Success && s.retcode !== :Terminated for s in sol)
failure = any(!SciMLBase.successful_retcode(s.retcode) for s in sol)
else
failure = sol.retcode !== :Success && sol.retcode !== :Terminated
failure = !SciMLBase.successful_retcode(sol.retcode)
end
failure && return Inf

Expand Down Expand Up @@ -72,9 +72,9 @@ function (f::L2Loss)(sol::SciMLBase.AbstractSciMLSolution)
dudt = f.dudt

if sol isa DiffEqBase.AbstractEnsembleSolution
failure = any(s.retcode !== :Success && s.retcode !== :Terminated for s in sol)
failure = any(!SciMLBase.successful_retcode(s.retcode) for s in sol)
else
failure = sol.retcode !== :Success && sol.retcode !== :Terminated
failure = !SciMLBase.successful_retcode(sol.retcode)
end
failure && return Inf

Expand Down Expand Up @@ -171,9 +171,9 @@ end
function (f::LogLikeLoss)(sol::SciMLBase.AbstractSciMLSolution)
distributions = f.data_distributions
if sol isa DiffEqBase.AbstractEnsembleSolution
failure = any(s.retcode !== :Success && s.retcode !== :Terminated for s in sol)
failure = any(!SciMLBase.successful_retcode(s.retcode) for s in sol)
else
failure = sol.retcode !== :Success && sol.retcode !== :Terminated
failure = !SciMLBase.successful_retcode(sol.retcode)
end
failure && return Inf
ll = 0.0
Expand Down Expand Up @@ -220,9 +220,9 @@ end
function (f::LogLikeLoss)(sol::DiffEqBase.AbstractEnsembleSolution)
distributions = f.data_distributions
if sol_tmp isa DiffEqBase.AbstractEnsembleSolution
failure = any(s.retcode !== :Success && s.retcode !== :Terminated for s in sol_tmp)
failure = any(!SciMLBase.successful_retcode(s.retcode) for s in sol_tmp)
else
failure = sol_tmp.retcode !== :Success && sol_tmp.retcode !== :Terminated
failure = !SciMLBase.successful_retcode(sol_tmp.retcode)
end
failure && return Inf
ll = 0.0
Expand Down
4 changes: 2 additions & 2 deletions src/multiple_shooting_objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function multiple_shooting_objective(prob::DiffEqBase.DEProblem, alg, loss,
push!(sol, solve(tmp_prob, alg; kwargs...))
end
end
if any((s.retcode != :Success for s in sol))
if any((!SciMLBase.successful_retcode(s.retcode) for s in sol))
return Inf
end
u = [uc for k in 1:K for uc in sol[k].u[1:(end - 1)]]
Expand All @@ -63,7 +63,7 @@ function multiple_shooting_objective(prob::DiffEqBase.DEProblem, alg, loss,
push!(t, sol[K].t[end])
sol_loss = Merged_Solution(u, t, sol)
sol_new = DiffEqBase.build_solution(prob, alg, sol_loss.t, sol_loss.u,
retcode = :Success)
retcode = ReturnCode.Success)
loss_val = loss(sol_new)
if priors !== nothing
loss_val += prior_loss(priors, p[(end - length(priors)):end])
Expand Down