JuliaLinearAlgebra / ArnoldiMethod.jl

The Arnoldi Method with Krylov-Schur restart, natively in Julia.

Home Page:https://julialinearalgebra.github.io/ArnoldiMethod.jl/dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Allow an initial start-vector

simonschoelly opened this issue · comments

Right now, the initial vector for the iteration seems to be chosen at random. I think Arpack had the option to select an initial vector. This would allow two things:

  1. If one had an idea what the end result should look like, they could give this as an initial vector which would lead to fewer iterations.
  2. Determinism in regression tests. For example GraphPlots.jl compares the output image with previously generated images. Right now, it does not do that for spectral graph layouts and without an initial starting value, the output might look slightly different every time.

Yes, that seems very reasonable, will add it soon!

Two options or combinations thereof as I see it:

  1. add initial vector as arg to partialschur():
function _partialschur(A, ::Type{T}, mindim::Int, maxdim::Int, nev::Int, tol::Ttol, restarts::Int, which::Target, history_level::Type{Thist},v0::AbstractVector{T}=randn(n)) where {T,Ttol<:Real,Thist<:History}
  1. add initial Arnoldi-object as kwarg/arg to partialschur(). Starting with a given vector would require the creation of an Arnoldi-object.
function _partialschur(A, ::Type{T}, mindim::Int, maxdim::Int, nev::Int, tol::Ttol, restarts::Int, which::Target, history_level::Type{Thist},A0::Arnoldi=Arnoldi{T}(n,maxdim)) where {T,Ttol<:Real,Thist<:History}

Initializing with an Arnoldi-factorization would be more general, but not very common usecase. A starting vector would be more user friendly for the common usecase.

Which option would you prefer @haampie?

Suppose we choose option 2 and partialschur is modified to also return the Arnoldi decomposition. Then, am I correct to think that this would allow for warm-starting cases where the user has already calculated n eigenvalues/vectors for an eigen-problem and then decides that he wants a few more?

Warm starting cases like this is very desirable for me and I can provide a minimal example use-case, if you think that's useful.

Yes. I think it could be made to allow warm-starting. One would need to create an Arnoldi object from the returned PartialSchur.

Perfect! I am happy to do a PR for (2) then if it is up for grabs.

👍 In this type of project all PRs are usually appreciated. :-)

Yes, I would be very happy to see (2), also pinging @jagot about this issue.

It should be very convenient for the user to pre-allocate the chunk of memory for the Krylov basis so that it's reusable when solving multiple times. And it should be easy to setup an initial partial Schur decomposition and continue expanding it. Providing an initial guess is just a special case of this.

So a PR that decouples the allocations from the algorithm is a step in the right direction! :)

Yes, I would be very interested in this. At the moment, I need to solve integro-differential equations on the form 𝓛u + F(u) = λu, where 𝓛 is a differential operator and F contains an integral of u. To this end, I solve an eigenvalue repeatedly, updating F after each iteration, until u and λ converges. Therefore, I'd like to specify an initial u and reuse the memory allocations as much as possible.

Does anyone working on this think this feature would be available soon? It’s the only thing that’s keeping me using Arpack.

I believe KrylovKit.jl has this already, check it out.

I think ArnoldiMethod.jl is now the most stable and fastest option among ARPACK and KrylovKit (at least on the CPU).

Now that most work is done w.r.t. stability of the algorithm, it would be good to fix the API.

  • Allow users to pass v1
  • Allow users to pass an initial partial Schur decomposition (i.e. v1, v2, ..., vn)
  • Simpler helper partialeigen (i.e. matlab's eigs)