From 2d0ff28b1becae4b9fc02f9b403f9de810d68da6 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Tue, 24 Mar 2026 02:04:05 -0400 Subject: [PATCH 1/4] simplify objective functions since the log(A_ij) is constant, there's no need to include it in the linear objectives, which allows for simplifying the loop dramatically (at least when the matrix has no zeros) --- ext/SIAJuMP.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/SIAJuMP.jl b/ext/SIAJuMP.jl index a06203b..ff7855f 100644 --- a/ext/SIAJuMP.jl +++ b/ext/SIAJuMP.jl @@ -33,7 +33,7 @@ function ScaleInvariantAnalysis.symcover_lmin(A) model = JuMP.Model(HiGHS.Optimizer) JuMP.set_silent(model) @variable(model, α[1:n]) - @objective(model, Min, sum(α[i] + α[j] - logA[i, j] for i in 1:n, j in 1:n if A[i, j] != 0)) + @objective(model, Min, sum(α)) for i in 1:n for j in i:n if A[i, j] != 0 @@ -74,7 +74,7 @@ function ScaleInvariantAnalysis.cover_lmin(A) JuMP.set_silent(model) @variable(model, α[1:m]) @variable(model, β[1:n]) - @objective(model, Min, sum(α[i] + β[j] - logA[i, j] for i in 1:m, j in 1:n if A[i, j] != 0)) + @objective(model, Min, sum(α) + sum(β)) for i in 1:m for j in 1:n if A[i, j] != 0 From 03cee047beaa5804a6c0944783edd990dccdbb3e Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Tue, 24 Mar 2026 12:56:03 -0400 Subject: [PATCH 2/4] account for zeros of `A` --- ext/SIAJuMP.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/SIAJuMP.jl b/ext/SIAJuMP.jl index ff7855f..35babf8 100644 --- a/ext/SIAJuMP.jl +++ b/ext/SIAJuMP.jl @@ -33,7 +33,10 @@ function ScaleInvariantAnalysis.symcover_lmin(A) model = JuMP.Model(HiGHS.Optimizer) JuMP.set_silent(model) @variable(model, α[1:n]) - @objective(model, Min, sum(α)) + + nonzero_rows = count(!iszero, A, dims=1) + nonzero_cols = count(!iszero, A, dims=2) + @objective(model, Min, dot(α, nonzero_rows.*nonzero_cols)) for i in 1:n for j in i:n if A[i, j] != 0 @@ -74,7 +77,10 @@ function ScaleInvariantAnalysis.cover_lmin(A) JuMP.set_silent(model) @variable(model, α[1:m]) @variable(model, β[1:n]) - @objective(model, Min, sum(α) + sum(β)) + + nonzero_rows = count(!iszero, A, dims=1) + nonzero_cols = count(!iszero, A, dims=2) + @objective(model, Min, dot(α, nonzero_rows) + dot(β, nonzero_cols)) for i in 1:m for j in 1:n if A[i, j] != 0 From 446a03e43c64012e0d0183a2ad4ee9f816c50cef Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Tue, 24 Mar 2026 13:08:20 -0400 Subject: [PATCH 3/4] fix --- ext/SIAJuMP.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/SIAJuMP.jl b/ext/SIAJuMP.jl index 35babf8..d192ee3 100644 --- a/ext/SIAJuMP.jl +++ b/ext/SIAJuMP.jl @@ -3,6 +3,7 @@ module SIAJuMP using JuMP: JuMP, @variable, @objective, @constraint using HiGHS: HiGHS using ScaleInvariantAnalysis +using LinearAlgebra: dot # Reference implementation for a symmetric matrix cover function ScaleInvariantAnalysis.symcover_qmin(A) @@ -34,9 +35,9 @@ function ScaleInvariantAnalysis.symcover_lmin(A) JuMP.set_silent(model) @variable(model, α[1:n]) - nonzero_rows = count(!iszero, A, dims=1) + nonzero_rows = count(!iszero, A, dims=1)' nonzero_cols = count(!iszero, A, dims=2) - @objective(model, Min, dot(α, nonzero_rows.*nonzero_cols)) + @objective(model, Min, dot(α, nonzero_rows.+nonzero_cols)) for i in 1:n for j in i:n if A[i, j] != 0 From a8cf11ae918bab34e37177d9d24b85b19bb2cb67 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Tue, 24 Mar 2026 13:13:55 -0400 Subject: [PATCH 4/4] fix nonsymmetric --- ext/SIAJuMP.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/SIAJuMP.jl b/ext/SIAJuMP.jl index d192ee3..1da9871 100644 --- a/ext/SIAJuMP.jl +++ b/ext/SIAJuMP.jl @@ -79,9 +79,9 @@ function ScaleInvariantAnalysis.cover_lmin(A) @variable(model, α[1:m]) @variable(model, β[1:n]) - nonzero_rows = count(!iszero, A, dims=1) + nonzero_rows = count(!iszero, A, dims=1)' nonzero_cols = count(!iszero, A, dims=2) - @objective(model, Min, dot(α, nonzero_rows) + dot(β, nonzero_cols)) + @objective(model, Min, dot(α, nonzero_cols) + dot(β, nonzero_rows)) for i in 1:m for j in 1:n if A[i, j] != 0