Skip to content

Commit

Permalink
Merge pull request #986 from anastasia21112/anastasia-suite-sparse
Browse files Browse the repository at this point in the history
Loop over all classes of matrices
  • Loading branch information
ChrisRackauckas authored Aug 1, 2024
2 parents 46f7076 + 8e8b48f commit f9e5a99
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions benchmarks/LinearSolve/MatrixDepot.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,33 @@ algnames_transpose = reshape(algnames, 1, length(algnames))

cols = [:red, :blue, :green, :magenta, :turqoise] # one color per alg

matrices = ["HB/1138_bus", "HB/494_bus", "HB/662_bus", "HB/685_bus", "HB/bcsstk01", "HB/bcsstk02", "HB/bcsstk03", "HB/bcsstk04",
"HB/bcsstk05", "HB/bcsstk06", "HB/bcsstk07", "HB/bcsstk08", "HB/bcsstk09", "HB/bcsstk10", "HB/bcsstk11", "HB/bcsstk12",
"HB/bcsstk13", "HB/bcsstk14", "HB/bcsstk15", "HB/bcsstk16"]
# matrices = ["HB/1138_bus", "HB/494_bus", "HB/662_bus", "HB/685_bus", "HB/bcsstk01", "HB/bcsstk02", "HB/bcsstk03", "HB/bcsstk04", "HB/bcsstk05", "HB/bcsstk06", "HB/bcsstk07", "HB/bcsstk08", "HB/bcsstk09", "HB/bcsstk10", "HB/bcsstk11", "HB/bcsstk12", "HB/bcsstk13", "HB/bcsstk14", "HB/bcsstk15", "HB/bcsstk16"]
allmatrices_md = listnames("*/*")

times = fill(NaN, length(matrices), length(algs))
percentage_sparsity = fill(NaN, length(matrices))
matrix_size = fill(NaN, length(matrices))
@info "Total number of matrices: $(allmatrices_md.content[1].rows)"
times = fill(NaN, length(allmatrices_md.content[1].rows), length(algs))
percentage_sparsity = fill(NaN, length(allmatrices_md.content[1].rows))
matrix_size = fill(NaN, length(allmatrices_md.content[1].rows))
```

```julia
for z in 1:length(matrices)
for z in 1:length(allmatrices_md.content[1].rows)
try
matrix = allmatrices_md.content[1].rows[z]
matrix = string(matrix[1])

currMTX = matrix

rng = MersenneTwister(123)
A = mdopen(matrices[z]).A
A = mdopen(currMTX).A
A = convert(SparseMatrixCSC, A)
n = size(A, 1)
matrix_size[z] = n
percentage_sparsity[z] = length(nonzeros(A)) / n^2
@info "$n × $n"

n > 100 && error("Skipping too large matrices")

b = rand(rng, n)
u0 = rand(rng, n)

Expand All @@ -56,14 +64,25 @@ for z in 1:length(matrices)
alias_b = true))
times[z,j] = bt
end

#=
p = bar(algnames, times[z, :];
ylabel = "Time/s",
yscale = :log10,
title = "Time on $(matrices[z])",
title = "Time on $(currMTX)",
fmt = :png,
legend = :outertopright)
display(p)
=#

println("successfully factorized $(currMTX)")
catch e
println("$(matrices[z]) failed to factorize.")
matrix = allmatrices_md.content[1].rows[z]
matrix = string(matrix[1])

currMTX = matrix

println("$(currMTX) failed to factorize.")
println(e)
end
end
Expand All @@ -75,6 +94,7 @@ p = bar(algnames, meantimes;
ylabel = "Time/s",
yscale = :log10,
title = "Mean factorization time",
fmt = :png,
legend = :outertopright)
```

Expand All @@ -86,6 +106,7 @@ p = scatter(percentage_sparsity, times;
xscale = :log10,
label = algnames_transpose,
title = "Factorization Time vs Percentage Sparsity",
fmt = :png,
legend = :outertopright)
```

Expand All @@ -97,9 +118,11 @@ p = scatter(matrix_size, times;
xscale = :log10,
label = algnames_transpose,
title = "Factorization Time vs Matrix Size",
fmt = :png,
legend = :outertopright)
```


## Appendix

```julia, echo = false
Expand Down

0 comments on commit f9e5a99

Please sign in to comment.