Skip to content

Commit 07eafc4

Browse files
Merge pull request #89 from SciML/pardiso2
Fix Pardiso analysis saving
2 parents f2f1b52 + 122e0d6 commit 07eafc4

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/pardiso.jl

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,30 @@ function init_cacheval(alg::PardisoJL, A, b, u, Pl, Pr, maxiters, abstol, reltol
6060
# Make sure to say it's transposed because its CSC not CSR
6161
Pardiso.set_iparm!(solver,12, 1)
6262

63+
#=
64+
Note: It is recommended to use IPARM(11)=1 (scaling) and IPARM(13)=1 (matchings) for
65+
highly indefinite symmetric matrices e.g. from interior point optimizations or saddle point problems.
66+
It is also very important to note that the user must provide in the analysis phase (PHASE=11)
67+
the numerical values of the matrix A if IPARM(11)=1 (scaling) or PARM(13)=1 or 2 (matchings).
68+
69+
The numerical values will be incorrect since the analysis is ran once and
70+
cached. If these two are not set, then Pardiso.NUM_FACT in the solve must
71+
be changed to Pardiso.ANALYSIS_NUM_FACT in the solver loop otherwise instabilities
72+
occur in the example https://github.com/SciML/OrdinaryDiffEq.jl/issues/1569
73+
=#
74+
Pardiso.set_iparm!(solver,11, 0)
75+
Pardiso.set_iparm!(solver,13, 0)
76+
6377
Pardiso.set_phase!(solver, Pardiso.ANALYSIS)
78+
79+
if alg.solver_type == 1
80+
# PARDISO uses a numerical factorization A = LU for the first system and
81+
# applies these exact factors L and U for the next steps in a
82+
# preconditioned Krylov-Subspace iteration. If the iteration does not
83+
# converge, the solver will automatically switch back to the numerical factorization.
84+
Pardiso.set_iparm!(solver,3,round(Int,abs(log10(reltol)),RoundDown) * 10 + 1)
85+
end
86+
6487
Pardiso.pardiso(solver, u, A, b)
6588

6689
return solver
@@ -72,11 +95,11 @@ function SciMLBase.solve(cache::LinearCache, alg::PardisoJL; kwargs...)
7295

7396
if cache.isfresh
7497
Pardiso.set_phase!(cache.cacheval, Pardiso.NUM_FACT)
75-
Pardiso.pardiso(cache.cacheval, u, A, b)
98+
Pardiso.pardiso(cache.cacheval, A, eltype(A)[])
7699
end
100+
77101
Pardiso.set_phase!(cache.cacheval, Pardiso.SOLVE_ITERATIVE_REFINE)
78102
Pardiso.pardiso(cache.cacheval, u, A, b)
79-
80103
return SciMLBase.build_linear_solution(alg,cache.u,nothing,cache)
81104
end
82105

0 commit comments

Comments
 (0)