Skip to content
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

An implementation of DIOM #63

Merged
merged 9 commits into from
Oct 23, 2018
Merged

Conversation

amontoison
Copy link
Member

Little brother of DQGMRES.

Currently, the factorization is H is done without pivoting.
Like DQGMRES, we can avoid the storage of H and I found a way to preconditioned it too.
This algorithm needs 2n + 1 vectors of mem coefficients.

@coveralls
Copy link

coveralls commented Sep 27, 2018

Coverage Status

Coverage increased (+0.02%) to 99.506% when pulling dfa69c7 on Xx-fractale-xX:diom into c221384 on JuliaSmoothOptimizers:master.

@amontoison
Copy link
Member Author

I didn't passed tests on julia 0.7:
ERROR: LoadError: LoadError: UndefVarError: A_mul_B! not defined

I don't understand why, It works on my laptop...
I tested it with include(Krylov.jl") and using Main.Krylov.

@dpo
Copy link
Member

dpo commented Sep 27, 2018

Possibly because this package hasn't yet been upgraded to 0.7 and so doesn't pull the correct version of LinearOperators?! You're probably using a recent enough version on your laptop. First we need to upgrade to 0.7 (in another PR).

@amontoison
Copy link
Member Author

amontoison commented Sep 28, 2018

I found the problem, @abel renamed the function A_mul_B! by mul! with the version 5.0 of LinearOperators.
A_mul_B! is used to preallocated LinearOperators in variants.jl.
If we want that tests passed on julia 0.7, we need to phase out julia 0.6 and modify variants.jl.

@codecov-io
Copy link

codecov-io commented Sep 28, 2018

Codecov Report

Merging #63 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     JuliaLang/julia#63      +/-   ##
=========================================
+ Coverage   99.48%   99.5%   +0.02%     
=========================================
  Files          19      20       +1     
  Lines        1542    1619      +77     
=========================================
+ Hits         1534    1611      +77     
  Misses          8       8
Impacted Files Coverage Δ
src/variants.jl 100% <ø> (ø) ⬆️
src/Krylov.jl 100% <ø> (ø) ⬆️
src/diom.jl 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c221384...dfa69c7. Read the comment docs.

@abelsiqueira
Copy link
Member

A_mul_B and similar were removed from 1.0 link and mul! with dispatch is the new way to handle it. LinearOperators v0.4.1 still uses A_mul_B and will only work on 0.6/0.7.
There should be a last release limiting LinearOperators on REQUIRE, then dropping 0.6.

@amontoison
Copy link
Member Author

Thanks @abel !
I limited LinearOperators 0.4.1 in the REQUIRE with a previous commit but during the continous integration it's still LinearOperators 0.5.0 that is installed on Julia 0.7.

@abelsiqueira abelsiqueira reopened this Oct 3, 2018
@amontoison
Copy link
Member Author

LU factorization with partial pivoting don't break if H is singular. Furthermore the process is more stable, the biggest pivot is chosen at each step.

I'm quite sure that this version was never implemented. In the article Practical use of some Krylov subspace methods for solving indefinite and nonsymmetric linear systems, Youcef Saad talked about this variant but he made a mistake (from my point of view) in the update of x. I finally found an other way to do it which seems correct for me.

@@ -0,0 +1,71 @@
include("get_div_grad.jl")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DIOM and DQGMRES should really be tested on unsymmetric systems as well.

@amontoison
Copy link
Member Author

I also updated the reference of the article Practical use of some krylov subspace methods for solving indefinite and nonsymmetric linear systems.

src/diom.jl Outdated

"""Solve the consistent linear system Ax = b using direct incomplete orthogonalization method.

DIOM is similar to SYMMLQ for nonsymmetric problems.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is accurate. FOM is to the Arnoldi process as CG is to the Lanczos process. I think it would be more accurate to say that DIOM is similar to CG with partial reorthogonalization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will rewrite the docString.

src/diom.jl Outdated
It's a more economical algorithm based upon the LU factorization with partial pivoting.

In the particular case where A is symmetric indefinite, DIOM is theorecally equivalent
to SYMMLQ but slightly more economical.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is true either; DIOM and SYMMLQ do not minimize the same quantities.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's not norm(x) that is minimized. I think we could delete this sentence?

next_pos = mod(iter, mem) + 1 # Position corresponding to vₘ₊₁ in the circular stack V.

# Incomplete Arnoldi procedure.
z = M * V[:,pos] # Forms pₘ
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why Github isn't rendering UTF-8 characters correctly. Is your editor set to use UTF-8 encoding?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my editor is set to use UTF-8 encoding. Github is rendering UTF-8 correctly for me, maybe it's your web browser?
encodage

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both Safari and Chrome seem to be missing characters...

@dpo
Copy link
Member

dpo commented Oct 19, 2018

Great, thank you!

src/diom.jl Outdated
# m-i+2 represents the indice of the diagonal where hᵢ.ₘ is located.
# In addition of that, the last column of Uₘ is stored in H.
L = zeros(mem) # Last mem Pivots of Lₘ.
p = zeros(Bool, mem) # Last mem permutations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe p could be a BitArray?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I didn't know that a Bool was an Uint8 in Julia and not a single bit.

end
# Compute hₘ₊₁.ₘ and vₘ₊₁.
H[1] = @knrm2(n, w) # hₘ₊₁.ₘ = ‖vₘ₊₁‖
if H[1] ≉ 0 # hₘ₊₁.ₘ ≈ 0 ⇒ "lucky breakdown"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a tolerance involved in ? In my experience, we want to test for != 0.

Copy link
Member Author

@amontoison amontoison Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is a tolerance involved in , x ≈ y return true if norm(x-y) ≤ rtol * max(|x|,|y|). With rtol that depend of the type of x and y. It's sqrt(eps) with eps the precision machine of Float16, Float32, Float64....

But when we do x ≈ 0, It's mean that |x| ≤ rtol * |x| ↔ x = 0. I used this notation because I find it nicer than ==. Also I like this notation because it means that x is a zero for the computer in the working precision but it's possible that it's not a zero in another precision or in exact arithmetic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

@dpo dpo merged commit 075b1c6 into JuliaSmoothOptimizers:master Oct 23, 2018
@dpo
Copy link
Member

dpo commented Oct 23, 2018

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants