Skip to content

Commit

Permalink
Use symmetric_coefficient from SMC
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle authored and amontoison committed Jul 18, 2024
1 parent 570798e commit e1921d6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ NLPModels = "0.18, 0.19, 0.20, 0.21"
Requires = "1"
ReverseDiff = "1"
SparseConnectivityTracer = "0.5"
SparseMatrixColorings = "0.3.4"
SparseMatrixColorings = "0.3.5"
julia = "^1.6"
3 changes: 2 additions & 1 deletion src/ADNLPModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ using LinearAlgebra, SparseArrays
# external
using ADTypes: ADTypes, AbstractColoringAlgorithm, AbstractSparsityDetector
using SparseConnectivityTracer: TracerSparsityDetector
using SparseMatrixColorings: GreedyColoringAlgorithm, symmetric_coloring_detailed
using SparseMatrixColorings:
GreedyColoringAlgorithm, symmetric_coloring_detailed, symmetric_coefficient
using ForwardDiff, ReverseDiff

# JSO
Expand Down
19 changes: 2 additions & 17 deletions src/sparsity_pattern.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,13 @@ function nnz_colors(trilH, star_set, colors, ncolors)
# Because we exploit the symmetry, we also need to store the row index for a given coefficient
# in the "compressed column".
dcolors = Dict(i => Tuple{Int,Int}[] for i=1:ncolors)
star = star_set.star
hub = star_set.hub

n = LinearAlgebra.checksquare(trilH)
for j in 1:n
for k in trilH.colptr[j]:trilH.colptr[j+1]-1
i = trilH.rowval[k]

if i == j
h = i
else
star_id = star[(j, i)]
h = hub[star_id]
end

# pick arbitrary hub
(h == 0) && (h = i)
c = colors[h]
# i is the spoke
(h == j) && push!(dcolors[c], (i,k))
# j is the spoke
(h == i) && push!(dcolors[c], (j,k))
l, c = symmetric_coefficient(i, j, color, star_set)
push!(dcolors[c], (l, k))
end
end

Expand Down

0 comments on commit e1921d6

Please sign in to comment.