Skip to content

Commit b20b029

Browse files
update SolverCore compat and add step_status
1 parent 9b65b29 commit b20b029

9 files changed

Lines changed: 21 additions & 1 deletion

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Percival = "0.7.2"
3535
ProximalOperators = "0.15"
3636
RegularizedProblems = "0.1.3"
3737
ShiftedProximalOperators = "0.2"
38-
SolverCore = "0.3.0"
38+
SolverCore = "0.3.10"
3939
julia = "^1.6.0"
4040

4141
[extras]

src/LMTR_alg.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ function SolverCore.solve!(
418418

419419
σmax, found_σ = opnorm(solver.subpb.model.J)
420420
found_σ || error("operator norm computation failed")
421+
set_step_status!(stats, :accepted)
421422
end
422423

423424
if η2 ρk < Inf
@@ -438,6 +439,7 @@ function SolverCore.solve!(
438439
set_radius!(solver.subsolver.ψ, Δk)
439440
set_radius!(ψ, Δk)
440441
end
442+
set_step_status!(stats, :rejected)
441443
end
442444

443445
set_objective!(stats, fk + hk)

src/LM_alg.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ function SolverCore.solve!(
416416
σmax, found_σ = opnorm(solver.subpb.model.J)
417417
found_σ || error("operator norm computation failed")
418418
end
419+
set_step_status!(stats, :accepted)
419420
end
420421

421422
if η2 ρk < Inf
@@ -424,6 +425,7 @@ function SolverCore.solve!(
424425

425426
if ρk < η1 || ρk == Inf
426427
σk = σk * γ
428+
set_step_status!(stats, :rejected)
427429
end
428430

429431
m_monotone > 1 && (m_fh_hist[stats.iter % (m_monotone - 1) + 1] = fk + hk)

src/R2DH.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ function SolverCore.solve!(
408408
@. ∇fk⁻ = ∇fk - ∇fk⁻
409409
push!(D, s, ∇fk⁻) # update QN operator
410410
∇fk⁻ .= ∇fk
411+
set_step_status!(stats, :accepted)
411412
end
412413

413414
if η2 ρk < Inf
@@ -416,6 +417,7 @@ function SolverCore.solve!(
416417

417418
if ρk < η1 || ρk == Inf
418419
σk = σk * γ
420+
set_step_status!(stats, :rejected)
419421
end
420422

421423
set_objective!(stats, fk + hk)

src/R2N.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ function SolverCore.solve!(
463463
λmax = power_method!(solver.subpb.model.B, solver.v0, solver.subpb.model.v, opnorm_maxiter)
464464
end
465465
found_λ || error("operator norm computation failed")
466+
set_step_status!(stats, :accepted)
466467
end
467468

468469
if η2 ρk < Inf
@@ -471,6 +472,7 @@ function SolverCore.solve!(
471472

472473
if ρk < η1 || ρk == Inf
473474
σk = σk * γ
475+
set_step_status!(stats, :rejected)
474476
end
475477

476478
ν₁ = θ / (λmax + σk)

src/R2_alg.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,15 @@ function SolverCore.solve!(
473473
hk = hkn
474474
grad!(nlp, xk, ∇fk)
475475
shift!(ψ, xk)
476+
set_step_status!(stats, :accepted)
476477
end
477478

478479
if η2 ρk < Inf
479480
σk = max(σk / γ, σmin)
480481
end
481482
if ρk < η1 || ρk == Inf
482483
σk = σk * γ
484+
set_step_status!(stats, :rejected)
483485
end
484486

485487
ν = 1 / σk

src/TRDH_alg.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ function SolverCore.solve!(
459459
dk .= D.d
460460
DNorm = norm(D.d, Inf)
461461
∇fk⁻ .= ∇fk
462+
set_step_status!(stats, :accepted)
462463
end
463464

464465
if η2 ρk < Inf
@@ -474,6 +475,7 @@ function SolverCore.solve!(
474475
else
475476
set_radius!(ψ, Δk)
476477
end
478+
set_step_status!(stats, :rejected)
477479
end
478480

479481
set_objective!(stats, fk + hk)

src/TR_alg.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ function SolverCore.solve!(
475475
found_λ || error("operator norm computation failed")
476476

477477
∇fk⁻ .= ∇fk
478+
set_step_status!(stats, :accepted)
478479
end
479480

480481
if ρk < η1 || ρk == Inf
@@ -487,6 +488,7 @@ function SolverCore.solve!(
487488
set_radius!(ψ, Δk)
488489
set_radius!(solver.subsolver.ψ, Δk)
489490
end
491+
set_step_status!(stats, :rejected)
490492
end
491493

492494
m_monotone > 1 && (m_fh_hist[stats.iter % (m_monotone - 1) + 1] = fk + hk)

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ for (mod, mod_name) ∈ ((x -> x, "exact"), (LSR1Model, "lsr1"), (LBFGSModel, "l
3737
@test length(out.solution) == bpdn.meta.nvar
3838
@test typeof(out.dual_feas) == eltype(out.solution)
3939
@test out.status == :first_order
40+
@test out.step_status == (out.iter > 0 ? :accepted : :unknown)
4041
end
4142
end
4243
end
@@ -55,6 +56,7 @@ for (mod, mod_name) ∈ ((SpectralGradientModel, "spg"),)
5556
@test length(out.solution) == bpdn.meta.nvar
5657
@test typeof(out.dual_feas) == eltype(out.solution)
5758
@test out.status == :first_order
59+
@test out.step_status == (out.iter > 0 ? :accepted : :unknown)
5860
end
5961
end
6062
end
@@ -71,6 +73,7 @@ for (mod, mod_name) ∈ ((LSR1Model, "lsr1"), (LBFGSModel, "lbfgs"))
7173
@test length(TR_out.solution) == bpdn.meta.nvar
7274
@test typeof(TR_out.dual_feas) == eltype(TR_out.solution)
7375
@test TR_out.status == :first_order
76+
@test TR_out.step_status == (TR_out.iter > 0 ? :accepted : :unknown)
7477
end
7578
end
7679
end
@@ -90,6 +93,7 @@ for (h, h_name) ∈ ((NormL0(λ), "l0"), (NormL1(λ), "l1"), (IndBallL0(10 * com
9093
@test length(out.solution) == bpdn.meta.nvar
9194
@test typeof(out.dual_feas) == eltype(out.solution)
9295
@test out.status == :first_order
96+
@test out.step_status == (out.iter > 0 ? :accepted : :unknown)
9397
end
9498
end
9599
end
@@ -105,6 +109,7 @@ for (h, h_name) ∈ ((NormL1(λ), "l1"),)
105109
@test length(LMTR_out.solution) == bpdn.meta.nvar
106110
@test typeof(LMTR_out.dual_feas) == eltype(LMTR_out.solution)
107111
@test LMTR_out.status == :first_order
112+
@test LMTR_out.step_status == (LMTR_out.iter > 0 ? :accepted : :unknown)
108113
end
109114
end
110115

@@ -129,6 +134,7 @@ for (mod, mod_name) ∈ (
129134
@test length(out.solution) == bpdn.meta.nvar
130135
@test typeof(out.dual_feas) == eltype(out.solution)
131136
@test out.status == :first_order
137+
@test out.step_status == (out.iter > 0 ? :accepted : :unknown)
132138
end
133139
end
134140
end

0 commit comments

Comments
 (0)