Skip to content

Commit

Permalink
Merge branch 'master' into 23Q2/test/restore3alttests
Browse files Browse the repository at this point in the history
  • Loading branch information
dehann authored Sep 5, 2023
2 parents c5059b4 + 9e320bc commit 008ab5b
Show file tree
Hide file tree
Showing 37 changed files with 774 additions and 614 deletions.
7 changes: 5 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Additional NEWS on IncrementalInference.jl Releases
# NEWS on IncrementalInference.jl Releases

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.
- https://github.com/JuliaRobotics/IncrementalInference.jl/milestones?state=closed
Expand All @@ -13,8 +13,11 @@ The list below highlights breaking changes according to normal semver workflow -

# Changes in v0.34

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

# Changes in v0.33

Expand Down
26 changes: 14 additions & 12 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "IncrementalInference"
uuid = "904591bb-b899-562f-9e6f-b8df64c7d480"
keywords = ["MM-iSAMv2", "Bayes tree", "junction tree", "Bayes network", "variable elimination", "graphical models", "SLAM", "inference", "sum-product", "belief-propagation"]
desc = "Implements the Multimodal-iSAMv2 algorithm."
version = "0.34.0"
version = "0.34.1"

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

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

[extensions]
DiffEqFactorExt = "DifferentialEquations"
GadflyExt = "Gadfly"
InteractiveUtilsExt = "InteractiveUtils"
InterpolationsExt = "Interpolations"
IncrInfrApproxMinDegreeExt = "AMD"
IncrInfrDiffEqFactorExt = "DifferentialEquations"
IncrInfrFluxFactorsExt = "Flux"
IncrInfrGadflyExt = "Gadfly"
IncrInfrInteractiveUtilsExt = "InteractiveUtils"
IncrInfrInterpolationsExt = "Interpolations"

[compat]
ApproxManifoldProducts = "0.7"
ApproxManifoldProducts = "0.7, 0.8"
BSON = "0.2, 0.3"
BlockArrays = "0.16"
Combinatorics = "1.0"
DataStructures = "0.16, 0.17, 0.18"
DelimitedFiles = "1"
DistributedFactorGraphs = "0.21, 0.22"
DistributedFactorGraphs = "0.23"
Distributions = "0.24, 0.25"
DocStringExtensions = "0.8, 0.9"
FileIO = "1"
Expand All @@ -88,17 +91,16 @@ PrecompileTools = "1"
ProgressMeter = "1"
RecursiveArrayTools = "2.31.1"
Reexport = "1"
Requires = "1"
SparseDiffTools = "2"
StaticArrays = "1"
StatsBase = "0.32, 0.33, 0.34"
StructTypes = "1"
TensorCast = "0.3.3, 0.4"
TimeZones = "1.3.1"
julia = "1.8"
julia = "1.9"

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

[targets]
test = ["DifferentialEquations", "Flux", "Graphs", "Manopt", "InteractiveUtils", "Interpolations", "LineSearches", "Pkg", "Rotations", "Test", "Zygote"]
test = ["AMD", "DifferentialEquations", "Flux", "Graphs", "Manopt", "InteractiveUtils", "Interpolations", "LineSearches", "Pkg", "Rotations", "Test", "Zygote"]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

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

using Base64

import Base: convert

function _serializeFluxModelBase64(model::Flux.Chain)
io = IOBuffer()
Expand Down
105 changes: 105 additions & 0 deletions ext/HeatmapSampler.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,110 @@
# heatmap sampler (experimental)


(hmd::HeatmapGridDensity)(w...; kw...) = hmd.densityFnc(w...; kw...)

function sampleTangent(M::AbstractManifold, hms::HeatmapGridDensity)
return sampleTangent(M, hms.densityFnc)
end

function Base.show(io::IO, x::HeatmapGridDensity{T, H, B}) where {T, H, B}
printstyled(io, "HeatmapGridDensity{"; bold = true, color = :blue)
println(io)
printstyled(io, " T"; color = :magenta, bold = true)
println(io, " = ", T)
printstyled(io, " H"; color = :magenta, bold = true)
println(io, "`int = ", H)
printstyled(io, " B"; color = :magenta, bold = true)
println(io, " = ", B)
printstyled(io, " }"; color = :blue, bold = true)
println(io, "(")
println(io, " data: ", size(x.data))
println(
io,
" min/max: ",
round(minimum(x.data); digits = 5),
" / ",
round(maximum(x.data); digits = 5),
)
println(io, " domain: ", size(x.domain[1]), ", ", size(x.domain[2]))
println(
io,
" min/max: ",
round(minimum(x.domain[1]); digits = 5),
" / ",
round(maximum(x.domain[1]); digits = 5),
)
println(
io,
" min/max: ",
round(minimum(x.domain[2]); digits = 5),
" / ",
round(maximum(x.domain[2]); digits = 5),
)
println(io, " bw_factor: ", x.bw_factor)
print(io, " ")
show(io, x.densityFnc)
return nothing
end

Base.show(io::IO, ::MIME"text/plain", x::HeatmapGridDensity) = show(io, x)
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::HeatmapGridDensity) = show(io, x)

"""
$SIGNATURES
Internal function for updating HGD.
Notes
- Likely to be used for [unstashing packed factors](@ref section_stash_unstash) via [`preambleCache`](@ref).
- Counterpart to `AMP._update!` function for stashing of either MKD or HGD.
"""
function _update!(
dst::HeatmapGridDensity{T, H, B},
src::HeatmapGridDensity{T, H, B},
) where {T, H, B}
@assert size(dst.data) == size(src.data) "Updating HeatmapDensityGrid can only be done for data of the same size"
dst.data .= src.data
if !isapprox(dst.domain[1], src.domain[1])
dst.domain[1] .= src.domain[1]
end
if !isapprox(dst.domain[2], src.domain[2])
dst.domain[2] .= src.domain[2]
end
AMP._update!(dst.densityFnc, src.densityFnc)
return dst
end


##

(lsg::LevelSetGridNormal)(w...; kw...) = lsg.densityFnc(w...; kw...)

function sampleTangent(M::AbstractManifold, lsg::LevelSetGridNormal)
return sampleTangent(M, lsg.heatmap.densityFnc)
end

function Base.show(io::IO, x::LevelSetGridNormal{T, H}) where {T, H}
printstyled(io, "LevelSetGridNormal{"; bold = true, color = :blue)
println(io)
printstyled(io, " T"; color = :magenta, bold = true)
println(io, " = ", T)
printstyled(io, " H"; color = :magenta, bold = true)
println(io, "`int = ", H)
printstyled(io, " }"; color = :blue, bold = true)
println(io, "(")
println(io, " level: ", x.level)
println(io, " sigma: ", x.sigma)
println(io, " sig.scale: ", x.sigma_scale)
println(io, " heatmap: ")
show(io, x.heatmap)
return nothing
end

Base.show(io::IO, ::MIME"text/plain", x::LevelSetGridNormal) = show(io, x)
Base.show(io::IO, ::MIME"application/prs.juno.inline", x::LevelSetGridNormal) = show(io, x)


##

getManifold(hgd::HeatmapGridDensity) = getManifold(hgd.densityFnc)
Expand Down
100 changes: 100 additions & 0 deletions ext/IncrInfrApproxMinDegreeExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
module IncrInfrApproxMinDegreeExt

using AMD
import IncrementalInference: _ccolamd, _ccolamd!

# elseif ordering == :ccolamd
# cons = zeros(SuiteSparse_long, length(adjMat.colptr) - 1)
# cons[findall(x -> x in constraints, permuteds)] .= 1
# p = Ccolamd.ccolamd(adjMat, cons)
# @warn "Ccolamd is experimental in IIF at this point in time."

const KNOBS = 20
const STATS = 20



function _ccolamd!(
n_row, #SuiteSparse_long,
A::AbstractVector{T}, # SuiteSparse_long},
p::AbstractVector, # SuiteSparse_long},
knobs::Union{Ptr{Nothing}, Vector{Float64}},
stats::AbstractVector, #{SuiteSparse_long},
cmember::Union{Ptr{Nothing}, <:AbstractVector}, #{SuiteSparse_long}},
) where T
n_col = length(p) - 1

if length(stats) != STATS
error("stats must hcae length $STATS")
end
if isa(cmember, Vector) && length(cmember) != n_col
error("cmember must have length $n_col")
end

Alen = AMD.ccolamd_l_recommended(length(A), n_row, n_col)
resize!(A, Alen)

for i in eachindex(A)
A[i] -= 1
end
for i in eachindex(p)
p[i] -= 1
end
err = AMD.ccolamd_l( # ccolamd_l
n_row,
n_col,
Alen,
A,
p,
knobs,
stats,
cmember
)

if err == 0
AMD.ccolamd_l_report(stats)
error("call to ccolamd return with error code $(stats[4])")
end

for i in eachindex(p)
p[i] += 1
end

pop!(p) # remove last zero from pivoting vector
return p
end

function _ccolamd!(
n_row,
A::AbstractVector{T1}, #SuiteSparse_long},
p::AbstractVector{<:Real}, # {SuiteSparse_long},
cmember::Union{Ptr{Nothing}, <:AbstractVector{T}}, # SuiteSparse_long
) where {T1<:Real, T}
n_col = length(p) - 1

if length(cmember) != n_col
error("cmember must have length $n_col")
end

Alen = AMD.ccolamd_l_recommended(length(A), n_row, n_col)
resize!(A, Alen)
stats = zeros(T1, STATS)
return _ccolamd!(n_row, A, p, C_NULL, stats, cmember)
end

# function _ccolamd!(
# n_row,
# A::AbstractVector{T}, # ::Vector{SuiteSparse_long},
# p::AbstractVector, # ::Vector{SuiteSparse_long},
# constraints = zeros(T,length(p) - 1), # SuiteSparse_long,
# ) where T
# n_col = length(p) - 1
# return _ccolamd!(n_row, A, p, constraints)
# end

_ccolamd(n_row,A,p,constraints) = _ccolamd!(n_row, copy(A), copy(p), constraints)
_ccolamd(biadjMat, constraints) = _ccolamd(size(biadjMat, 1), biadjMat.rowval, biadjMat.colptr, constraints)



end
Loading

0 comments on commit 008ab5b

Please sign in to comment.