-
Notifications
You must be signed in to change notification settings - Fork 10
TRDH algorithm #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TRDH algorithm #91
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #91 +/- ##
==========================================
+ Coverage 53.04% 57.47% +4.42%
==========================================
Files 10 11 +1
Lines 1001 1204 +203
==========================================
+ Hits 531 692 +161
- Misses 470 512 +42
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
Here are the |
|
Here are the |
|
I had luck with the following changes (sorry, some are simply formatting changes by the linter; I'm pasting them in a hurry): diff --git a/benchmarks/tables/bpdn-constr-table.jl b/benchmarks/tables/bpdn-constr-table.jl
index 65e72a3..7f2b9a9 100644
--- a/benchmarks/tables/bpdn-constr-table.jl
+++ b/benchmarks/tables/bpdn-constr-table.jl
@@ -3,24 +3,24 @@ include("regulopt-tables.jl")
# model
Random.seed!(1234)
compound = 1
-model, nls_model, sol = bpdn_model(compound, bounds = true)
+model, nls_model, sol = bpdn_model(compound, bounds=true)
f = LSR1Model(model)
λ = norm(grad(model, zeros(model.meta.nvar)), Inf) / 10
h = NormL1(λ)
verbose = 0 # 10
-options = ROSolverOptions(ν = 1.0, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = true)
-options2 = ROSolverOptions(spectral = false, psb = true, ϵa = 1e-6, ϵr = 1e-6, maxIter=20)
-options3 = ROSolverOptions(spectral = false, psb = false, ϵa = 1e-6, ϵr = 1e-6, maxIter=20)
-options4 = ROSolverOptions(spectral = true, ϵa = 1e-6, ϵr = 1e-6, maxIter=20)
-options5 = ROSolverOptions(ν = 1.0, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = false, psb = true)
-options6 = ROSolverOptions(ν = 1.0, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = false, psb = false)
-options7 = ROSolverOptions(spectral = false, psb = true, ϵa = 1e-6, ϵr = 1e-6, maxIter=20, reduce_TR = false)
+options = ROSolverOptions(ν=1.0, β=1e16, ϵa=1e-6, ϵr=1e-6, verbose=verbose, maxIter=500, spectral=true)
+options2 = ROSolverOptions(spectral=false, psb=true, ϵa=1e-6, ϵr=1e-6, maxIter=20)
+options3 = ROSolverOptions(spectral=false, psb=false, ϵa=1e-6, ϵr=1e-6, maxIter=20)
+options4 = ROSolverOptions(spectral=true, ϵa=1e-6, ϵr=1e-6, maxIter=20)
+options5 = ROSolverOptions(ν=1.0, β=1e16, ϵa=1e-6, ϵr=1e-6, verbose=verbose, maxIter=500, spectral=false, psb=true)
+options6 = ROSolverOptions(ν=1.0, β=1e16, ϵa=1e-6, ϵr=1e-6, verbose=verbose, maxIter=500, spectral=false, psb=false)
+options7 = ROSolverOptions(spectral=false, psb=true, ϵa=1e-6, ϵr=1e-6, maxIter=20, reduce_TR=false)
solvers = [:R2, :TRDH, :TRDH, :TRDH, :TR, :TR, :TR, :TR, :TR]
subsolvers = [:None, :None, :None, :None, :R2, :TRDH, :TRDH, :TRDH, :TRDH]
solver_options = [options, options, options5, options6, options, options, options, options, options]
subsolver_options = [options2, options2, options2, options2, options2, options7, options2, options3, options4] # n'importe lequel si subsolver = :None
-benchmark_table(f, 1:f.meta.nvar, sol, h, λ, solvers, subsolvers, solver_options, subsolver_options, "BPDN-cstr")
\ No newline at end of file
+benchmark_table(f, 1:f.meta.nvar, sol, h, λ, solvers, subsolvers, solver_options, subsolver_options, "BPDN-cstr")
diff --git a/benchmarks/tables/bpdn-table.jl b/benchmarks/tables/bpdn-table.jl
index 644567a..fc0fbf3 100644
--- a/benchmarks/tables/bpdn-table.jl
+++ b/benchmarks/tables/bpdn-table.jl
@@ -6,7 +6,7 @@ compound = 1
model, nls_model, sol = bpdn_model(compound, bounds = false)
# parameters
-f = LSR1Model(model)
+f = LBFGSModel(model)
λ = norm(grad(model, zeros(model.meta.nvar)), Inf) / 10
h = NormL1(λ)
@@ -25,4 +25,4 @@ subsolvers = [:None, :None, :None, :None, :R2, :TRDH, :TRDH, :TRDH, :TRDH, :TRDH
solver_options = [options, options, options5, options6, options, options, options, options, options, options]
subsolver_options = [options2, options2, options2, options2, options2, options7, options2, options3, options4, options8] # n'importe lequel si subsolver = :None
-benchmark_table(f, 1:f.meta.nvar, sol, h, λ, solvers, subsolvers, solver_options, subsolver_options, "BPDN")
\ No newline at end of file
+benchmark_table(f, 1:f.meta.nvar, sol, h, λ, solvers, subsolvers, solver_options, subsolver_options, "BPDN")
diff --git a/benchmarks/tables/fh-table.jl b/benchmarks/tables/fh-table.jl
index 3421610..02bc409 100644
--- a/benchmarks/tables/fh-table.jl
+++ b/benchmarks/tables/fh-table.jl
@@ -10,15 +10,16 @@ f = LBFGSModel(model)
h = NormL0(λ)
ν = 1.0e2
verbose = 0 #10
-maxIter_sub = 200
-options = ROSolverOptions(ν = ν, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = true)
-options2 = ROSolverOptions(spectral = false, psb = true, ϵa = 1e-6, ϵr = 1e-6, maxIter = maxIter_sub)
-options3 = ROSolverOptions(spectral = false, psb = false, ϵa = 1e-6, ϵr = 1e-6, maxIter = maxIter_sub)
-options4 = ROSolverOptions(spectral = true, ϵa = 1e-6, ϵr = 1e-6, maxIter = maxIter_sub)
-options5 = ROSolverOptions(ν = ν, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = false, psb = true)
-options6 = ROSolverOptions(ν = ν, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = false, psb = false)
-options7 = ROSolverOptions(spectral = false, psb = true, reduce_TR = false, ϵa = 1e-6, ϵr = 1e-6, maxIter = maxIter_sub)
-options8 = ROSolverOptions(ν = ν, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = false, psb = false, reduce_TR = false)
+maxIter_sub = 10_000
+ϵ = 1.0e-3
+options = ROSolverOptions(ν=ν, β=1e16, ϵa=ϵ, ϵr=ϵ, verbose=verbose, maxIter=maxIter_sub, spectral=true)
+options2 = ROSolverOptions(spectral=false, psb=true, ϵa=ϵ, ϵr=ϵ, maxIter=maxIter_sub)
+options3 = ROSolverOptions(spectral=false, psb=false, ϵa=ϵ, ϵr=ϵ, maxIter=maxIter_sub)
+options4 = ROSolverOptions(spectral=true, ϵa=ϵ, ϵr=ϵ, maxIter=maxIter_sub)
+options5 = ROSolverOptions(ν=ν, β=1e16, ϵa=ϵ, ϵr=ϵ, verbose=verbose, maxIter=500, spectral=false, psb=true)
+options6 = ROSolverOptions(ν=ν, β=1e16, ϵa=ϵ, ϵr=ϵ, verbose=verbose, maxIter=500, spectral=false, psb=false)
+options7 = ROSolverOptions(spectral=false, psb=true, reduce_TR=false, ϵa=ϵ, ϵr=ϵ, maxIter=maxIter_sub)
+options8 = ROSolverOptions(ν=ν, β=1e16, ϵa=ϵ, ϵr=ϵ, verbose=verbose, maxIter=500, spectral=false, psb=false, reduce_TR=false)
solvers = [:R2, :TRDH, :TRDH, :TRDH, :TRDH, :TR, :TR, :TR, :TR, :TR]
subsolvers = [:None, :None, :None, :None, :None, :R2, :TRDH, :TRDH, :TRDH, :TRDH]
@@ -27,4 +28,4 @@ subsolver_options = [options2, options2, options2, options2, options2, options2,
subset = 2:10 # issues with R2 alone
benchmark_table(f, 1:f.meta.nvar, [], h, λ, solvers[subset], subsolvers[subset], solver_options[subset], subsolver_options[subset],
- "FH with ν = $ν, λ = $λ")
\ No newline at end of file
+ "FH with ν = $ν, λ = $λ")
diff --git a/benchmarks/tables/nnmf-table.jl b/benchmarks/tables/nnmf-table.jl
index 9a08ec9..f0ee7ab 100644
--- a/benchmarks/tables/nnmf-table.jl
+++ b/benchmarks/tables/nnmf-table.jl
@@ -2,20 +2,24 @@ include("regulopt-tables.jl")
Random.seed!(1234)
m, n, k = 100, 50, 5
+
model, A, selected = nnmf_model(m, n, k)
f = LSR1Model(model)
-λ = norm(grad(model, rand(model.meta.nvar)), Inf) / 1000
+# λ = norm(grad(model, rand(model.meta.nvar)), Inf) / 1000
+λ = norm(grad(model, rand(model.meta.nvar)), Inf) / 10
h = NormL0(λ)
ν = 1.0
verbose = 0 #10
-options = ROSolverOptions(ν = ν, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = true)
-options2 = ROSolverOptions(spectral = false, psb = true, ϵa = 1e-6, ϵr = 1e-6, maxIter=40)
-options3 = ROSolverOptions(spectral = false, psb = false, ϵa = 1e-6, ϵr = 1e-6, maxIter=40)
-options4 = ROSolverOptions(spectral = true, ϵa = 1e-6, ϵr = 1e-6, maxIter=40)
-options5 = ROSolverOptions(ν = ν, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = false, psb = true)
-options6 = ROSolverOptions(ν = ν, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = false, psb = false)
-options7 = ROSolverOptions(spectral = false, psb = true, reduce_TR = false, ϵa = 1e-6, ϵr = 1e-6, maxIter=40)
-options8 = ROSolverOptions(ν = ν, β = 1e16, ϵa = 1e-6, ϵr = 1e-6, verbose = verbose, maxIter = 500, spectral = false, psb = false, reduce_TR = false)
+
+ϵ = 1e-3
+options = ROSolverOptions(ν=ν, β=1e16, ϵa=ϵ, ϵr=ϵ, verbose=verbose, maxIter=500, spectral=true)
+options2 = ROSolverOptions(spectral=false, psb=true, ϵa=ϵ, ϵr=ϵ, maxIter=40)
+options3 = ROSolverOptions(spectral=false, psb=false, ϵa=ϵ, ϵr=ϵ, maxIter=40)
+options4 = ROSolverOptions(spectral=true, ϵa=ϵ, ϵr=ϵ, maxIter=40)
+options5 = ROSolverOptions(ν=ν, β=1e16, ϵa=ϵ, ϵr=ϵ, verbose=verbose, maxIter=500, spectral=false, psb=true)
+options6 = ROSolverOptions(ν=ν, β=1e16, ϵa=ϵ, ϵr=ϵ, verbose=verbose, maxIter=500, spectral=false, psb=false)
+options7 = ROSolverOptions(spectral=false, psb=true, reduce_TR=false, ϵa=ϵ, ϵr=ϵ, maxIter=40)
+options8 = ROSolverOptions(ν=ν, β=1e16, ϵa=ϵ, ϵr=ϵ, verbose=verbose, maxIter=500, spectral=false, psb=false, reduce_TR=false)
solvers = [:R2, :TRDH, :TRDH, :TRDH, :TRDH, :TR, :TR, :TR, :TR, :TR, :TR]
subsolvers = [:None, :None, :None, :None, :None, :R2, :TRDH, :TRDH, :TRDH, :TRDH, :TRDH]
@@ -23,4 +27,4 @@ solver_options = [options, options, options5, options6, options8, options, optio
subsolver_options = [options2, options2, options2, options2, options2, options2, options7, options2, options3, options4]
benchmark_table(f, selected, [], h, λ, solvers, subsolvers, solver_options, subsolver_options,
- "NNMF with m = $m, n = $n, k = $k, ν = $ν, λ = $λ")
\ No newline at end of file
+ "NNMF with m = $m, n = $n, k = $k, ν = $ν, λ = $λ")
diff --git a/src/TRDH_alg.jl b/src/TRDH_alg.jl
index 8e2fbce..126d3f3 100644
--- a/src/TRDH_alg.jl
+++ b/src/TRDH_alg.jl
@@ -44,7 +44,13 @@ The Hessian is accessed as an abstract operator and need not be the exact Hessia
* `Hobj_hist`: an array with the history of values of the nonsmooth objective
* `Complex_hist`: an array with the history of number of inner iterations.
"""
-function TRDH(nlp::AbstractNLPModel{R}, h, χ, options::ROSolverOptions{R}; kwargs...) where {R <: Real}
+function TRDH(
+ nlp::AbstractNLPModel{R},
+ h,
+ χ,
+ options::ROSolverOptions{R};
+ kwargs...,
+) where {R <: Real}
kwargs_dict = Dict(kwargs...)
x0 = pop!(kwargs_dict, :x0, nlp.meta.x0)
xk, k, outdict = TRDH(
@@ -317,6 +323,8 @@ function TRDH(
tired = k ≥ maxIter || elapsed_time > maxTime
end
+ !reduce_TR && (ξ1 = ξ) # for output dict
+
if verbose > 0
if k == 1
@info @sprintf "%6d %8s %8.1e %8.1e" k "" fk hk
@@ -328,8 +336,6 @@ function TRDH(
end
end
- !reduce_TR && (ξ1 = ξ) # for output dict
-
status = if optimal
:first_order
elseif elapsed_time > maxTime |
|
I don't have the same "good" results with these parameters. Did you try with the changes of |
|
Oh the PR for the release 2.5.2 of LinearOperators has not been merged yet. I'll launch the tests again once it is merged. |
|
Here are the |
|
No, it was before the updates to LinearOperators |
| end | ||
| end | ||
|
|
||
| !reduce_TR && (ξ1 = ξ) # for output dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this above line 320. Otherwise, there's an error when reduceTR = false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. When reduce_TR = false , ξ1 is not defined, and the stopping criterion is based on the ξ value, but I need to return ξ1 in the ouput dict L353. I did not experience any error when testing with reduceTR = false.
Or are you referring to something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When reduce_TR = false , ξ1 is not defined
Exactly. So there is an error because you try to print ξ1 on line 328.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok I see you're right. I actually forgot to change the last verbose instruction if reduce_TR = false, this is now fixed.
|
Here are the |
|
Here are the |
dpo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, thank you.
@dpo so that you can try the algorithm. I added the code to do the benchmark tables, you just have to run for example
bpdn-table.jl.I suggest you play with the$\lambda$ and $\nu$ values to see the beheviour of the solvers when these parameters are changed.
You can also change the Quasi-Newton model type and the norm used for the proximal operator.
I made the changes with the$\xi$ instead of $\xi_1$ ).
reduce_TRoption (iffalse, the optimality criterion is based upon