From f97da256d5d46362eb9c400f6e0ded89c8ef1834 Mon Sep 17 00:00:00 2001 From: Paul Goulart Date: Sat, 4 May 2024 14:05:17 +0100 Subject: [PATCH] Force include diagonal in aggregate sparsity (#187) Attempts to resolve issue #183 --- src/chordal_decomposition/chordal_decomposition.jl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/chordal_decomposition/chordal_decomposition.jl b/src/chordal_decomposition/chordal_decomposition.jl index 056a3341..f6a83684 100644 --- a/src/chordal_decomposition/chordal_decomposition.jl +++ b/src/chordal_decomposition/chordal_decomposition.jl @@ -85,7 +85,7 @@ function nz_rows(a::SparseMatrixCSC{T}, ind::UnitRange{Int}, DROP_ZEROS_FLAG::Bo active[r - ind.start + 1] = true end end - return findall(active) + active end function number_of_overlaps_in_rows(A::SparseMatrixCSC{T}) where {T <: AbstractFloat} @@ -97,7 +97,16 @@ end function find_aggregate_sparsity(A::SparseMatrixCSC{T}, b::AbstractVector{T}, ind::UnitRange{Int}, C::DecomposableCones{T}) where {T <: AbstractFloat} - AInd = nz_rows(A, ind, false) + + AInd_logical = nz_rows(A, ind, false) + + # explicitly flag all the terms corresonding to the cone diagonal + for i = 1:C.sqrt_dim + AInd_logical[vec_dim(i, C)] = true + end + + AInd = findall(AInd_logical) + # commonZeros = AInd[find(x->x==0,b[AInd])] bInd = findall(x -> x != 0, view(b, ind)) commonNZeros = union(AInd, bInd)