diff --git a/Project.toml b/Project.toml index 22a69a3..2464435 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ScaleInvariantAnalysis" uuid = "727e6139-ff52-4636-a344-ed1d23e73ffc" -authors = ["Tim Holy and contributors"] version = "1.0.0-DEV" +authors = ["Tim Holy and contributors"] [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -23,6 +23,7 @@ LinearAlgebra = "1.10.0" NautyGraphs = "0.7" ParametricOptInterface = "0.15" PrecompileTools = "1" +ProgressMeter = "1" Random = "1" SparseArrays = "1.10.0" julia = "1.10.10" @@ -33,9 +34,10 @@ HiGHS = "87dc4568-4c63-4d18-b0c0-bb2238e4078b" JuMP = "4076af6c-e467-56ae-b986-b466b2749572" NautyGraphs = "7509a0a4-015a-4167-b44b-0799a1a2605e" ParametricOptInterface = "0ce4ce61-57bf-432b-a095-efac525d185e" +ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Graphs", "HiGHS", "JuMP", "NautyGraphs", "ParametricOptInterface", "Random", "Statistics", "Test"] +test = ["Graphs", "HiGHS", "JuMP", "NautyGraphs", "ParametricOptInterface", "ProgressMeter", "Random", "Statistics", "Test"] diff --git a/test/buildmatrices.jl b/test/buildmatrices.jl index cd74e16..ec72df5 100644 --- a/test/buildmatrices.jl +++ b/test/buildmatrices.jl @@ -2,6 +2,7 @@ using LinearAlgebra using Graphs: Graphs, connected_components using NautyGraphs: NautyGraphs, NautyGraph, NautyDiGraph, canonize! using Random +using ProgressMeter # The following partially duplicate "testutils.jl", but with an emphasis on performance in generating @@ -55,7 +56,7 @@ function logA_reset!(ps, logA) end -function accumulate_examples!(fdA, NG, comps, A, model, ps, vars...) +function accumulate_examples!(fdA, NG, comps, lenhist, i, A, model, ps, vars...) logA = log.(abs.(A)) logA_reset!(ps, logA) dA = fdA(model, A, logA, vars...) @@ -69,6 +70,7 @@ function accumulate_examples!(fdA, NG, comps, A, model, ps, vars...) end if !haskey(comps, edges) comps[edges] = A[p, p] + push!(lenhist, i) end end @@ -77,6 +79,7 @@ function dA_symmetric(model, A, logA, αvariable) JuMP.optimize!(model) JuMP.value.(αvariable) catch err + # xref https://github.com/jump-dev/HiGHS.jl/issues/322 @warn "Optimization failed for matrix $A: $err" return end @@ -98,19 +101,21 @@ Random.seed!(1234) valrange = 1:20 comps_sym = Dict{Vector{Tuple{Int,Int}}, Matrix{Int}}() +lenhist_sym = Int[] Adummy = Symmetric([rand(valrange) for _ in 1:5, _ in 1:5]) model, αvariable, ps = logsymcover_ref_setup(log.(abs.(Adummy))) -for i = 1:10^5 +@showprogress "Building random symmetric matrices..." for i = 1:10^5 A = Symmetric([rand(valrange) for _ in 1:5, _ in 1:5]) - accumulate_examples!(dA_symmetric, NautyGraph, comps_sym, A, model, ps, αvariable) + accumulate_examples!(dA_symmetric, NautyGraph, comps_sym, lenhist_sym, i, A, model, ps, αvariable) end comps = Dict{Vector{Tuple{Int,Int}}, Matrix{Int}}() +lenhist = Int[] Adummy = [rand(valrange) for _ in 1:5, _ in 1:5] model, αvariable, βvariable, ps = logcover_ref_setup(log.(abs.(Adummy))) -for i = 1:10^5 +@showprogress "Building random general matrices..." for i = 1:10^5 A = [rand(valrange) for _ in 1:5, _ in 1:5] - accumulate_examples!(dA_general, NautyDiGraph, comps, A, model, ps, αvariable, βvariable) + accumulate_examples!(dA_general, NautyDiGraph, comps, lenhist, i, A, model, ps, αvariable, βvariable) end