Skip to content

Commit 008ab5b

Browse files
authored
Merge branch 'master' into 23Q2/test/restore3alttests
2 parents c5059b4 + 9e320bc commit 008ab5b

37 files changed

+774
-614
lines changed

NEWS.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Additional NEWS on IncrementalInference.jl Releases
1+
# NEWS on IncrementalInference.jl Releases
22

33
Currently general maintenance and bug fix changes are mostly tracked via Github Integrations. E.g. see Milestones along with Label filters to quickly find specific issues.
44
- https://github.com/JuliaRobotics/IncrementalInference.jl/milestones?state=closed
@@ -13,8 +13,11 @@ The list below highlights breaking changes according to normal semver workflow -
1313

1414
# Changes in v0.34
1515

16-
- Start transition to Manopt.jl via Riemannian Levenberg Marquart.
16+
- Start transition to Manopt.jl via Riemannian Levenberg-Marquart.
1717
- Deprecate `AbstractRelativeRoots`.
18+
- Standardization improvements surrounding weakdeps code extensions.
19+
- Code quality improvements along wiht refactoring and reorganizing of file names and locations.
20+
- Restoring `DERelative` factors, although further fixes necessary beyond anticipated patch release v0.34.1.
1821

1922
# Changes in v0.33
2023

Project.toml

+14-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "IncrementalInference"
22
uuid = "904591bb-b899-562f-9e6f-b8df64c7d480"
33
keywords = ["MM-iSAMv2", "Bayes tree", "junction tree", "Bayes network", "variable elimination", "graphical models", "SLAM", "inference", "sum-product", "belief-propagation"]
44
desc = "Implements the Multimodal-iSAMv2 algorithm."
5-
version = "0.34.0"
5+
version = "0.34.1"
66

77
[deps]
88
ApproxManifoldProducts = "9bbbb610-88a1-53cd-9763-118ce10c1f89"
@@ -37,7 +37,6 @@ ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
3737
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
3838
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
3939
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
40-
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
4140
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
4241
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
4342
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
@@ -50,25 +49,29 @@ TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
5049
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
5150

5251
[weakdeps]
52+
AMD = "14f7f29c-3bd6-536c-9a0b-7339e30b5a3e"
5353
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
54+
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
5455
Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004"
5556
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
5657
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
5758

5859
[extensions]
59-
DiffEqFactorExt = "DifferentialEquations"
60-
GadflyExt = "Gadfly"
61-
InteractiveUtilsExt = "InteractiveUtils"
62-
InterpolationsExt = "Interpolations"
60+
IncrInfrApproxMinDegreeExt = "AMD"
61+
IncrInfrDiffEqFactorExt = "DifferentialEquations"
62+
IncrInfrFluxFactorsExt = "Flux"
63+
IncrInfrGadflyExt = "Gadfly"
64+
IncrInfrInteractiveUtilsExt = "InteractiveUtils"
65+
IncrInfrInterpolationsExt = "Interpolations"
6366

6467
[compat]
65-
ApproxManifoldProducts = "0.7"
68+
ApproxManifoldProducts = "0.7, 0.8"
6669
BSON = "0.2, 0.3"
6770
BlockArrays = "0.16"
6871
Combinatorics = "1.0"
6972
DataStructures = "0.16, 0.17, 0.18"
7073
DelimitedFiles = "1"
71-
DistributedFactorGraphs = "0.21, 0.22"
74+
DistributedFactorGraphs = "0.23"
7275
Distributions = "0.24, 0.25"
7376
DocStringExtensions = "0.8, 0.9"
7477
FileIO = "1"
@@ -88,17 +91,16 @@ PrecompileTools = "1"
8891
ProgressMeter = "1"
8992
RecursiveArrayTools = "2.31.1"
9093
Reexport = "1"
91-
Requires = "1"
9294
SparseDiffTools = "2"
9395
StaticArrays = "1"
9496
StatsBase = "0.32, 0.33, 0.34"
9597
StructTypes = "1"
9698
TensorCast = "0.3.3, 0.4"
9799
TimeZones = "1.3.1"
98-
julia = "1.8"
100+
julia = "1.9"
99101

100102
[extras]
101-
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
103+
AMD = "14f7f29c-3bd6-536c-9a0b-7339e30b5a3e"
102104
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
103105
LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
104106
Manopt = "0fc0a36d-df90-57f3-8f93-d78a9fc72bb5"
@@ -108,4 +110,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
108110
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
109111

110112
[targets]
111-
test = ["DifferentialEquations", "Flux", "Graphs", "Manopt", "InteractiveUtils", "Interpolations", "LineSearches", "Pkg", "Rotations", "Test", "Zygote"]
113+
test = ["AMD", "DifferentialEquations", "Flux", "Graphs", "Manopt", "InteractiveUtils", "Interpolations", "LineSearches", "Pkg", "Rotations", "Test", "Zygote"]
File renamed without changes.

src/Serialization/services/FluxModelsSerialization.jl ext/FluxModelsSerialization.jl

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
# @info "IncrementalInference is adding Flux/BSON serialization functionality."
44

5-
using Base64
6-
7-
import Base: convert
85

96
function _serializeFluxModelBase64(model::Flux.Chain)
107
io = IOBuffer()

ext/HeatmapSampler.jl

+105
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,110 @@
11
# heatmap sampler (experimental)
22

3+
4+
(hmd::HeatmapGridDensity)(w...; kw...) = hmd.densityFnc(w...; kw...)
5+
6+
function sampleTangent(M::AbstractManifold, hms::HeatmapGridDensity)
7+
return sampleTangent(M, hms.densityFnc)
8+
end
9+
10+
function Base.show(io::IO, x::HeatmapGridDensity{T, H, B}) where {T, H, B}
11+
printstyled(io, "HeatmapGridDensity{"; bold = true, color = :blue)
12+
println(io)
13+
printstyled(io, " T"; color = :magenta, bold = true)
14+
println(io, " = ", T)
15+
printstyled(io, " H"; color = :magenta, bold = true)
16+
println(io, "`int = ", H)
17+
printstyled(io, " B"; color = :magenta, bold = true)
18+
println(io, " = ", B)
19+
printstyled(io, " }"; color = :blue, bold = true)
20+
println(io, "(")
21+
println(io, " data: ", size(x.data))
22+
println(
23+
io,
24+
" min/max: ",
25+
round(minimum(x.data); digits = 5),
26+
" / ",
27+
round(maximum(x.data); digits = 5),
28+
)
29+
println(io, " domain: ", size(x.domain[1]), ", ", size(x.domain[2]))
30+
println(
31+
io,
32+
" min/max: ",
33+
round(minimum(x.domain[1]); digits = 5),
34+
" / ",
35+
round(maximum(x.domain[1]); digits = 5),
36+
)
37+
println(
38+
io,
39+
" min/max: ",
40+
round(minimum(x.domain[2]); digits = 5),
41+
" / ",
42+
round(maximum(x.domain[2]); digits = 5),
43+
)
44+
println(io, " bw_factor: ", x.bw_factor)
45+
print(io, " ")
46+
show(io, x.densityFnc)
47+
return nothing
48+
end
49+
50+
Base.show(io::IO, ::MIME"text/plain", x::HeatmapGridDensity) = show(io, x)
51+
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::HeatmapGridDensity) = show(io, x)
52+
53+
"""
54+
$SIGNATURES
55+
56+
Internal function for updating HGD.
57+
58+
Notes
59+
- Likely to be used for [unstashing packed factors](@ref section_stash_unstash) via [`preambleCache`](@ref).
60+
- Counterpart to `AMP._update!` function for stashing of either MKD or HGD.
61+
"""
62+
function _update!(
63+
dst::HeatmapGridDensity{T, H, B},
64+
src::HeatmapGridDensity{T, H, B},
65+
) where {T, H, B}
66+
@assert size(dst.data) == size(src.data) "Updating HeatmapDensityGrid can only be done for data of the same size"
67+
dst.data .= src.data
68+
if !isapprox(dst.domain[1], src.domain[1])
69+
dst.domain[1] .= src.domain[1]
70+
end
71+
if !isapprox(dst.domain[2], src.domain[2])
72+
dst.domain[2] .= src.domain[2]
73+
end
74+
AMP._update!(dst.densityFnc, src.densityFnc)
75+
return dst
76+
end
77+
78+
79+
##
80+
81+
(lsg::LevelSetGridNormal)(w...; kw...) = lsg.densityFnc(w...; kw...)
82+
83+
function sampleTangent(M::AbstractManifold, lsg::LevelSetGridNormal)
84+
return sampleTangent(M, lsg.heatmap.densityFnc)
85+
end
86+
87+
function Base.show(io::IO, x::LevelSetGridNormal{T, H}) where {T, H}
88+
printstyled(io, "LevelSetGridNormal{"; bold = true, color = :blue)
89+
println(io)
90+
printstyled(io, " T"; color = :magenta, bold = true)
91+
println(io, " = ", T)
92+
printstyled(io, " H"; color = :magenta, bold = true)
93+
println(io, "`int = ", H)
94+
printstyled(io, " }"; color = :blue, bold = true)
95+
println(io, "(")
96+
println(io, " level: ", x.level)
97+
println(io, " sigma: ", x.sigma)
98+
println(io, " sig.scale: ", x.sigma_scale)
99+
println(io, " heatmap: ")
100+
show(io, x.heatmap)
101+
return nothing
102+
end
103+
104+
Base.show(io::IO, ::MIME"text/plain", x::LevelSetGridNormal) = show(io, x)
105+
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::LevelSetGridNormal) = show(io, x)
106+
107+
3108
##
4109

5110
getManifold(hgd::HeatmapGridDensity) = getManifold(hgd.densityFnc)

ext/IncrInfrApproxMinDegreeExt.jl

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
module IncrInfrApproxMinDegreeExt
2+
3+
using AMD
4+
import IncrementalInference: _ccolamd, _ccolamd!
5+
6+
# elseif ordering == :ccolamd
7+
# cons = zeros(SuiteSparse_long, length(adjMat.colptr) - 1)
8+
# cons[findall(x -> x in constraints, permuteds)] .= 1
9+
# p = Ccolamd.ccolamd(adjMat, cons)
10+
# @warn "Ccolamd is experimental in IIF at this point in time."
11+
12+
const KNOBS = 20
13+
const STATS = 20
14+
15+
16+
17+
function _ccolamd!(
18+
n_row, #SuiteSparse_long,
19+
A::AbstractVector{T}, # SuiteSparse_long},
20+
p::AbstractVector, # SuiteSparse_long},
21+
knobs::Union{Ptr{Nothing}, Vector{Float64}},
22+
stats::AbstractVector, #{SuiteSparse_long},
23+
cmember::Union{Ptr{Nothing}, <:AbstractVector}, #{SuiteSparse_long}},
24+
) where T
25+
n_col = length(p) - 1
26+
27+
if length(stats) != STATS
28+
error("stats must hcae length $STATS")
29+
end
30+
if isa(cmember, Vector) && length(cmember) != n_col
31+
error("cmember must have length $n_col")
32+
end
33+
34+
Alen = AMD.ccolamd_l_recommended(length(A), n_row, n_col)
35+
resize!(A, Alen)
36+
37+
for i in eachindex(A)
38+
A[i] -= 1
39+
end
40+
for i in eachindex(p)
41+
p[i] -= 1
42+
end
43+
err = AMD.ccolamd_l( # ccolamd_l
44+
n_row,
45+
n_col,
46+
Alen,
47+
A,
48+
p,
49+
knobs,
50+
stats,
51+
cmember
52+
)
53+
54+
if err == 0
55+
AMD.ccolamd_l_report(stats)
56+
error("call to ccolamd return with error code $(stats[4])")
57+
end
58+
59+
for i in eachindex(p)
60+
p[i] += 1
61+
end
62+
63+
pop!(p) # remove last zero from pivoting vector
64+
return p
65+
end
66+
67+
function _ccolamd!(
68+
n_row,
69+
A::AbstractVector{T1}, #SuiteSparse_long},
70+
p::AbstractVector{<:Real}, # {SuiteSparse_long},
71+
cmember::Union{Ptr{Nothing}, <:AbstractVector{T}}, # SuiteSparse_long
72+
) where {T1<:Real, T}
73+
n_col = length(p) - 1
74+
75+
if length(cmember) != n_col
76+
error("cmember must have length $n_col")
77+
end
78+
79+
Alen = AMD.ccolamd_l_recommended(length(A), n_row, n_col)
80+
resize!(A, Alen)
81+
stats = zeros(T1, STATS)
82+
return _ccolamd!(n_row, A, p, C_NULL, stats, cmember)
83+
end
84+
85+
# function _ccolamd!(
86+
# n_row,
87+
# A::AbstractVector{T}, # ::Vector{SuiteSparse_long},
88+
# p::AbstractVector, # ::Vector{SuiteSparse_long},
89+
# constraints = zeros(T,length(p) - 1), # SuiteSparse_long,
90+
# ) where T
91+
# n_col = length(p) - 1
92+
# return _ccolamd!(n_row, A, p, constraints)
93+
# end
94+
95+
_ccolamd(n_row,A,p,constraints) = _ccolamd!(n_row, copy(A), copy(p), constraints)
96+
_ccolamd(biadjMat, constraints) = _ccolamd(size(biadjMat, 1), biadjMat.rowval, biadjMat.colptr, constraints)
97+
98+
99+
100+
end

0 commit comments

Comments
 (0)