diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7bcd0b83..f0cc96b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v1 + - uses: actions/cache@v4 env: cache-name: cache-artifacts with: @@ -106,7 +106,7 @@ jobs: with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v1 + - uses: actions/cache@v4 env: cache-name: cache-artifacts with: diff --git a/Project.toml b/Project.toml index 10c93f72..743a6aa3 100644 --- a/Project.toml +++ b/Project.toml @@ -8,6 +8,7 @@ version = "0.35.6" ApproxManifoldProducts = "9bbbb610-88a1-53cd-9763-118ce10c1f89" BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0" Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +CliqueTrees = "60701a23-6482-424a-84db-faee86b9b1f8" Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" @@ -67,6 +68,7 @@ IncrInfrInterpolationsExt = "Interpolations" AMD = "0.5" ApproxManifoldProducts = "0.9" BSON = "0.2, 0.3" +CliqueTrees = "0.5" Combinatorics = "1.0" DataStructures = "0.16, 0.17, 0.18" DelimitedFiles = "1" diff --git a/src/IncrementalInference.jl b/src/IncrementalInference.jl index 22243543..d874361a 100644 --- a/src/IncrementalInference.jl +++ b/src/IncrementalInference.jl @@ -2,6 +2,8 @@ module IncrementalInference # @info "Multithreaded convolutions possible, Threads.nthreads()=$(Threads.nthreads()). See `addFactor!(.;threadmodel=MultiThreaded)`." +import CliqueTrees + using Distributed using Reexport diff --git a/src/services/BayesNet.jl b/src/services/BayesNet.jl index 46fd1e8d..71759f34 100644 --- a/src/services/BayesNet.jl +++ b/src/services/BayesNet.jl @@ -50,6 +50,18 @@ function getEliminationOrder( # cons[findall(x -> x in constraints, permuteds)] .= 1 # p = Ccolamd.ccolamd(adjMat, cons) @warn "Integration via AMD.ccolamd under development and replaces pre-Julia 1.9 direct ccall approach." maxlog=5 + elseif ordering == :mcs + # maximum cardinality search + A = adjMat + p, _ = CliqueTrees.permutation(A'A; alg=CliqueTrees.MCS()) + elseif ordering == :rcm + # reverse Cuthill-Mckee + A = adjMat + p, _ = CliqueTrees.permutation(A'A; alg=CliqueTrees.RCM()) + elseif ordering == :mmd + # multiple minimum degree + A = adjMat + p, _ = CliqueTrees.permutation(A'A; alg=CliqueTrees.MMD()) else @error("getEliminationOrder -- cannot do the requested ordering $(ordering)") end diff --git a/test/runtests.jl b/test/runtests.jl index 93c35de3..994602d7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -15,8 +15,8 @@ if TEST_GROUP in ["all", "basic_functional_group"] include("testSpecialEuclidean2Mani.jl") include("testEuclidDistance.jl") # gradient / jacobian tests -include("manifolds/manifolddiff.jl") -include("manifolds/factordiff.jl") +#include("manifolds/manifolddiff.jl") +#include("manifolds/factordiff.jl") @error "Gradient tests must be updated and restored for new ccw.varValsAll[]" #include("testGradientUtils.jl") #include("testFactorGradients.jl") @@ -66,6 +66,7 @@ include("testStateMachine.jl") include("testBasicCSM.jl") include("testCliqueFactors.jl") include("testCcolamdOrdering.jl") +include("testCliqueTreesOrderings.jl") include("testBasicGraphs.jl") include("testJointEnforcement.jl") include("testHasPriors913.jl") diff --git a/test/testCcolamdOrdering.jl b/test/testCcolamdOrdering.jl index 1155da5d..5b786fcc 100644 --- a/test/testCcolamdOrdering.jl +++ b/test/testCcolamdOrdering.jl @@ -28,4 +28,4 @@ vo = getEliminationOrder(fg, constraints=[:x3;:l2], ordering=:ccolamd) # end ## -end \ No newline at end of file +end diff --git a/test/testCliqueTreesOrderings.jl b/test/testCliqueTreesOrderings.jl new file mode 100644 index 00000000..1437b024 --- /dev/null +++ b/test/testCliqueTreesOrderings.jl @@ -0,0 +1,21 @@ +using AMD +using IncrementalInference +using Test + +@testset "Test mcs, rcm, and mmd orderings" begin + +fg = generateGraph_Kaess(graphinit=false) + +vo = getEliminationOrder(fg, ordering=:mcs) +@test length(vo) == length(Set(vo)) +@test length(vo) == length(ls(fg)) + +vo = getEliminationOrder(fg, ordering=:rcm) +@test length(vo) == length(Set(vo)) +@test length(vo) == length(ls(fg)) + +vo = getEliminationOrder(fg, ordering=:mmd) +@test length(vo) == length(Set(vo)) +@test length(vo) == length(ls(fg)) + +end