Skip to content

Commit 65ca2c5

Browse files
authored
Measure test-matrix saturation (#12)
Records the iteration at which each was added, as a measure of saturation.
1 parent c795697 commit 65ca2c5

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ScaleInvariantAnalysis"
22
uuid = "727e6139-ff52-4636-a344-ed1d23e73ffc"
3-
authors = ["Tim Holy <tim.holy@gmail.com> and contributors"]
43
version = "1.0.0-DEV"
4+
authors = ["Tim Holy <tim.holy@gmail.com> and contributors"]
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -23,6 +23,7 @@ LinearAlgebra = "1.10.0"
2323
NautyGraphs = "0.7"
2424
ParametricOptInterface = "0.15"
2525
PrecompileTools = "1"
26+
ProgressMeter = "1"
2627
Random = "1"
2728
SparseArrays = "1.10.0"
2829
julia = "1.10.10"
@@ -33,9 +34,10 @@ HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b"
3334
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
3435
NautyGraphs = "7509a0a4-015a-4167-b44b-0799a1a2605e"
3536
ParametricOptInterface = "0ce4ce61-57bf-432b-a095-efac525d185e"
37+
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
3638
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
3739
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
3840
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3941

4042
[targets]
41-
test = ["Graphs", "HiGHS", "JuMP", "NautyGraphs", "ParametricOptInterface", "Random", "Statistics", "Test"]
43+
test = ["Graphs", "HiGHS", "JuMP", "NautyGraphs", "ParametricOptInterface", "ProgressMeter", "Random", "Statistics", "Test"]

test/buildmatrices.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ using LinearAlgebra
22
using Graphs: Graphs, connected_components
33
using NautyGraphs: NautyGraphs, NautyGraph, NautyDiGraph, canonize!
44
using Random
5+
using ProgressMeter
56

67

78
# The following partially duplicate "testutils.jl", but with an emphasis on performance in generating
@@ -55,7 +56,7 @@ function logA_reset!(ps, logA)
5556
end
5657

5758

58-
function accumulate_examples!(fdA, NG, comps, A, model, ps, vars...)
59+
function accumulate_examples!(fdA, NG, comps, lenhist, i, A, model, ps, vars...)
5960
logA = log.(abs.(A))
6061
logA_reset!(ps, logA)
6162
dA = fdA(model, A, logA, vars...)
@@ -69,6 +70,7 @@ function accumulate_examples!(fdA, NG, comps, A, model, ps, vars...)
6970
end
7071
if !haskey(comps, edges)
7172
comps[edges] = A[p, p]
73+
push!(lenhist, i)
7274
end
7375
end
7476

@@ -77,6 +79,7 @@ function dA_symmetric(model, A, logA, αvariable)
7779
JuMP.optimize!(model)
7880
JuMP.value.(αvariable)
7981
catch err
82+
# xref https://github.com/jump-dev/HiGHS.jl/issues/322
8083
@warn "Optimization failed for matrix $A: $err"
8184
return
8285
end
@@ -98,19 +101,21 @@ Random.seed!(1234)
98101

99102
valrange = 1:20
100103
comps_sym = Dict{Vector{Tuple{Int,Int}}, Matrix{Int}}()
104+
lenhist_sym = Int[]
101105
Adummy = Symmetric([rand(valrange) for _ in 1:5, _ in 1:5])
102106
model, αvariable, ps = logsymcover_ref_setup(log.(abs.(Adummy)))
103-
for i = 1:10^5
107+
@showprogress "Building random symmetric matrices..." for i = 1:10^5
104108
A = Symmetric([rand(valrange) for _ in 1:5, _ in 1:5])
105-
accumulate_examples!(dA_symmetric, NautyGraph, comps_sym, A, model, ps, αvariable)
109+
accumulate_examples!(dA_symmetric, NautyGraph, comps_sym, lenhist_sym, i, A, model, ps, αvariable)
106110
end
107111

108112
comps = Dict{Vector{Tuple{Int,Int}}, Matrix{Int}}()
113+
lenhist = Int[]
109114
Adummy = [rand(valrange) for _ in 1:5, _ in 1:5]
110115
model, αvariable, βvariable, ps = logcover_ref_setup(log.(abs.(Adummy)))
111-
for i = 1:10^5
116+
@showprogress "Building random general matrices..." for i = 1:10^5
112117
A = [rand(valrange) for _ in 1:5, _ in 1:5]
113-
accumulate_examples!(dA_general, NautyDiGraph, comps, A, model, ps, αvariable, βvariable)
118+
accumulate_examples!(dA_general, NautyDiGraph, comps, lenhist, i, A, model, ps, αvariable, βvariable)
114119
end
115120

116121

0 commit comments

Comments
 (0)