Minres Fail to solve subproblem and cuases R2N solver to Max_timed
bug
We are using Krylov as a subsolver for R2N, you can access it https://github.com/Farhad-phd/JSOSolvers.jl.git#R2N_R2NLS_2026_Jan
Here is the code that shows
```julia
using Revise
using JSOSolvers
using HSL
using Arpack, TSVD, GenericLinearAlgebra
using SparseArrays, LinearAlgebra
using ADNLPModels, Krylov, LinearOperators, NLPModels, NLPModelsModifiers, SolverCore
using Printf
using CUTEst
# 1. Define the Problem
n = 30
nlp = ADNLPModel(
x -> sum(100 * (x[i + 1] - x[i]^2)^2 + (x[i] - 1)^2 for i = 1:(n - 1)),
collect(1:n) ./ (n + 1),
name = "Extended Rosenbrock",
)
println("\nSubsolver = Minres, NPC Handler = AG")
stats_minres =
R2N(nlp; verbose = 1, max_iter = 50, subsolver = MinresR2NSubsolver, npc_handler = :ag, subsolver_verbose = 1)
println("\nSubsolver = CR, NPC Handler = AG")
stats_cr = R2N(nlp; verbose = 1, max_iter = 200, subsolver = CRR2NSubsolver, npc_handler = :ag, subsolver_verbose = 1)
println("\nSubsolver = MinresQlp, NPC Handler = AG")
stats_minres_qlp =
R2N(nlp; verbose = 1, max_iter = 50, subsolver = MinresQlpR2NSubsolver, npc_handler = :ag, subsolver_verbose = 1)
println("\nStastics Summary:")
println("stats_minres: ", stats_minres)
println("stats_cr: ", stats_cr)
println("stats_minres_qlp: ", stats_minres_qlp)
```
Here is the results:
```
Stastics Summary:
stats_minres: Generic Execution stats
status: maximum iteration
objective value: 68.38758422768275
primal feasibility: 0.0
dual feasibility: 25.73140889343297
solution: [0.9889333207366354 0.9769356894569213 0.9521497483850498 0.899043128944154 ⋯ 0.9478308012350751]
iterations: 51
elapsed time: 0.3819999694824219
stats_minres_qlp: Generic Execution stats
status: first-order stationary
objective value: 8.264512926113936e-15
primal feasibility: 0.0
dual feasibility: 9.208909843275436e-8
solution: [1.0000000000023905 1.0000000000024127 1.0000000000013747 1.0000000000012088 ⋯ 0.9999998422126554]
iterations: 35
elapsed time: 0.0280001163482666
```
here is the first 5 iteration of the R2N with subsolver verbose = 1
```
Subsolver = Minres, NPC Handler = AG
[ Info: iter f(x) ‖∇f‖ ‖s‖ σ ρ subiter dir
[ Info: 0 1.5e+02 7.6e+01 0.0e+00 8.4e-01 0.0e+00 0
MINRES: system of size 30
k ‖r‖ ‖Aᴴr‖ β cos sin ‖A‖ κ(A) test1 test2 timer
0 7.6e+01 0.0e+00 7.6e+01 -1.0e+00 0.0e+00 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.00s
1 7.4e+01 1.4e+04 1.8e+02 2.7e-01 9.6e-01 2.0e+02 1.0e+00 3.4e+00 9.2e-01 0.18s
[ Info: 1 1.4e+02 7.3e+01 1.1e-01 4.2e-01 1.0e+00 1 ↘ found approximate minimum least-squares solution
MINRES: system of size 30
k ‖r‖ ‖Aᴴr‖ β cos sin ‖A‖ κ(A) test1 test2 timer
0 7.3e+01 0.0e+00 7.3e+01 -1.0e+00 0.0e+00 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.00s
1 7.2e+01 1.0e+04 1.4e+02 1.9e-01 9.8e-01 1.6e+02 1.0e+00 4.5e+00 8.8e-01 0.00s
[ Info: 2 1.3e+02 7.1e+01 1.0e-01 2.1e-01 1.0e+00 1 ↘ found approximate minimum least-squares solution
MINRES: system of size 30
k ‖r‖ ‖Aᴴr‖ β cos sin ‖A‖ κ(A) test1 test2 timer
0 7.1e+01 0.0e+00 7.1e+01 -1.0e+00 0.0e+00 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.00s
1 7.0e+01 9.3e+03 1.3e+02 2.0e-01 9.8e-01 1.5e+02 1.0e+00 4.3e+00 8.8e-01 0.00s
[ Info: 3 1.3e+02 6.9e+01 1.1e-01 1.0e-01 1.0e+00 1 ↘ found approximate minimum least-squares solution
MINRES: system of size 30
k ‖r‖ ‖Aᴴr‖ β cos sin ‖A‖ κ(A) test1 test2 timer
0 6.9e+01 0.0e+00 6.9e+01 -1.0e+00 0.0e+00 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.00s
1 6.7e+01 1.1e+04 1.5e+02 2.2e-01 9.8e-01 1.7e+02 1.0e+00 4.1e+00 9.2e-01 0.00s
[ Info: 4 1.2e+02 6.6e+01 9.6e-02 5.2e-02 1.0e+00 1 ↘ found approximate minimum least-squares solution
MINRES: system of size 30
k ‖r‖ ‖Aᴴr‖ β cos sin ‖A‖ κ(A) test1 test2 timer
0 6.6e+01 0.0e+00 6.6e+01 -1.0e+00 0.0e+00 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.00s
1 6.4e+01 1.2e+04 1.7e+02 2.4e-01 9.7e-01 1.9e+02 1.0e+00 3.8e+00 9.4e-01 0.00s
[ Info: 5 1.1e+02 6.4e+01 9.0e-02 2.6e-02 1.0e+00 1 ↘ found approximate minimum least-squares solution
MINRES: system of size 30
k ‖r‖ ‖Aᴴr‖ β cos sin ‖A‖ κ(A) test1 test2 timer
0 6.4e+01 0.0e+00 6.4e+01 -1.0e+00 0.0e+00 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.00s
1 6.2e+01 1.3e+04 1.9e+02 2.6e-01 9.7e-01 2.1e+02 1.0e+00 3.6e+00 9.5e-01 0.00s
[ Info: 6 1.1e+02 6.1e+01 8.3e-02 1.3e-02 1.0e+00 1 ↘ found approximate minimum least-squares solution
Subsolver = CR, NPC Handler = AG
[ Info: iter f(x) ‖∇f‖ ‖s‖ σ ρ subiter dir
[ Info: 0 1.5e+02 7.6e+01 0.0e+00 8.4e-01 0.0e+00 0
[ Info: 1 1.0e+02 1.0e+02 1.1e+00 1.3e+00 5.3e-01 2 ↘ nonpositive curvature
[ Info: 2 9.7e+01 1.3e+02 7.4e-01 1.9e+00 2.7e-01 10 ↘ nonpositive curvature
[ Info: 3 7.7e+01 1.7e+01 3.9e-01 9.4e-01 9.9e-01 6 ↘ solution good enough given atol and rtol
[ Info: 4 7.6e+01 2.1e+01 2.3e-01 1.4e+00 7.4e-01 7 ↘ nonpositive curvature
[ Info: 5 7.6e+01 1.9e+01 4.1e-01 2.1e+00 2.4e-01 11 ↘ solution good enough given atol and rtol
[ Info: 6 7.5e+01 3.1e+01 3.1e-01 3.2e+00 4.7e-01 6 ↘ nonpositive curvature
Subsolver = MinresQlp, NPC Handler = AG
[ Info: iter f(x) ‖∇f‖ ‖s‖ σ ρ subiter dir
[ Info: 0 1.5e+02 7.6e+01 0.0e+00 8.4e-01 0.0e+00 0
MINRES-QLP: system of size 30
k ‖rₖ‖ ‖Arₖ₋₁‖ βₖ₊₁ Rₖ.ₖ Lₖ.ₖ ‖A‖ κ(A) backward timer
0 7.6e+01 ✗ ✗ ✗ ✗ 7.6e+01 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ 0.00s
1 7.4e+01 1.4e+04 1.8e+02 1.9e+02 1.9e+02 2.0e+02 1.0e+00 Inf 0.00s
2 7.3e+01 9.3e+03 4.5e+02 4.5e+02 -9.8e+01 9.6e+02 8.6e+00 Inf 0.00s
nonpositive curvature detected: cₖ * λbarₖ = 5.197591e+00
[ Info: 1 1.0e+02 1.0e+02 1.1e+00 1.3e+00 5.3e-01 3 ↘ nonpositive curvature
MINRES-QLP: system of size 30
k ‖rₖ‖ ‖Arₖ₋₁‖ βₖ₊₁ Rₖ.ₖ Lₖ.ₖ ‖A‖ κ(A) backward timer
0 1.0e+02 ✗ ✗ ✗ ✗ 1.0e+02 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ 0.00s
1 6.4e+01 6.9e+04 4.0e+02 6.6e+02 6.6e+02 6.7e+02 1.0e+00 Inf 0.00s
2 4.6e+01 3.7e+04 4.7e+02 6.5e+02 -4.0e+02 1.3e+03 2.7e+00 Inf 0.00s
3 3.9e+01 3.0e+04 6.9e+02 8.2e+02 -3.4e+02 1.8e+03 3.3e+00 2.8e-01 0.00s
4 3.6e+01 1.2e+04 4.6e+02 4.9e+02 -2.0e+02 2.3e+03 5.7e+00 1.3e-01 0.00s
5 3.4e+01 6.8e+03 3.8e+02 4.0e+02 -9.1e+01 2.6e+03 1.2e+01 7.1e-02 0.00s
6 3.1e+01 8.8e+03 4.8e+02 5.3e+02 -5.6e+01 2.8e+03 2.0e+01 4.9e-02 0.00s
7 2.8e+01 9.9e+03 5.1e+02 5.6e+02 -4.4e+01 3.1e+03 2.5e+01 3.8e-02 0.00s
8 2.5e+01 8.3e+03 4.4e+02 5.0e+02 -4.1e+01 3.3e+03 2.7e+01 3.0e-02 0.00s
9 2.4e+01 6.8e+03 4.8e+02 5.0e+02 -4.9e+01 3.4e+03 2.7e+01 2.5e-02 0.00s
10 2.4e+01 3.8e+03 4.6e+02 4.6e+02 -8.2e+01 3.6e+03 2.7e+01 2.1e-02 0.00s
nonpositive curvature detected: cₖ * λbarₖ = 6.161692e+00
[ Info: 2 9.7e+01 1.3e+02 7.4e-01 1.9e+00 2.7e-01 11 ↘ nonpositive curvature
MINRES-QLP: system of size 30
k ‖rₖ‖ ‖Arₖ₋₁‖ βₖ₊₁ Rₖ.ₖ Lₖ.ₖ ‖A‖ κ(A) backward timer
0 1.3e+02 ✗ ✗ ✗ ✗ 1.3e+02 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ 0.00s
1 6.6e+01 8.8e+04 3.6e+02 6.9e+02 6.9e+02 7.0e+02 1.0e+00 Inf 0.00s
2 3.7e+01 4.8e+04 4.3e+02 7.6e+02 -5.0e+02 1.3e+03 2.1e+00 Inf 0.00s
3 2.4e+01 3.2e+04 6.1e+02 9.3e+02 -4.9e+02 1.9e+03 2.2e+00 1.3e-01 0.00s
4 1.8e+01 1.5e+04 5.4e+02 7.2e+02 -3.7e+02 2.3e+03 2.9e+00 4.8e-02 0.00s
5 1.3e+01 8.8e+03 4.2e+02 5.8e+02 -2.3e+02 2.6e+03 4.7e+00 2.2e-02 0.00s
6 8.7e+00 6.1e+03 3.5e+02 5.3e+02 -1.7e+02 2.8e+03 6.2e+00 1.1e-02 0.00s
[ Info: 3 7.7e+01 1.7e+01 3.9e-01 9.4e-01 9.9e-01 6 ↘ solution good enough given atol and rtol
MINRES-QLP: system of size 30
k ‖rₖ‖ ‖Arₖ₋₁‖ βₖ₊₁ Rₖ.ₖ Lₖ.ₖ ‖A‖ κ(A) backward timer
0 1.7e+01 ✗ ✗ ✗ ✗ 1.7e+01 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ 0.00s
1 1.2e+01 1.2e+04 4.8e+02 7.0e+02 7.0e+02 7.0e+02 1.0e+00 Inf 0.00s
2 7.7e+00 6.7e+03 4.3e+02 6.5e+02 -3.4e+02 1.5e+03 3.9e+00 Inf 0.00s
3 5.3e+00 4.4e+03 4.3e+02 6.3e+02 -2.7e+02 1.8e+03 5.0e+00 3.2e-01 0.00s
4 4.1e+00 3.5e+03 6.2e+02 7.9e+02 -2.9e+02 2.2e+03 5.0e+00 9.1e-02 0.00s
5 3.8e+00 1.2e+03 3.9e+02 4.2e+02 -1.9e+02 2.5e+03 7.1e+00 4.9e-02 0.00s
6 3.7e+00 6.1e+02 3.3e+02 3.5e+02 -9.1e+01 2.7e+03 1.5e+01 2.7e-02 0.00s
7 3.7e+00 5.8e+02 5.1e+02 5.2e+02 -9.2e+01 2.8e+03 1.5e+01 2.2e-02 0.00s
nonpositive curvature detected: cₖ * λbarₖ = 2.180380e+00
[ Info: 4 7.6e+01 2.1e+01 2.3e-01 1.4e+00 7.4e-01 8 ↘ nonpositive curvature
MINRES-QLP: system of size 30
k ‖rₖ‖ ‖Arₖ₋₁‖ βₖ₊₁ Rₖ.ₖ Lₖ.ₖ ‖A‖ κ(A) backward timer
0 2.1e+01 ✗ ✗ ✗ ✗ 2.1e+01 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ 0.00s
1 1.4e+01 1.6e+04 4.9e+02 7.7e+02 7.7e+02 7.7e+02 1.0e+00 Inf 0.00s
2 8.6e+00 8.2e+03 4.2e+02 6.6e+02 -3.9e+02 1.5e+03 3.4e+00 Inf 0.00s
3 5.0e+00 5.8e+03 4.2e+02 7.3e+02 -3.1e+02 1.9e+03 4.3e+00 2.2e-01 0.00s
4 3.8e+00 3.7e+03 6.4e+02 8.3e+02 -3.9e+02 2.2e+03 4.3e+00 7.2e-02 0.00s
5 3.6e+00 1.1e+03 3.9e+02 4.2e+02 -2.2e+02 2.5e+03 6.1e+00 3.7e-02 0.00s
6 3.5e+00 4.4e+02 2.9e+02 3.0e+02 -7.8e+01 2.7e+03 1.7e+01 2.2e-02 0.00s
7 3.4e+00 6.4e+02 4.6e+02 4.9e+02 -4.3e+01 2.9e+03 3.1e+01 1.7e-02 0.00s
8 3.2e+00 7.0e+02 4.9e+02 5.1e+02 -3.5e+01 3.1e+03 3.9e+01 1.5e-02 0.00s
9 2.5e+00 8.0e+02 3.1e+02 3.8e+02 -1.6e+01 3.4e+03 8.6e+01 1.1e-02 0.00s
10 1.8e+00 7.6e+02 2.6e+02 3.6e+02 -1.6e+01 3.5e+03 8.6e+01 7.4e-03 0.00s
11 1.1e+00 7.8e+02 3.0e+02 4.8e+02 -2.0e+01 3.6e+03 8.6e+01 4.4e-03 0.00s
[ Info: 5 7.6e+01 1.9e+01 4.1e-01 2.1e+00 2.4e-01 11 ↘ solution good enough given atol and rtol
MINRES-QLP: system of size 30
k ‖rₖ‖ ‖Arₖ₋₁‖ βₖ₊₁ Rₖ.ₖ Lₖ.ₖ ‖A‖ κ(A) backward timer
0 1.9e+01 ✗ ✗ ✗ ✗ 1.9e+01 ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗ 0.0e+00 0.0e+00 ✗ ✗ ✗ ✗ 0.00s
1 1.2e+01 6.0e+03 2.0e+02 3.2e+02 3.2e+02 3.2e+02 1.0e+00 Inf 0.00s
2 8.6e+00 5.9e+03 4.1e+02 5.6e+02 -2.7e+02 8.7e+02 2.5e+00 Inf 0.00s
3 6.5e+00 3.2e+03 3.4e+02 4.4e+02 -1.9e+02 1.3e+03 3.8e+00 2.6e-01 0.00s
4 5.2e+00 3.6e+03 5.6e+02 7.0e+02 -1.8e+02 1.7e+03 3.9e+00 7.5e-02 0.00s
5 5.0e+00 1.8e+03 5.1e+02 5.3e+02 -2.0e+02 2.0e+03 4.3e+00 4.7e-02 0.00s
6 5.0e+00 5.7e+02 3.9e+02 3.9e+02 -1.1e+02 2.3e+03 7.2e+00 3.1e-02 0.00s
nonpositive curvature detected: cₖ * λbarₖ = 1.964178e+00
[ Info: 6 7.5e+01 3.1e+01 3.1e-01 3.2e+00 4.7e-01 7 ↘ nonpositive curvature
```
3 条评论