-
Notifications
You must be signed in to change notification settings - Fork 11
Use operator norm upper bound in solvers #275
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
Open
MaxenceGollier
wants to merge
10
commits into
JuliaSmoothOptimizers:master
Choose a base branch
from
MaxenceGollier:opnorm
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b7a07b1
add opnorm_upper_bound function
MaxenceGollier 429d036
add opnorm_upper_bound in TR and R2N and add !isnan tests for norm me…
MaxenceGollier 4732ee7
add tests
MaxenceGollier 8871987
add matrix and arpack tests
MaxenceGollier f385d85
simplify condition for arpack
MaxenceGollier 18bf6c1
use linearOperators 2.12 and new op_upper_bound feature for SR1 and B…
MaxenceGollier 7c296aa
Update LinearOperators version to 2.13.0
MaxenceGollier 06e102c
Apply suggestions from code review
MaxenceGollier 1c31211
add opnorm_upper_bound for TR
MaxenceGollier 2c293d3
Merge branch 'JuliaSmoothOptimizers:master' into opnorm
MaxenceGollier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| function test_opnorm_upper_bound(B, m, n) | ||
| T = eltype(B) | ||
| is_upper_bound = true | ||
| for _ = 1:m | ||
| upper_bound, found = RegularizedOptimization.opnorm_upper_bound(B) | ||
| if opnorm(Matrix(B)) > upper_bound || !found | ||
| is_upper_bound = false | ||
| break | ||
| end | ||
|
|
||
| push!(B, randn(T, n), randn(T, n)) | ||
| end | ||
|
|
||
| nallocs = @allocated RegularizedOptimization.opnorm_upper_bound(B) | ||
| @test nallocs == 0 | ||
| @test is_upper_bound == true | ||
| end | ||
|
|
||
| # Test norm functions | ||
|
|
||
| @testset "Test opnorm upper bound functions" begin | ||
| n = 10 | ||
| m = 40 | ||
| @testset "LBFGS" begin | ||
| B = LBFGSOperator(Float64, n, scaling = false) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = LBFGSOperator(Float64, n, scaling = true) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = LBFGSOperator(Float32, n, scaling = false) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = LBFGSOperator(Float32, n, scaling = true) | ||
| test_opnorm_upper_bound(B, m, n) | ||
| end | ||
|
|
||
| @testset "LSR1" begin | ||
| B = LSR1Operator(Float64, n, scaling = false) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = LSR1Operator(Float64, n, scaling = true) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = LSR1Operator(Float32, n, scaling = false) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = LSR1Operator(Float32, n, scaling = true) | ||
| test_opnorm_upper_bound(B, m, n) | ||
| end | ||
|
|
||
| @testset "Diagonal" begin | ||
| B = SpectralGradient(randn(Float64), n) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = SpectralGradient(randn(Float32), n) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = DiagonalPSB(randn(Float64, n)) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = DiagonalPSB(randn(Float32, n)) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = DiagonalAndrei(randn(Float64, n)) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
|
||
| B = DiagonalAndrei(randn(Float32, n)) | ||
| test_opnorm_upper_bound(B, m, n) | ||
|
MaxenceGollier marked this conversation as resolved.
|
||
| end | ||
|
|
||
| @testset "Matrix" begin | ||
| is_upper_bound = true | ||
| for _ = 1:m | ||
| B = randn(n, n) | ||
| upper_bound, found = RegularizedOptimization.opnorm_upper_bound(B) | ||
| if opnorm(Matrix(B)) > upper_bound || !found | ||
|
MaxenceGollier marked this conversation as resolved.
|
||
| is_upper_bound = false | ||
| break | ||
| end | ||
| end | ||
|
|
||
| @test is_upper_bound == true | ||
| end | ||
|
|
||
| @testset "Arpack" begin | ||
| is_upper_bound = true | ||
| for _ = 1:m | ||
| B = randn(n, n) | ||
| B = LinearOperator((B + B')/2, symmetric = true) | ||
| upper_bound, found = RegularizedOptimization.opnorm_upper_bound(B) | ||
|
|
||
| if opnorm(Matrix(B)) > upper_bound + 1e-12 || !found | ||
| is_upper_bound = false | ||
| break | ||
| end | ||
| end | ||
| @test is_upper_bound == true | ||
| end | ||
| end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.