Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/LMTR_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ function LMTR(
Fobj_hist = zeros(maxIter)
Hobj_hist = zeros(maxIter)
Complex_hist = zeros(Int, maxIter)
Grad_hist = zeros(Int, maxIter)
Resid_hist = zeros(Int, maxIter)

if verbose > 0
#! format: off
@info @sprintf "%6s %8s %8s %8s %7s %7s %8s %7s %7s %7s %7s %1s" "outer" "inner" "f(x)" "h(x)" "√ξ1" "√ξ" "ρ" "Δ" "‖x‖" "‖s‖" "1/ν" "TR"
Expand Down Expand Up @@ -140,6 +143,8 @@ function LMTR(
elapsed_time = time() - start_time
Fobj_hist[k] = fk
Hobj_hist[k] = hk
Grad_hist[k] = nls.counters.neval_jtprod_residual + nls.counters.neval_jprod_residual
Resid_hist[k] = nls.counters.neval_residual

# model for first prox-gradient iteration
φ1(d) = begin
Expand Down Expand Up @@ -292,5 +297,7 @@ function LMTR(
set_solver_specific!(stats, :Hhist, Hobj_hist[1:k])
set_solver_specific!(stats, :NonSmooth, h)
set_solver_specific!(stats, :SubsolverCounter, Complex_hist[1:k])
set_solver_specific!(stats, :NLSGradHist, Grad_hist[1:k])
set_solver_specific!(stats, :ResidHist, Resid_hist[1:k])
return stats
end
7 changes: 7 additions & 0 deletions src/LM_alg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ function LM(
Fobj_hist = zeros(maxIter)
Hobj_hist = zeros(maxIter)
Complex_hist = zeros(Int, maxIter)
Grad_hist = zeros(Int, maxIter)
Resid_hist = zeros(Int, maxIter)

if verbose > 0
#! format: off
@info @sprintf "%6s %8s %8s %8s %7s %7s %8s %7s %7s %7s %7s %1s" "outer" "inner" "f(x)" "h(x)" "√ξ1" "√ξ" "ρ" "σ" "‖x‖" "‖s‖" "‖Jₖ‖²" "reg"
Expand Down Expand Up @@ -133,6 +136,8 @@ function LM(
elapsed_time = time() - start_time
Fobj_hist[k] = fk
Hobj_hist[k] = hk
Grad_hist[k] = nls.counters.neval_jtprod_residual + nls.counters.neval_jprod_residual
Resid_hist[k] = nls.counters.neval_residual

# model for first prox-gradient iteration
φ1(d) = begin
Expand Down Expand Up @@ -281,5 +286,7 @@ function LM(
set_solver_specific!(stats, :Hhist, Hobj_hist[1:k])
set_solver_specific!(stats, :NonSmooth, h)
set_solver_specific!(stats, :SubsolverCounter, Complex_hist[1:k])
set_solver_specific!(stats, :NLSGradHist, Grad_hist[1:k])
set_solver_specific!(stats, :ResidHist, Resid_hist[1:k])
return stats
end
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ for (h, h_name) ∈ ((NormL0(λ), "l0"), (NormL1(λ), "l1"), (IndBallL0(10 * com
@test typeof(out.dual_feas) == eltype(out.solution)
@test length(out.solver_specific[:Fhist]) == length(out.solver_specific[:Hhist])
@test length(out.solver_specific[:Fhist]) == length(out.solver_specific[:SubsolverCounter])
@test length(out.solver_specific[:Fhist]) == length(out.solver_specific[:NLSGradHist])
@test out.solver_specific[:NLSGradHist][end] == bpdn_nls.counters.neval_jprod_residual + bpdn_nls.counters.neval_jtprod_residual - 1
@test obj(bpdn_nls, out.solution) == out.solver_specific[:Fhist][end]
@test h(out.solution) == out.solver_specific[:Hhist][end]
@test out.status == :first_order
Expand All @@ -106,6 +108,8 @@ for (h, h_name) ∈ ((NormL1(λ), "l1"),)
@test length(LMTR_out.solver_specific[:Fhist]) == length(LMTR_out.solver_specific[:Hhist])
@test length(LMTR_out.solver_specific[:Fhist]) ==
length(LMTR_out.solver_specific[:SubsolverCounter])
@test length(LMTR_out.solver_specific[:Fhist]) == length(LMTR_out.solver_specific[:NLSGradHist])
@test LMTR_out.solver_specific[:NLSGradHist][end] == bpdn_nls.counters.neval_jprod_residual + bpdn_nls.counters.neval_jtprod_residual - 1
@test obj(bpdn_nls, LMTR_out.solution) == LMTR_out.solver_specific[:Fhist][end]
@test h(LMTR_out.solution) == LMTR_out.solver_specific[:Hhist][end]
@test LMTR_out.status == :first_order
Expand Down