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

Solutions generated with MINRES-QLP #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ to be cut off and I was not able to un-archive it or repair it.
If you know of a way to repair it, or better yet, have done it, please consider
submitting a pull request!

## Solutions
## Solutions generated with MATLAB

Because each problem is rank deficient, the solution we elected to report
is the minimum least-squares solution, i.e., among all the least-squares
Expand All @@ -61,6 +61,14 @@ For this reason, the solutions are named, e.g., `small_scaled_mls.rb`.
The Matlab code writes the solutions as simple vectors in a text file.
The matrices, right-hand sides and solutions are subsequently converted to Rutherford-Boeing format using the Julia package [`HarwellRutherfordBoeing.jl`](https://github.com/JuliaSparse/HarwellRutherfordBoeing.jl).

## Solutions generated with Julia

Each solution was generated by the Krylov method [`minres_qlp`](https://github.com/JuliaSmoothOptimizers/Krylov.jl) applied on the normal equations.
The computations are performed in quadruple precision.

Each minimum least-squares solution was generated using the Julia script
`write_mls.jl` found under `julia`. Solutions are stored in `mls\krylov` folder.

## References

Here are the original references for this test set.
Expand Down
35 changes: 35 additions & 0 deletions julia/write_mls.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using BenchmarkTools, HarwellRutherfordBoeing
using LinearAlgebra, SparseArrays, DelimitedFiles
using Krylov, Quadmath

function scale_ls!(A)
n, m = size(A)
s = ones(m)
for j = 1 : m
i = A.colptr[j]
k = A.colptr[j+1] - 1
nj = (i ≤ k) ? norm(A.nzval[i:k]) : 0.0
if nj > 0.0
A.nzval[i:k] ./= nj
s[j] = nj
end
end
return s
end

for pb in ("small", "small2", "medium", "medium2", "large", "large2", "very", "very2")
print("$pb: ")
A = RutherfordBoeingData("../rb/$(pb).rb").data
b = HarwellBoeingMatrix("../hb/$(pb).hb").rhs[:]
Comment on lines +21 to +22
Copy link
Author

Choose a reason for hiding this comment

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

HB = HarwellBoeingMatrix("../rb/$(pb).rb")
A = HB.matrix
b = HB.rhs[:,1]

is not working.

Copy link
Member

Choose a reason for hiding this comment

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

You have to read a hb file.

s = scale_ls!(A)
A = Float128.(A)
b = Float128.(b)
M = A' * A
rhs = A' * b
x, stats = minres_qlp(M, rhs, rtol=Float128(1e-20), atol=Float128(1e-25))
println("✓")
x = Float64.(x)
open("../mls/krylov/$(pb)_scaled_mls.txt", "w") do io
writedlm(io, x)
end
end
Loading