@@ -9,6 +9,7 @@ using Dates
99
1010using IncrementalInference
1111import IncrementalInference: getSample, getManifold, DERelative
12+ import IncrementalInference: sampleFactor
1213
1314using DocStringExtensions
1415
9495#
9596#
9697
97- # Xtra splat are variable points (X3::Matrix, X4::Matrix,...)
98+ # n-ary factor: Xtra splat are variable points (X3::Matrix, X4::Matrix,...)
9899function _solveFactorODE! (measArr, prob, u0pts, Xtra... )
99- # should more variables be included in calculation
100+ # happens when more variables (n-ary) must be included in DE solve
100101 for (xid, xtra) in enumerate (Xtra)
101102 # update the data register before ODE solver calls the function
102- prob. p[xid + 1 ][:] = Xtra[xid] [:]
103+ prob. p[xid + 1 ][:] = xtra [:]
103104 end
104105
105106 # set the initial condition
@@ -111,47 +112,47 @@ function _solveFactorODE!(measArr, prob, u0pts, Xtra...)
111112 return sol
112113end
113114
114- getSample (cf:: CalcFactor{<:DERelative} ) = error (" getSample(::CalcFactor{<:DERelative}) must still be implemented in new IIF design" )
115+ # # # output for AbstractRelative is tangents (but currently we working in coordinates for integration with DiffEqs)
116+ # # # FIXME , how to consolidate DERelative with parametric solve which currently only goes through getMeasurementParametric
117+ # function getSample(cf::CalcFactor{<:DERelative})
118+ # #
119+ # oder = cf.factor
120+
121+ # # how many trajectories to propagate?
122+ # # @show getLabel(cf.fullvariables[2]), getDimension(cf.fullvariables[2])
123+ # meas = zeros(getDimension(cf.fullvariables[2]))
124+
125+ # # pick forward or backward direction
126+ # # set boundary condition
127+ # u0pts = if cf.solvefor == 1
128+ # # backward direction
129+ # prob = oder.backwardProblem
130+ # addOp, diffOp, _, _ = AMP.buildHybridManifoldCallbacks(
131+ # convert(Tuple, getManifold(getVariableType(cf.fullvariables[1]))),
132+ # )
133+ # # FIXME use ccw.varValsAll containter?
134+ # (getBelief(cf.fullvariables[2]) |> getPoints)[cf._sampleIdx]
135+ # else
136+ # # forward backward
137+ # prob = oder.forwardProblem
138+ # # buffer manifold operations for use during factor evaluation
139+ # addOp, diffOp, _, _ = AMP.buildHybridManifoldCallbacks(
140+ # convert(Tuple, getManifold(getVariableType(cf.fullvariables[2]))),
141+ # )
142+ # # FIXME use ccw.varValsAll containter?
143+ # (getBelief(cf.fullvariables[1]) |> getPoints)[cf._sampleIdx]
144+ # end
145+
146+ # # solve likely elements
147+ # # TODO , does this respect hyporecipe ???
148+ # # TBD check if cf._legacyParams == ccw.varValsAll???
149+ # idxArr = (k -> cf._legacyParams[k][cf._sampleIdx]).(1:length(cf._legacyParams))
150+ # _solveFactorODE!(meas, prob, u0pts, _maketuplebeyond2args(idxArr...)...)
151+ # # _solveFactorODE!(meas, prob, u0pts, i, _maketuplebeyond2args(cf._legacyParams...)...)
152+
153+ # return meas, diffOp
154+ # end
115155
116- # FIXME see #1025, `multihypo=` will not work properly yet
117- function sampleFactor (cf:: CalcFactor{<:DERelative} , N:: Int = 1 )
118- #
119- oder = cf. factor
120-
121- # how many trajectories to propagate?
122- # @show getLabel(cf.fullvariables[2]), getDimension(cf.fullvariables[2])
123- meas = [zeros (getDimension (cf. fullvariables[2 ])) for _ = 1 : N]
124-
125- # pick forward or backward direction
126- # set boundary condition
127- u0pts = if cf. solvefor == 1
128- # backward direction
129- prob = oder. backwardProblem
130- addOp, diffOp, _, _ = AMP. buildHybridManifoldCallbacks (
131- convert (Tuple, getManifold (getVariableType (cf. fullvariables[1 ]))),
132- )
133- getBelief (cf. fullvariables[2 ]) |> getPoints
134- else
135- # forward backward
136- prob = oder. forwardProblem
137- # buffer manifold operations for use during factor evaluation
138- addOp, diffOp, _, _ = AMP. buildHybridManifoldCallbacks (
139- convert (Tuple, getManifold (getVariableType (cf. fullvariables[2 ]))),
140- )
141- getBelief (cf. fullvariables[1 ]) |> getPoints
142- end
143-
144- # solve likely elements
145- for i = 1 : N
146- # TODO , does this respect hyporecipe ???
147- idxArr = (k -> cf. _legacyParams[k][i]). (1 : length (cf. _legacyParams))
148- _solveFactorODE! (meas[i], prob, u0pts[i], _maketuplebeyond2args (idxArr... )... )
149- # _solveFactorODE!(meas, prob, u0pts, i, _maketuplebeyond2args(cf._legacyParams...)...)
150- end
151-
152- return map (x -> (x, diffOp), meas)
153- end
154- # getDimension(oderel.domain)
155156
156157# NOTE see #1025, CalcFactor should fix `multihypo=` in `cf.__` fields; OBSOLETE
157158function (cf:: CalcFactor{<:DERelative} )(measurement, X... )
@@ -197,6 +198,56 @@ function (cf::CalcFactor{<:DERelative})(measurement, X...)
197198 return res
198199end
199200
201+
202+
203+
204+ # # =========================================================================
205+ # # MAYBE legacy
206+
207+ # FIXME see #1025, `multihypo=` will not work properly yet
208+ function IncrementalInference. sampleFactor (cf:: CalcFactor{<:DERelative} , N:: Int = 1 )
209+ #
210+ oder = cf. factor
211+
212+ # how many trajectories to propagate?
213+ # @show getLabel(cf.fullvariables[2]), getDimension(cf.fullvariables[2])
214+ meas = [zeros (getDimension (cf. fullvariables[2 ])) for _ = 1 : N]
215+
216+ # pick forward or backward direction
217+ # set boundary condition
218+ u0pts = if cf. solvefor == 1
219+ # backward direction
220+ prob = oder. backwardProblem
221+ addOp, diffOp, _, _ = AMP. buildHybridManifoldCallbacks (
222+ convert (Tuple, getManifold (getVariableType (cf. fullvariables[1 ]))),
223+ )
224+ getBelief (cf. fullvariables[2 ]) |> getPoints
225+ else
226+ # forward backward
227+ prob = oder. forwardProblem
228+ # buffer manifold operations for use during factor evaluation
229+ addOp, diffOp, _, _ = AMP. buildHybridManifoldCallbacks (
230+ convert (Tuple, getManifold (getVariableType (cf. fullvariables[2 ]))),
231+ )
232+ getBelief (cf. fullvariables[1 ]) |> getPoints
233+ end
234+
235+ # solve likely elements
236+ for i = 1 : N
237+ # TODO , does this respect hyporecipe ???
238+ idxArr = (k -> cf. _legacyParams[k][i]). (1 : length (cf. _legacyParams))
239+ _solveFactorODE! (meas[i], prob, u0pts[i], _maketuplebeyond2args (idxArr... )... )
240+ # _solveFactorODE!(meas, prob, u0pts, i, _maketuplebeyond2args(cf._legacyParams...)...)
241+ end
242+
243+ return map (x -> (x, diffOp), meas)
244+ end
245+ # getDimension(oderel.domain)
246+
247+
248+
249+
250+
200251# # the function
201252# ode.problem.f.f
202253
0 commit comments