Skip to content

Consolidate / Simplify factor evaluation (CalcFactor) #467

@dehann

Description

@dehann

EDITED (20Q4 / 21Q1):

Using this issue for topics related to consolidating the nonparametric and parametric factor residual function API. Idea is user writes one residual factor in a sensible way, and IIF is able to use that factor for both parametric and nonparametric with little to no change from the user perspective. A critical point to note here is that nonparametric (nonGaussian) is much more versatile and general, so there are many many cases where parametric will just not be possible -- regardless the API should be standardized.

References:


Current holdups:


New Documentation


Preliminary New API Example

# new and simplified interface for both nonparametric and parametric
function (s::CalcFactor{<:LinearRelative})( res::AbstractVector{<:Real},
z,
x1,
x2 ) # where {M<:FactorMetadata,P<:Tuple,X<:AbstractVector}
#
# TODO convert to distance(distance(x2,x1),z) # or use dispatch on `-` -- what to do about `.-`
res .= z - (x2 - x1)
nothing
end


Parametric Integration Work 90% (?) Done

DF, I was hoping to just finish the consolidation with (#467 (comment)) but alas! Note that much of the consolidation work has already been done surrounding _CalcFactorParametric as the internal interface between new CalcFactor API and solve__Parametric functions. E.g. see:

# pass in residual for consolidation with nonparametric
# userdata is now at `cfp.cf.cachedata`
function (cfp::_CalcFactorParametric)(variables...)
# call the user function (be careful to call the new CalcFactor version only!!!)
res = zeros(length(cfp.meanVal))
cfp.calcfactor!(res, cfp.meanVal, variables...)
# 1/2*log(1/( sqrt(det(Σ)*(2pi)^k) )) ## k = dim(μ)
return 0.5 * (res' * cfp.informationMat * res)
end


Original Issue Question

How would you use a normal IIF factor in parametric? example.

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions