Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ext/SIAJuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -33,7 +34,10 @@ 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))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right this is a good simplification (although it's the constraints that make it slow), but we need to handle the case where A has zeros. I think precomputing sum(iszero, A; dims=1 or 2) might enable this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're need both. It would be somewhat surprising to me if going from an O(mn) to O(m+n) size objective didn't speed things up a bit.


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
Expand Down Expand Up @@ -74,7 +78,10 @@ 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))

nonzero_rows = count(!iszero, A, dims=1)'
nonzero_cols = count(!iszero, A, dims=2)
@objective(model, Min, dot(α, nonzero_cols) + dot(β, nonzero_rows))
for i in 1:m
for j in 1:n
if A[i, j] != 0
Expand Down
Loading