williamesamuelson / AffineRayleighOptimization.jl

MIT License
0 stars 0 forks source link

implement sparse solver #4

Closed williamesamuelson closed 4 months ago

williamesamuelson commented 4 months ago

Added sparse RQ solver from #1.

However, I am a bit confused about the RQ_EIG solver. Do we allow $b$ to be a matrix?

cvsvensson commented 4 months ago

b can be a matrix, as in the section Extension in https://www.cis.upenn.edu/~jshi/papers/supplement_nips2006.pdf. We return one eigenvector for each column of b.

For weak majoranas, that means we can solve for both majoranas at once (the two columns of b are the two different right hand sides), while reusing the factorization of CC'.

williamesamuelson commented 4 months ago

I see, thanks!

cvsvensson commented 4 months ago

Perhaps https://github.com/JuliaLinearAlgebra/ArnoldiMethod.jl is preferable over Arpack.

cvsvensson commented 4 months ago

Perhaps https://github.com/JuliaLinearAlgebra/ArnoldiMethod.jl is preferable over Arpack.

Actually, our problem is hermitian, so the Lanczos algorithm is appropriate. Arpack.jl and KrylovKit.jl has this. I'd suggest trying the latter.

williamesamuelson commented 4 months ago

we decided that we should return a vector from solve and that $b$ can be given as a single vector or as a Span struct.

todo

williamesamuelson commented 4 months ago

There seems to be something going on in select_vectors causing RQ_EIG and RQ_SPARSE return different vectors.

function _select_vectors(eigvecs, P, eps=DEFAULT_SELECTVEC_EPS)
    vecs = eachcol(eigvecs)
    v = similar(first(vecs))
    f = x -> any(>(eps) ∘ abs, mul!(v, P, x))
    i1 = findfirst(f, vecs)
    return vecs[i1]
end

Could we instead return the vector corresponding to the first eigenvalue>epsilon?

Related to this, it seems like it would be easier to solve the maximization problem instead. In that case, with KrylovKit, we just have to calculate one eigenvector without comparing a bunch of eigenvalues to epsilon.

I guess that would be fine in the WeakMajorana problem if we adjust the penalty matrix.

Actually, it would be nice to implement both maximize and minimize

codecov[bot] commented 4 months ago

Welcome to Codecov :tada:

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered :open_umbrella:

williamesamuelson commented 4 months ago

A few questions/issues:

cvsvensson commented 4 months ago