Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast implementation of triangulation algorithms. #14

Merged
merged 2 commits into from
Mar 6, 2025

Conversation

samuelsonric
Copy link
Contributor

@samuelsonric samuelsonric commented Mar 4, 2025

I have a package CliqueTrees.jl with fast implementations of various graph triangulation algorithms. Here are some benchmarks.

julia> using Graphs, MatrixMarket, SuiteSparseMatrixCollection, SparseArrays, TSSOS

julia> ssmc = ssmc_db();

julia> name = "bcsstk11";

julia> matrix = mmread(joinpath(fetch_ssmc(ssmc[ssmc.name .== name, :], format="MM")[1], "$(name).mtx"));

julia> graph = Graph(fkeep!((i, j, x) -> i != j, matrix))
{1473, 16384} undirected simple Int64 graph

old implementation

julia> @time TSSOS.chordal_cliques!(copy(graph); method="MF", minimize=false);
  7.749093 seconds (96.07 k allocations: 67.437 MiB, 0.27% gc time)

julia> @time TSSOS.chordal_cliques!(copy(graph); method="MF", minimize=true);
  9.379268 seconds (311.25 k allocations: 142.738 MiB, 0.12% gc time)

new implementation

julia> @time TSSOS.chordal_cliques!(copy(graph); method="MF", minimize=false);
  0.011180 seconds (14.00 k allocations: 6.338 MiB)

julia> @time TSSOS.chordal_cliques!(copy(graph); method="MF", minimize=true);
  0.042636 seconds (22.98 k allocations: 11.396 MiB)

@samuelsonric
Copy link
Contributor Author

samuelsonric commented Mar 4, 2025

Here, I am benchmarking the Broyden banded function from example 7.1 of this paper.

julia> using DynamicPolynomials, TSSOS

julia> function broyden_banded(n)
           @polyvar x[1:n]
    
           g = sum(1:n) do i
               f = x[i] * (2 + 5x[i]^2) + 1
        
               for j in max(1, i - 5):min(n, i + 1)
                   if i != j
                       f += (1 + x[j]) * x[j]
                   end
               end
        
               return f^2
           end
    
           return g, x
       end;

julia> f, x = broyden_banded(500);

old implementation

julia> @time cs_tssos_first([f], x, 3; TS="MF");
 91.944828 seconds (5.83 G allocations: 219.252 GiB, 22.71% gc time)

new implementation

julia> @time cs_tssos_first([f], x, 3; TS="MF");
 78.821616 seconds (5.37 G allocations: 201.896 GiB, 23.82% gc time)

@wangjie212 wangjie212 merged commit b72d3ac into wangjie212:master Mar 6, 2025
1 check failed
@wangjie212
Copy link
Owner

Thank you very much for introducing this nice package to me!

@samuelsonric
Copy link
Contributor Author

Let me know if there are any problems.

@mschauer
Copy link

mschauer commented Mar 6, 2025

@samuelsonric on a run mschauer/CausalInference.jl#168 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants