Skip to content

Commit

Permalink
Change ReturnCodes from SciMLBase
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarsh530 committed Oct 24, 2022
1 parent a737b3e commit 2e26ff2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/bisection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function perform_step(solver::BracketingImmutableSolver, alg::Bisection, cache)

if left == mid || right == mid
@set! solver.force_stop = true
@set! solver.retcode = ReturnCode.Success
@set! solver.retcode = ReturnCode.FloatingPointLimit
return solver
end

Expand Down
4 changes: 2 additions & 2 deletions src/falsi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function perform_step(solver, alg::Falsi, cache)

if right == mid || right == mid
@set! solver.force_stop = true
@set! solver.retcode = ReturnCode.Success
@set! solver.retcode = ReturnCode.FloatingPointLimit
return solver
end

Expand All @@ -32,7 +32,7 @@ function perform_step(solver, alg::Falsi, cache)
@set! solver.force_stop = true
@set! solver.left = mid
@set! solver.fl = fm
@set! solver.retcode = ReturnCode.Success
@set! solver.retcode = ReturnCode.ExactSolutionLeft
else
if sign(fm) == sign(fl)
@set! solver.left = mid
Expand Down
12 changes: 6 additions & 6 deletions src/scalar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function SciMLBase.solve(prob::NonlinearProblem, alg::Bisection, args...; maxite

if iszero(fl)
return SciMLBase.build_solution(prob, alg, left, fl;
retcode = ReturnCode.Success, left = left,
retcode = ReturnCode.ExactSolutionLeft, left = left,
right = right)
end

Expand All @@ -119,7 +119,7 @@ function SciMLBase.solve(prob::NonlinearProblem, alg::Bisection, args...; maxite
mid = (left + right) / 2
(mid == left || mid == right) &&
return SciMLBase.build_solution(prob, alg, left, fl;
retcode = ReturnCode.Success,
retcode = ReturnCode.FloatingPointLimit,
left = left, right = right)
fm = f(mid)
if iszero(fm)
Expand All @@ -141,7 +141,7 @@ function SciMLBase.solve(prob::NonlinearProblem, alg::Bisection, args...; maxite
mid = (left + right) / 2
(mid == left || mid == right) &&
return SciMLBase.build_solution(prob, alg, left, fl;
retcode = ReturnCode.Success,
retcode = ReturnCode.FloatingPointLimit,
left = left, right = right)
fm = f(mid)
if iszero(fm)
Expand All @@ -166,7 +166,7 @@ function SciMLBase.solve(prob::NonlinearProblem, alg::Falsi, args...; maxiters =

if iszero(fl)
return SciMLBase.build_solution(prob, alg, left, fl;
retcode = ReturnCode.Success, left = left,
retcode = ReturnCode.ExactSolutionLeft, left = left,
right = right)
end

Expand All @@ -175,7 +175,7 @@ function SciMLBase.solve(prob::NonlinearProblem, alg::Falsi, args...; maxiters =
while i < maxiters
if nextfloat_tdir(left, prob.u0...) == right
return SciMLBase.build_solution(prob, alg, left, fl;
retcode = ReturnCode.Success,
retcode = ReturnCode.FloatingPointLimit,
left = left, right = right)
end
mid = (fr * left - fl * right) / (fr - fl)
Expand Down Expand Up @@ -205,7 +205,7 @@ function SciMLBase.solve(prob::NonlinearProblem, alg::Falsi, args...; maxiters =
mid = (left + right) / 2
(mid == left || mid == right) &&
return SciMLBase.build_solution(prob, alg, left, fl;
retcode = ReturnCode.Success,
retcode = ReturnCode.FloatingPointLimit,
left = left, right = right)
fm = f(mid)
if iszero(fm)
Expand Down
4 changes: 2 additions & 2 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ function mic_check(solver::BracketingImmutableSolver)
(flr > fzero) && error("Non bracketing interval passed in bracketing method.")
if fl == fzero
@set! solver.force_stop = true
@set! solver.retcode = Retcode.Success
@set! solver.retcode = Retcode.ExactSolutionLeft
elseif fr == fzero
@set! solver.force_stop = true
@set! solver.retcode = Retcode.Success
@set! solver.retcode = Retcode.ExactionSolutionRight
end
solver
end
Expand Down

0 comments on commit 2e26ff2

Please sign in to comment.