Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion IncrementalInference/ext/FluxModelsSerialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function DFG.unpackDistribution(obj::PackedFluxModelsDistribution)
end

function Base.convert(
::Union{Type{<:PackedSamplableBelief}, Type{<:PackedFluxModelsDistribution}},
::Union{Type{<:PackedBelief}, Type{<:PackedFluxModelsDistribution}},
obj::FluxModelsDistribution,
)
#
Expand Down
4 changes: 2 additions & 2 deletions IncrementalInference/ext/IncrInfrDiffEqFactorExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ _maketuplebeyond2args = (w1 = nothing, w2 = nothing, w3_...) -> (w3_...,)

function DERelative(
Xi::AbstractVector{<:DFGVariable},
domain::Type{<:InferenceVariable},
domain::Type{<:VariableStateType},
f::Function,
data = () -> ();
dt::Real = 1,
Expand All @@ -94,7 +94,7 @@ end
function DERelative(
dfg::AbstractDFG,
labels::AbstractVector{Symbol},
domain::Type{<:InferenceVariable},
domain::Type{<:VariableStateType},
f::Function,
data = () -> ();
Xi::AbstractArray{<:DFGVariable} = getVariable.(dfg, labels),
Expand Down
7 changes: 3 additions & 4 deletions IncrementalInference/ext/IncrInfrInteractiveUtilsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module IncrInfrInteractiveUtilsExt

using InteractiveUtils
using DocStringExtensions
using IncrementalInference: InferenceVariable, AbstractPrior, AbstractRelativeMinimize, AbstractManifoldMinimize
using IncrementalInference: VariableStateType, AbstractPrior, RelativeObservation
# using IncrementalInference: getCurrentWorkspaceFactors, getCurrentWorkspaceVariables, listTypeTree
import IncrementalInference: getCurrentWorkspaceFactors, getCurrentWorkspaceVariables, listTypeTree

Expand All @@ -19,8 +19,7 @@ Return all factors currently registered in the workspace.
function getCurrentWorkspaceFactors()
return [
InteractiveUtils.subtypes(AbstractPrior)...,
# InteractiveUtils.subtypes(AbstractRelativeRoots)...,
InteractiveUtils.subtypes(AbstractRelativeMinimize)...,
InteractiveUtils.subtypes(RelativeObservation)...,
]
end

Expand All @@ -30,7 +29,7 @@ end
Return all variables currently registered in the workspace.
"""
function getCurrentWorkspaceVariables()
return InteractiveUtils.subtypes(InferenceVariable)
return InteractiveUtils.subtypes(VariableStateType)
end

function _listTypeTree(mytype, printlevel::Int)
Expand Down
38 changes: 38 additions & 0 deletions IncrementalInference/src/Deprecated.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
## ================================================================================================
## Deprecated in v0.36
## ================================================================================================

#TODO this looks like dead code, should be removed
# TODO deprecate testshuffle
function _checkErrorCCWNumerics(
ccwl::Union{CommonConvWrapper{F}, CommonConvWrapper{Mixture{N_, F, S, T}}},
testshuffle::Bool = false,
) where {N_, F <: AbstractRelativeMinimize, S, T}
return nothing
end
function _checkErrorCCWNumerics(
ccwl::Union{CommonConvWrapper{F}, CommonConvWrapper{Mixture{N_, F, S, T}}},
testshuffle::Bool = false,
) where {N_, F <: AbstractManifoldMinimize, S, T}
return nothing
end

#TODO this looks like dead code, should be removed
function _perturbIfNecessary(
fcttype::Union{F, <:Mixture{N_, F, S, T}},
len::Int = 1,
perturbation::Real = 1e-10,
) where {N_, F <: AbstractRelativeMinimize, S, T}
return 0
end

function _perturbIfNecessary(
fcttype::Union{F, <:Mixture{N_, F, S, T}},
len::Int = 1,
perturbation::Real = 1e-10,
) where {N_, F <: AbstractManifoldMinimize, S, T}
return 0
end
#


## ================================================================================================
## ================================================================================================

Expand Down
4 changes: 2 additions & 2 deletions IncrementalInference/src/ExportAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ export CSMHistory,

# general types for softtyping of variable nodes
BeliefArray,
InferenceVariable,
VariableStateType,
ContinuousScalar,
SamplableBelief,
PackedSamplableBelief,
PackedBelief,
Prior,
PackedPrior,
MsgPrior,
Expand Down
8 changes: 4 additions & 4 deletions IncrementalInference/src/Factors/EuclidDistance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $(TYPEDEF)

Default linear offset between two scalar variables.
"""
struct EuclidDistance{T <: SamplableBelief} <: AbstractManifoldMinimize # AbstractRelativeMinimize
struct EuclidDistance{T <: SamplableBelief} <: RelativeObservation
Z::T
end

Expand All @@ -29,13 +29,13 @@ Serialization type for `EuclidDistance` binary factor.
"""
Base.@kwdef mutable struct PackedEuclidDistance <: AbstractPackedFactor
_type::String
Z::PackedSamplableBelief
Z::PackedBelief
end

function convert(::Type{PackedEuclidDistance}, d::EuclidDistance)
return PackedEuclidDistance(
"/application/JuliaLang/PackedSamplableBelief",
convert(PackedSamplableBelief, d.Z),
"/application/JuliaLang/PackedBelief",
convert(PackedBelief, d.Z),
)
end

Expand Down
10 changes: 5 additions & 5 deletions IncrementalInference/src/Factors/GenericFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export ManifoldFactor
struct ManifoldFactor{
M <: AbstractManifold,
T <: SamplableBelief
} <: AbstractManifoldMinimize
} <: RelativeObservation
M::M
Z::T
end
Expand Down Expand Up @@ -106,7 +106,7 @@ end


# Adjoints defined in ApproxManifoldProducts
struct AdFactor{F <: AbstractManifoldMinimize} <: AbstractManifoldMinimize
struct AdFactor{F <: RelativeObservation} <: RelativeObservation
factor::F
end

Expand Down Expand Up @@ -229,7 +229,7 @@ end
Base.@kwdef mutable struct PackedManifoldPrior <: AbstractPackedFactor
varType::String
p::Vector{Float64} #NOTE This is a fixed point from where the measurement `Z` likely stored as a coordinate
Z::PackedSamplableBelief
Z::PackedBelief
end

function convert(
Expand All @@ -243,7 +243,7 @@ function convert(
c = AMP.makeCoordsFromPoint(obj.M, obj.p)

# TODO convert all distributions to JSON
Zst = convert(PackedSamplableBelief, obj.Z) # String
Zst = convert(PackedBelief, obj.Z) # String

return PackedManifoldPrior(varT, c, Zst)
end
Expand All @@ -254,7 +254,7 @@ function convert(
)
#

# piggy back on serialization of InferenceVariable rather than try serialize anything Manifolds.jl
# piggy back on serialization of VariableStateType rather than try serialize anything Manifolds.jl
M = DFG.getTypeFromSerializationModule(obj.varType) |> getManifold

# TODO this is too excessive
Expand Down
2 changes: 1 addition & 1 deletion IncrementalInference/src/Factors/GenericMarginal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
$(TYPEDEF)
"""
mutable struct GenericMarginal <: AbstractManifoldMinimize # AbstractRelativeRoots
mutable struct GenericMarginal <: RelativeObservation # AbstractRelativeRoots
Zij::Array{Float64, 1}
Cov::Array{Float64, 1}
W::Array{Float64, 1}
Expand Down
6 changes: 3 additions & 3 deletions IncrementalInference/src/Factors/LinearRelative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Default linear offset between two scalar variables.
X_2 = X_1 + η_Z
```
"""
struct LinearRelative{N, T <: SamplableBelief} <: AbstractManifoldMinimize # AbstractRelativeMinimize
struct LinearRelative{N, T <: SamplableBelief} <: RelativeObservation
Z::T
end

Expand Down Expand Up @@ -60,10 +60,10 @@ $(TYPEDEF)
Serialization type for `LinearRelative` binary factor.
"""
Base.@kwdef mutable struct PackedLinearRelative <: AbstractPackedFactor
Z::PackedSamplableBelief
Z::PackedBelief
end
function convert(::Type{PackedLinearRelative}, d::LinearRelative)
return PackedLinearRelative(convert(PackedSamplableBelief, d.Z))
return PackedLinearRelative(convert(PackedBelief, d.Z))
end
function convert(::Type{LinearRelative}, d::PackedLinearRelative)
return LinearRelative(convert(SamplableBelief, d.Z))
Expand Down
10 changes: 5 additions & 5 deletions IncrementalInference/src/Factors/Mixture.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ Base.@kwdef mutable struct PackedMixture <: AbstractPackedFactor
# store the packed type for later unpacking
F_::String
S::Vector{String}
components::Vector{PackedSamplableBelief}
diversity::PackedSamplableBelief
components::Vector{PackedBelief}
diversity::PackedBelief
end

function convert(::Type{<:PackedMixture}, obj::Mixture{N, F, S, T}) where {N, F, S, T}
allcomp = PackedSamplableBelief[]
allcomp = PackedBelief[]
for val in obj.components
dtr_ = convert(PackedSamplableBelief, val)
dtr_ = convert(PackedBelief, val)
# FIXME ON FIRE, likely to be difficult for non-standard "Samplable" types -- e.g. Flux models in RoME
push!(allcomp, dtr_)
end
Expand All @@ -186,7 +186,7 @@ function convert(::Type{<:PackedMixture}, obj::Mixture{N, F, S, T}) where {N, F,
pm = convert(DFG.convertPackedType(obj.mechanics), obj.mechanics)
end
sT = string(typeof(pm))
dvst = convert(PackedSamplableBelief, obj.diversity)
dvst = convert(PackedBelief, obj.diversity)
return PackedMixture(N, sT, string.(collect(S)), allcomp, dvst)
end

Expand Down
4 changes: 2 additions & 2 deletions IncrementalInference/src/Factors/MsgPrior.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ getManifold(mp::MsgPrior) = mp.M
(cfo::CalcFactor{<:MsgPrior})(z, x1) = z .- x1

Base.@kwdef struct PackedMsgPrior <: AbstractPackedFactor
Z::PackedSamplableBelief
Z::PackedBelief
infoPerCoord::Vector{Float64}
end

function convert(::Type{PackedMsgPrior}, d::MsgPrior)
return PackedMsgPrior(convert(PackedSamplableBelief, d.Z), d.infoPerCoord)
return PackedMsgPrior(convert(PackedBelief, d.Z), d.infoPerCoord)
end
function convert(::Type{<:MsgPrior}, d::PackedMsgPrior)
return MsgPrior(convert(SamplableBelief, d.Z), d.infoPerCoord)
Expand Down
8 changes: 4 additions & 4 deletions IncrementalInference/src/Factors/PartialPrior.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Notes
- Future TBD, consider using `AMP.getManifoldPartial` for more general abstraction.
"""
struct PartialPrior{T <: SamplableBelief, P <: Tuple} <: AbstractPrior
varType::Type{<:InferenceVariable}
varType::Type{<:VariableStateType}
Z::T
partial::P
end
Expand All @@ -29,13 +29,13 @@ Serialization type for `PartialPrior`.
"""
Base.@kwdef struct PackedPartialPrior <: AbstractPackedFactor
varType::String
Z::PackedSamplableBelief
Z::PackedBelief
partials::Vector{Int}
end

function convert(::Type{PackedPartialPrior}, d::PartialPrior)
return PackedPartialPrior(DFG.typeModuleName(d.varType), convert(PackedSamplableBelief, d.Z), [d.partial...;])
# return PackedPartialPrior(convert(PackedSamplableBelief, d.Z), [d.partial...;])
return PackedPartialPrior(DFG.typeModuleName(d.varType), convert(PackedBelief, d.Z), [d.partial...;])
# return PackedPartialPrior(convert(PackedBelief, d.Z), [d.partial...;])
end
function convert(::Type{PartialPrior}, d::PackedPartialPrior)
return PartialPrior(DFG.getTypeFromSerializationModule(d.varType), convert(SamplableBelief, d.Z),(d.partials...,))
Expand Down
4 changes: 2 additions & 2 deletions IncrementalInference/src/Factors/PartialPriorPassThrough.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ end
Required internal density to store its type
"""
Base.@kwdef mutable struct PackedPartialPriorPassThrough <: AbstractPackedFactor
Z::PackedSamplableBelief # PackedHeatmapGridDensity
Z::PackedBelief # PackedHeatmapGridDensity
partial::Vector{Int}
end

Expand All @@ -43,7 +43,7 @@ function convert(
)
#

po = convert(PackedSamplableBelief, obj.Z)
po = convert(PackedBelief, obj.Z)
return PackedPartialPriorPassThrough(po, Int[obj.partial...])
end

Expand Down
2 changes: 1 addition & 1 deletion IncrementalInference/src/NeedsResolution.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# FIXME move to DFG
getPointDefault(V::InferenceVariable) = getPointIdentity(V)
getPointDefault(V::VariableStateType) = getPointIdentity(V)

function compare(c1::Channel, c2::Channel; skip::Vector{Symbol} = [])
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Base.@kwdef struct PackedManifoldKernelDensity <: PackedSamplableBelief
Base.@kwdef struct PackedManifoldKernelDensity <: PackedBelief
_type::String = "IncrementalInference.PackedManifoldKernelDensity"
varType::String
pts::Vector{Vector{Float64}}
Expand All @@ -8,7 +8,7 @@ Base.@kwdef struct PackedManifoldKernelDensity <: PackedSamplableBelief
infoPerCoord::Vector{Float64} = zeros(length(pts[1]))
end

Base.@kwdef struct PackedAliasingScalarSampler <: PackedSamplableBelief
Base.@kwdef struct PackedAliasingScalarSampler <: PackedBelief
_type::String = "IncrementalInference.PackedAliasingScalarSampler"
domain::Vector{Float64} = [0; 1.0]
weights::Vector{Float64} = [0.5; 0.5]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ StringThemSamplableBeliefs = Union{
}

## TODO, TBD
# Base.@kwdef struct PackedDiscreteNonParametric <: PackedSamplableBelief
# Base.@kwdef struct PackedDiscreteNonParametric <: PackedBelief
# _type::String = "IncrementalInference.PackedDiscreteNonParametric"
# end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@



Base.@kwdef mutable struct PackedHeatmapGridDensity <: PackedSamplableBelief
Base.@kwdef mutable struct PackedHeatmapGridDensity <: PackedBelief
_type::String = "IncrementalInference.PackedHeatmapGridDensity"
data::Vector{Vector{Float64}}
domain::Tuple{Vector{Float64}, Vector{Float64}}
Expand All @@ -12,7 +12,7 @@ Base.@kwdef mutable struct PackedHeatmapGridDensity <: PackedSamplableBelief
end


Base.@kwdef mutable struct PackedLevelSetGridNormal <: PackedSamplableBelief
Base.@kwdef mutable struct PackedLevelSetGridNormal <: PackedBelief
_type::String = "IncrementalInference.PackedLevelSetGridNormal"
level::Float64
sigma::Float64
Expand All @@ -22,7 +22,7 @@ Base.@kwdef mutable struct PackedLevelSetGridNormal <: PackedSamplableBelief
end


Base.@kwdef mutable struct PackedFluxModelsDistribution <: PackedSamplableBelief
Base.@kwdef mutable struct PackedFluxModelsDistribution <: PackedBelief
# standardized _type field
_type::String
# shape of the input data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ getVariableType(M::TranslationGroup{TypeParameter{Tuple{N}}}) where {N} = Contin
function Base.convert(::Type{<:SamplableBelief}, ::Type{<:PackedManifoldKernelDensity})
return ManifoldKernelDensity
end
function Base.convert(::Type{<:PackedSamplableBelief}, ::Type{<:ManifoldKernelDensity})
function Base.convert(::Type{<:PackedBelief}, ::Type{<:ManifoldKernelDensity})
return PackedManifoldKernelDensity
end

Expand Down Expand Up @@ -49,7 +49,7 @@ function DFG.packDistribution(mkd::ManifoldKernelDensity)

return PackedManifoldKernelDensity(
"IncrementalInference.PackedManifoldKernelDensity",
# piggy back on InferenceVariable serialization rather than try serialize anything Manifolds.jl
# piggy back on VariableStateType serialization rather than try serialize anything Manifolds.jl
DFG.typeModuleName(getVariableType(mkd.manifold)),
[AMP.makeCoordsFromPoint(mkd.manifold, pt) for pt in pts],
getBW(mkd.belief)[:, 1],
Expand All @@ -59,7 +59,7 @@ function DFG.packDistribution(mkd::ManifoldKernelDensity)
end

function DFG.unpackDistribution(dtr::PackedManifoldKernelDensity)
# find InferenceVariable type from string (anything Manifolds.jl?)
# find VariableStateType type from string (anything Manifolds.jl?)
M = DFG.getTypeFromSerializationModule(dtr.varType) |> getManifold
vecP = [AMP.makePointFromCoords(M, pt) for pt in dtr.pts]
bw = length(dtr.bw) === 0 ? nothing : dtr.bw
Expand All @@ -79,7 +79,7 @@ function Base.convert(::Type{String}, mkd::ManifoldKernelDensity)
end

# Use general dispatch
# Base.convert(::Type{<:PackedSamplableBelief}, mkd::ManifoldKernelDensity) = convert(String, mkd)
# Base.convert(::Type{<:PackedBelief}, mkd::ManifoldKernelDensity) = convert(String, mkd)

# make module specific
# good references:
Expand Down
Loading
Loading