JuliaRobotics / IncrementalInference.jl

@@ -158,7 +158,8 @@
Loading
158 158
  domain::Tuple{Vector{Float64}, Vector{Float64}}
159 159
  hint_callback::String
160 160
  bw_factor::Float64
161 -
  densityFnc::String
161 +
  N::Int
162 +
  # densityFnc::String # TODO rather rebuild at unpack
162 163
end
163 164
164 165
@@ -171,13 +172,13 @@
Loading
171 172
  data__ = map(x->collect(x), data_)
172 173
  @cast data[i,j] := data__[j][i]
173 174
  _data__ = collect(data)
174 -
  densFnc = convert(SamplableBelief, obj.densityFnc)
175 +
  # densFnc = convert(SamplableBelief, obj.densityFnc)
175 176
  # build the final object, misses the hint...
176 177
  HeatmapGridDensity( _data__,
177 178
                      obj.domain,
178 179
                      obj.hint_callback == "" ? nothing : nothing,
179 -
                      obj.bw_factor,
180 -
                      densFnc )
180 +
                      obj.bw_factor;
181 +
                      N=obj.N )
181 182
end
182 183
183 184
function convert( ::Union{Type{<:PackedSamplableBelief},Type{<:PackedHeatmapGridDensity}}, 
@@ -185,14 +186,15 @@
Loading
185 186
  #
186 187
  data_ = obj.data
187 188
  @cast data[j][i] := data_[i,j]
188 -
  str = convert(SamplableBelief, obj.densityFnc)
189 +
  # str = convert(SamplableBelief, obj.densityFnc)
190 +
  N = Npts(obj.densityFnc)
189 191
  # TODO misses the hint...
190 192
  PackedHeatmapGridDensity( "IncrementalInference.PackedHeatmapGridDensity",
191 193
                            data,
192 194
                            obj.domain,
193 195
                            "", 
194 196
                            obj.bw_factor,
195 -
                            str )
197 +
                            N )
196 198
end
197 199
198 200

@@ -33,11 +33,14 @@
Loading
33 33
- Density approximation is constructed on Guassian measurement assumption of level set and sigma variation.
34 34
- Assume data is on a regular grid on TranslationGroup(2)
35 35
  - Assume on early implementation `x_grid, y_grid = domain`
36 +
- Serialization currently does not store the hint callback.
37 +
- To save space, serialization does not store the internal density, but rather reconstructs at unpacking.
36 38
37 39
DevNotes:
38 40
- Generalize to scalar fields on any Manifold.
39 41
- Generalize to vector fields if interpolation is sensible.
40 42
- TODO standardize with AliasingScalarSampler see IIF #1341
43 +
- TODO store the hint function (at least any easy cases)
41 44
"""
42 45
struct HeatmapGridDensity{T <: Real, H <: Union{<:Function, Nothing}, B <: Union{ManifoldKernelDensity, BallTreeDensity}}
43 46
  """intensity data, on regular grid"""

@@ -121,7 +121,8 @@
Loading
121 121
                                      measurement,
122 122
                                      pts::Tuple;
123 123
                                      tfg::AbstractDFG = initfg(),
124 -
                                      _blockRecursion::Bool=false )
124 +
                                      _blockRecursion::Bool=false,
125 +
                                      doTime::Bool=false  )
125 126
  #
126 127
127 128
  # build a new temporary graph
@@ -135,9 +136,14 @@
Loading
135 136
    cfo = CalcFactor(_getCCW(_dfgfct))
136 137
    sampleFactor(cfo, 1)[1]
137 138
  end
138 -
139 +
  
139 140
  # assume a single sample point is being run
140 -
  return calcFactorResidual(_dfgfct, _measurement, pts...) 
141 +
  return if doTime
142 +
    @time res = calcFactorResidual(_dfgfct, _measurement, pts...)
143 +
    res
144 +
  else
145 +
    calcFactorResidual(_dfgfct, _measurement, pts...)
146 +
  end
141 147
end
142 148
143 149

@@ -61,7 +61,7 @@
Loading
61 61
# Helper function to construct HGD
62 62
function HeatmapGridDensity(data::AbstractMatrix{<:Real}, 
63 63
                            domain::Tuple{<:AbstractVector{<:Real},<:AbstractVector{<:Real}},
64 -
                            hist_callback::Union{<:Function, Nothing}=nothing,
64 +
                            hint_callback::Union{<:Function, Nothing}=nothing,
65 65
                            bw_factor::Real=0.7;  # kde spread between domain points 
66 66
                            N::Int=10000  )
67 67
  #
@@ -101,7 +101,7 @@
Loading
101 101
  density = ManifoldKernelDensity(TranslationGroup(Ndim(bel)), bel)
102 102
103 103
  # return `<:SamplableBelief` object
104 -
  HeatmapGridDensity(data, domain, hist_callback, bw_factor, density)
104 +
  HeatmapGridDensity(data, domain, hint_callback, bw_factor, density)
105 105
end
106 106
107 107
@@ -111,7 +111,7 @@
Loading
111 111
                            level::Real,
112 112
                            sigma::Real;
113 113
                            sigma_scale::Real=3,
114 -
                            hist_callback::Union{<:Function, Nothing}=nothing,
114 +
                            hint_callback::Union{<:Function, Nothing}=nothing,
115 115
                            bw_factor::Real=0.7,  # kde spread between domain points 
116 116
                            N::Int=10000  )
117 117
  #
@@ -128,7 +128,7 @@
Loading
128 128
  #   l = 1/2 (h-z/σ)^2
129 129
  #   masked_roi = 0 .< κ^2 - l
130 130
  
131 -
  hgd = HeatmapGridDensity(data, domain, hist_callback, bw_factor; N=N)
131 +
  hgd = HeatmapGridDensity(data, domain, hint_callback, bw_factor; N=N)
132 132
133 133
  LevelSetGridNormal(level, sigma, float(sigma_scale), hgd)
134 134
end

@@ -29,7 +29,7 @@
Loading
29 29
30 30
## unpack converters------------------------------------------------------------
31 31
32 -
32 +
# FIXME see #1424
33 33
function convert(
34 34
            ::Type{GenericFunctionNodeData{CommonConvWrapper{F}}},
35 35
            packed::GenericFunctionNodeData{P} ) where {F <: AbstractFactor, P <: PackedInferenceType}
Files Coverage
src 77.17%
Project Totals (67 files) 77.17%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading