Skip to content

Commit

Permalink
Merge pull request #25 from lassepe/fix/linearsolve_fail_handling
Browse files Browse the repository at this point in the history
Handle failure of linear solve
  • Loading branch information
dfridovi authored Dec 30, 2024
2 parents 164f07f + 7108a01 commit 30ee358
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SymbolicTracingUtils = "77ddf47f-b2ab-4ded-95ee-54f4fa148129"
TrajectoryGamesBase = "ac1ac542-73eb-4349-ae1b-660ab3609574"
Expand All @@ -24,6 +25,7 @@ FiniteDiff = "2.26.2"
ForwardDiff = "0.10.38"
LinearAlgebra = "1.11.0"
LinearSolve = "2.38.0"
SciMLBase = "2.70.0"
SparseArrays = "1.11.0"
SymbolicTracingUtils = "0.1.1"
TrajectoryGamesBase = "0.3.10"
Expand Down
1 change: 1 addition & 0 deletions src/MixedComplementarityProblems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ using BlockArrays: blocks, blocksizes
using TrajectoryGamesBase: to_blockvector
using SymbolicTracingUtils: SymbolicTracingUtils as SymbolicTracingUtils
using LinearSolve: LinearProblem, init, solve!, KrylovJL_GMRES
using SciMLBase: SciMLBase

include("mcp.jl")
include("solver.jl")
Expand Down
6 changes: 6 additions & 0 deletions src/solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ function solve(
linsolve.A = ∇F + tol * I
linsolve.b = -F
solution = solve!(linsolve)
if !SciMLBase.successful_retcode(solution)
verbose && @warn "Linear solve failed. Exiting prematurely."
status = :failed
break
end

δz .= solution.u

# Fraction to the boundary linesearch.
Expand Down

0 comments on commit 30ee358

Please sign in to comment.