Skip to content

Commit 6c75ee9

Browse files
committed
common CalcFactor file
1 parent 4e6bfff commit 6c75ee9

File tree

6 files changed

+113
-97
lines changed

6 files changed

+113
-97
lines changed

src/Deprecated.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ end
124124
## Deprecate code below before v0.35
125125
##==============================================================================
126126

127+
# should probably deprecate the abstract type approach?
128+
abstract type _AbstractThreadModel end
129+
130+
"""
131+
$(TYPEDEF)
132+
"""
133+
struct SingleThreaded <: _AbstractThreadModel end
134+
# """
135+
# $(TYPEDEF)
136+
# """
137+
# struct MultiThreaded <: _AbstractThreadModel end
127138

128139

129140
function _solveLambdaNumeric(

src/IncrementalInference.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ include("ExportAPI.jl")
126126
include("entities/SolverParams.jl")
127127

128128
include("entities/HypoRecipe.jl")
129+
include("entities/CalcFactor.jl")
129130
include("entities/FactorOperationalMemory.jl")
130131

131132
include("Factors/GenericMarginal.jl")

src/entities/CalcFactor.jl

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
abstract type AbstractMaxMixtureSolver end
3+
4+
5+
"""
6+
$TYPEDEF
7+
8+
User factor interface method for computing the residual values of factors.
9+
10+
Notes
11+
- Also see #467 on API consolidation
12+
13+
```julia
14+
function (cf::CalcFactor{<:LinearRelative})(res::AbstractVector{<:Real}, z, xi, xj)
15+
cf.variablelist
16+
cf.cache
17+
# generic on-manifold residual function
18+
return distance(z, distance(xj, xi))
19+
end
20+
```
21+
22+
DevNotes
23+
- Follow the Github project in IIF to better consolidate CCW FMD CPT CF CFM
24+
25+
Related
26+
27+
[`CalcFactorMahalanobis`](@ref), [`CommonConvWrapper`](@ref)
28+
"""
29+
struct CalcFactor{
30+
FT <: AbstractFactor,
31+
X,
32+
C,
33+
VT <: Tuple,
34+
M <: AbstractManifold
35+
}
36+
""" the interface compliant user object functor containing the data and logic """
37+
factor::FT
38+
""" what is the sample (particle) id for which the residual is being calculated """
39+
_sampleIdx::Int
40+
""" legacy support for variable values old functor residual functions.
41+
TBD, this is still being used by DERelative factors. """
42+
_legacyParams::X
43+
""" allow threading for either sampling or residual calculations (workaround for thread yield issue) """
44+
_allowThreads::Bool
45+
""" user cache of arbitrary type, overload the [`preambleCache`](@ref) function. NOT YET THREADSAFE """
46+
cache::C
47+
48+
## TODO Consolidation WIP with FactorMetadata
49+
# full list of variables connected to the factor
50+
# TODO make sure this list is of the active hypo only
51+
fullvariables::VT # Vector{<:DFGVariable} # FIXME change to tuple for better type stability
52+
# which index is being solved for?
53+
solvefor::Int
54+
manifold::M
55+
end
56+
57+
58+
59+
"""
60+
$TYPEDEF
61+
62+
Internal parametric extension to [`CalcFactor`](@ref) used for buffering measurement and calculating Mahalanobis distance
63+
64+
Related
65+
66+
[`CalcFactor`](@ref)
67+
"""
68+
struct CalcFactorMahalanobis{N, D, L, S <: Union{Nothing, AbstractMaxMixtureSolver}}
69+
faclbl::Symbol
70+
calcfactor!::CalcFactor
71+
varOrder::Vector{Symbol}
72+
meas::NTuple{N, <:AbstractArray}
73+
::NTuple{N, SMatrix{D, D, Float64, L}}
74+
specialAlg::S
75+
end
76+
77+
78+
79+
80+
struct CalcFactorManopt{
81+
D,
82+
L,
83+
FT <: AbstractFactor,
84+
M <: AbstractManifold,
85+
MEAS <: AbstractArray,
86+
}
87+
faclbl::Symbol
88+
calcfactor!::CalcFactor{FT, Nothing, Nothing, Tuple{}, M}
89+
varOrder::Vector{Symbol}
90+
varOrderIdxs::Vector{Int}
91+
meas::MEAS
92+
::SMatrix{D, D, Float64, L}
93+
sqrt_iΣ::SMatrix{D, D, Float64, L}
94+
end
95+
96+

src/entities/FactorOperationalMemory.jl

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,4 @@
11

2-
"""
3-
$TYPEDEF
4-
5-
User factor interface method for computing the residual values of factors.
6-
7-
Notes
8-
- Also see #467 on API consolidation
9-
10-
```julia
11-
function (cf::CalcFactor{<:LinearRelative})(res::AbstractVector{<:Real}, z, xi, xj)
12-
cf.variablelist
13-
cf.cache
14-
# generic on-manifold residual function
15-
return distance(z, distance(xj, xi))
16-
end
17-
```
18-
19-
DevNotes
20-
- Follow the Github project in IIF to better consolidate CCW FMD CPT CF CFM
21-
22-
Related
23-
24-
[`CalcFactorMahalanobis`](@ref), [`CommonConvWrapper`](@ref)
25-
"""
26-
struct CalcFactor{
27-
FT <: AbstractFactor,
28-
X,
29-
C,
30-
VT <: Tuple,
31-
M <: AbstractManifold
32-
}
33-
""" the interface compliant user object functor containing the data and logic """
34-
factor::FT
35-
""" what is the sample (particle) id for which the residual is being calculated """
36-
_sampleIdx::Int
37-
""" legacy support for variable values old functor residual functions.
38-
TBD, this is still being used by DERelative factors. """
39-
_legacyParams::X
40-
""" allow threading for either sampling or residual calculations (workaround for thread yield issue) """
41-
_allowThreads::Bool
42-
""" user cache of arbitrary type, overload the [`preambleCache`](@ref) function. NOT YET THREADSAFE """
43-
cache::C
44-
45-
## TODO Consolidation WIP with FactorMetadata
46-
# full list of variables connected to the factor
47-
# TODO make sure this list is of the active hypo only
48-
fullvariables::VT # Vector{<:DFGVariable} # FIXME change to tuple for better type stability
49-
# which index is being solved for?
50-
solvefor::Int
51-
manifold::M
52-
end
53-
54-
# should probably deprecate the abstract type approach?
55-
abstract type _AbstractThreadModel end
56-
57-
"""
58-
$(TYPEDEF)
59-
"""
60-
struct SingleThreaded <: _AbstractThreadModel end
61-
"""
62-
$(TYPEDEF)
63-
"""
64-
struct MultiThreaded <: _AbstractThreadModel end
65-
662

673

684
"""

src/parametric/services/ParametricManoptDev.jl

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,7 @@ using SparseArrays
99

1010
##
1111

12-
struct CalcFactorManopt{
13-
D,
14-
L,
15-
FT <: AbstractFactor,
16-
M <: AbstractManifold,
17-
MEAS <: AbstractArray,
18-
}
19-
faclbl::Symbol
20-
calcfactor!::CalcFactor{FT, Nothing, Nothing, Tuple{}, M}
21-
varOrder::Vector{Symbol}
22-
varOrderIdxs::Vector{Int}
23-
meas::MEAS
24-
::SMatrix{D, D, Float64, L}
25-
sqrt_iΣ::SMatrix{D, D, Float64, L}
26-
end
12+
2713

2814
function CalcFactorManopt(fct::DFGFactor, varIntLabel)
2915
fac_func = getFactorType(fct)

src/parametric/services/ParametricUtils.jl

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,7 @@
22
## FactorOperationalMemory for parametric, TODO move back to FactorOperationalMemory.jl
33
## ================================================================================================
44

5-
abstract type AbstractMaxMixtureSolver end
65

7-
"""
8-
$TYPEDEF
9-
10-
Internal parametric extension to [`CalcFactor`](@ref) used for buffering measurement and calculating Mahalanobis distance
11-
12-
Related
13-
14-
[`CalcFactor`](@ref)
15-
"""
16-
struct CalcFactorMahalanobis{N, D, L, S <: Union{Nothing, AbstractMaxMixtureSolver}}
17-
faclbl::Symbol
18-
calcfactor!::CalcFactor
19-
varOrder::Vector{Symbol}
20-
meas::NTuple{N, <:AbstractArray}
21-
::NTuple{N, SMatrix{D, D, Float64, L}}
22-
specialAlg::S
23-
end
246
# struct CalcFactorMahalanobis{CF<:CalcFactor, S<:Union{Nothing,AbstractMaxMixtureSolver}, N}
257
# calcfactor!::CF
268
# varOrder::Vector{Symbol}
@@ -437,6 +419,10 @@ function (gsc::GraphSolveContainer)(Xc::Vector{T}) where {T <: Real}
437419
return obj / 2
438420
end
439421

422+
423+
# FIXME, deprecate and improve legacy use of `MultiThreaded` type
424+
struct MultiThreaded end
425+
440426
function (gsc::GraphSolveContainer)(Xc::Vector{T}, ::MultiThreaded) where {T <: Real}
441427
#
442428
buffs = getGraphSolveCache!(gsc, T)

0 commit comments

Comments
 (0)