@@ -2,6 +2,7 @@ using LinearAlgebra
22using Graphs: Graphs, connected_components
33using NautyGraphs: NautyGraphs, NautyGraph, NautyDiGraph, canonize!
44using 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)
5556end
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
7375end
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
99102valrange = 1 : 20
100103comps_sym = Dict {Vector{Tuple{Int,Int}}, Matrix{Int}} ()
104+ lenhist_sym = Int[]
101105Adummy = Symmetric ([rand (valrange) for _ in 1 : 5 , _ in 1 : 5 ])
102106model, α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)
106110end
107111
108112comps = Dict {Vector{Tuple{Int,Int}}, Matrix{Int}} ()
113+ lenhist = Int[]
109114Adummy = [rand (valrange) for _ in 1 : 5 , _ in 1 : 5 ]
110115model, α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)
114119end
115120
116121
0 commit comments