Skip to content

Commit

Permalink
[#179] Make compatible with IterativeSolvers v0.9+ (#180)
Browse files Browse the repository at this point in the history
* [#179] Make compatible with IterativeSolvers v0.9+

- Fix a breaking change in IterativeSolvers API
- Add information to docs about which version of IterativeSolvers to use
- Add version constraint to Project.toml

* Move CI test from Julia v1.0 to next LTS v1.6
  • Loading branch information
migarstka authored Jul 23, 2023
1 parent 39714ed commit bad6be7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- version: '1'
os: ubuntu-latest
arch: x64
- version: '1.0'
- version: '1.6'
os: ubuntu-latest
arch: x64
- version: '1'
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ AMD = "0.4, 0.5"
COSMOAccelerators = "^0.1.0"
DataStructures = "^0.17.0, ^0.18.0"
IterTools = "^1"
IterativeSolvers = "^0.9"
MathOptInterface = "~0.10.7, 1"
QDLDL = "0.4.1"
Reexport = "0.2, ^1"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lin_solver.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CGIndirectKKTSolver | IterativeSolvers.jl | Conjugate Gradients on the reduced K
MINRESIndirectKKTSolver | IterativeSolvers.jl | MINRES on the (full) KKT linear system.

!!! note
To use the Pardiso and Intel MKL Pardiso solver, you have to install the respective libraries and the corresponding Julia wrapper. For more information about installing these, visit the [Pardiso.jl](https://github.com/JuliaSparse/Pardiso.jl) repository page. Likewise in order to use Indirect(Reduced)KKTSolver you have to install [IterativeSolvers.jl](https://github.com/JuliaMath/IterativeSolvers.jl) and [LinearMaps.jl](https://github.com/Jutho/LinearMaps.jl). We are using the `Requires` package for lazy loading of code related to `Pardiso` and `IterativeSolvers`. This means in order to use `Pardiso` / `IterativeSolvers`, you'll have to load these packages alongside `COSMO`, i.e. `using Pardiso` and `using IterativeSolvers, LinearMaps`.
To use the Pardiso and Intel MKL Pardiso solver, you have to install the respective libraries and the corresponding Julia wrapper. For more information about installing these, visit the [Pardiso.jl](https://github.com/JuliaSparse/Pardiso.jl) repository page. Likewise in order to use Indirect(Reduced)KKTSolver you have to install [IterativeSolvers.jl](https://github.com/JuliaMath/IterativeSolvers.jl) (v0.9+) and [LinearMaps.jl](https://github.com/Jutho/LinearMaps.jl). We are using the `Requires` package for lazy loading of code related to `Pardiso` and `IterativeSolvers`. This means in order to use `Pardiso` / `IterativeSolvers`, you'll have to load these packages alongside `COSMO`, i.e. `using Pardiso` and `using IterativeSolvers, LinearMaps`.

COSMO uses the `Cholmod` linear system solver by default. You can specify a different solver in the settings by using the `kkt_solver` keyword and the respective type:

Expand Down
6 changes: 3 additions & 3 deletions src/linear_solver/kktsolver_indirect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ function solve!(S::IndirectReducedKKTSolver, y::AbstractVector{T}, x::AbstractVe
end
L = LinearMap(reduced_mul!, S.n; ismutating=true, issymmetric=true)
if S.solver_type == :CG
cg!(S.previous_solution, L, y1, tol=get_tolerance(S)/norm(y1))
cg!(S.previous_solution, L, y1, abstol=get_tolerance(S)/norm(y1), reltol = 0.)
elseif S.solver_type == :MINRES
init_residual = norm(L*S.previous_solution - y1)
minres!(S.previous_solution, L, y1, tol=get_tolerance(S)/init_residual)
minres!(S.previous_solution, L, y1, abstol=get_tolerance(S)/init_residual, reltol = 0.)
end
# Sanity check for tolerance
# might not always hold for MINRES, as its termination criterion is approximate, (see its documentation)
Expand Down Expand Up @@ -149,7 +149,7 @@ function solve!(S::IndirectKKTSolver, y::AbstractVector{T}, x::AbstractVector{T}
L = LinearMap(kkt_mul!, S.n + S.m; ismutating=true, issymmetric=true)
if S.solver_type == :MINRES
init_residual = norm(L*S.previous_solution - x)
minres!(S.previous_solution, L, x, tol=get_tolerance(S)/init_residual)
minres!(S.previous_solution, L, x, abstol=get_tolerance(S)/init_residual, reltol = 0.)
end
# Sanity check for tolerance
# might not always hold for MINRES, as its termination criterion is approximate, (see its documentation)
Expand Down

0 comments on commit bad6be7

Please sign in to comment.