Skip to content

Commit 992c83f

Browse files
authored
Merge pull request #1855 from samuelsonric/develop
Add elimination algorithms `mcs`, `rcm`, and `mmd`.
2 parents 0ac1954 + 8af2651 commit 992c83f

File tree

7 files changed

+43
-5
lines changed

7 files changed

+43
-5
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
with:
6565
version: ${{ matrix.version }}
6666
arch: ${{ matrix.arch }}
67-
- uses: actions/cache@v1
67+
- uses: actions/cache@v4
6868
env:
6969
cache-name: cache-artifacts
7070
with:
@@ -106,7 +106,7 @@ jobs:
106106
with:
107107
version: ${{ matrix.version }}
108108
arch: ${{ matrix.arch }}
109-
- uses: actions/cache@v1
109+
- uses: actions/cache@v4
110110
env:
111111
cache-name: cache-artifacts
112112
with:

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ version = "0.35.6"
88
ApproxManifoldProducts = "9bbbb610-88a1-53cd-9763-118ce10c1f89"
99
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
1010
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
11+
CliqueTrees = "60701a23-6482-424a-84db-faee86b9b1f8"
1112
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
1213
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
1314
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
@@ -67,6 +68,7 @@ IncrInfrInterpolationsExt = "Interpolations"
6768
AMD = "0.5"
6869
ApproxManifoldProducts = "0.9"
6970
BSON = "0.2, 0.3"
71+
CliqueTrees = "0.5"
7072
Combinatorics = "1.0"
7173
DataStructures = "0.16, 0.17, 0.18"
7274
DelimitedFiles = "1"

src/IncrementalInference.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module IncrementalInference
22

33
# @info "Multithreaded convolutions possible, Threads.nthreads()=$(Threads.nthreads()). See `addFactor!(.;threadmodel=MultiThreaded)`."
44

5+
import CliqueTrees
6+
57
using Distributed
68
using Reexport
79

src/services/BayesNet.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ function getEliminationOrder(
5050
# cons[findall(x -> x in constraints, permuteds)] .= 1
5151
# p = Ccolamd.ccolamd(adjMat, cons)
5252
@warn "Integration via AMD.ccolamd under development and replaces pre-Julia 1.9 direct ccall approach." maxlog=5
53+
elseif ordering == :mcs
54+
# maximum cardinality search
55+
A = adjMat
56+
p, _ = CliqueTrees.permutation(A'A; alg=CliqueTrees.MCS())
57+
elseif ordering == :rcm
58+
# reverse Cuthill-Mckee
59+
A = adjMat
60+
p, _ = CliqueTrees.permutation(A'A; alg=CliqueTrees.RCM())
61+
elseif ordering == :mmd
62+
# multiple minimum degree
63+
A = adjMat
64+
p, _ = CliqueTrees.permutation(A'A; alg=CliqueTrees.MMD())
5365
else
5466
@error("getEliminationOrder -- cannot do the requested ordering $(ordering)")
5567
end

test/runtests.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ if TEST_GROUP in ["all", "basic_functional_group"]
1515
include("testSpecialEuclidean2Mani.jl")
1616
include("testEuclidDistance.jl")
1717
# gradient / jacobian tests
18-
include("manifolds/manifolddiff.jl")
19-
include("manifolds/factordiff.jl")
18+
#include("manifolds/manifolddiff.jl")
19+
#include("manifolds/factordiff.jl")
2020
@error "Gradient tests must be updated and restored for new ccw.varValsAll[]"
2121
#include("testGradientUtils.jl")
2222
#include("testFactorGradients.jl")
@@ -66,6 +66,7 @@ include("testStateMachine.jl")
6666
include("testBasicCSM.jl")
6767
include("testCliqueFactors.jl")
6868
include("testCcolamdOrdering.jl")
69+
include("testCliqueTreesOrderings.jl")
6970
include("testBasicGraphs.jl")
7071
include("testJointEnforcement.jl")
7172
include("testHasPriors913.jl")

test/testCcolamdOrdering.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ vo = getEliminationOrder(fg, constraints=[:x3;:l2], ordering=:ccolamd)
2828
# end
2929

3030
##
31-
end
31+
end

test/testCliqueTreesOrderings.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using AMD
2+
using IncrementalInference
3+
using Test
4+
5+
@testset "Test mcs, rcm, and mmd orderings" begin
6+
7+
fg = generateGraph_Kaess(graphinit=false)
8+
9+
vo = getEliminationOrder(fg, ordering=:mcs)
10+
@test length(vo) == length(Set(vo))
11+
@test length(vo) == length(ls(fg))
12+
13+
vo = getEliminationOrder(fg, ordering=:rcm)
14+
@test length(vo) == length(Set(vo))
15+
@test length(vo) == length(ls(fg))
16+
17+
vo = getEliminationOrder(fg, ordering=:mmd)
18+
@test length(vo) == length(Set(vo))
19+
@test length(vo) == length(ls(fg))
20+
21+
end

0 commit comments

Comments
 (0)