Skip to content

Commit b07b219

Browse files
authored
Update for DFGv1 whereNoun filters (#1907)
Co-authored-by: Johannes Terblanche <Affie@users.noreply.github.com>
1 parent 7d3c31e commit b07b219

16 files changed

Lines changed: 32 additions & 32 deletions

IncrementalInference/src/CliqueStateMachine/services/CliqueStateMachine.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ function preUpSolve_StateMachine(csmc::CliqStateMachineContainer)
287287
logCSM(
288288
csmc,
289289
"CSM-2a messages for up";
290-
upmsg = lsf(csmc.cliqSubFg; tagsFilter = ([:__LIKELIHOODMESSAGE__])),
290+
upmsg = lsf(csmc.cliqSubFg; whereTags = ([:__LIKELIHOODMESSAGE__])),
291291
)
292292

293293
# store the cliqSubFg for later debugging
@@ -762,7 +762,7 @@ function tryDownInit_StateMachine(csmc::CliqStateMachineContainer)
762762
# structure for all up message densities computed during this initialization procedure.
763763
# XXX
764764
dwnkeys_ =
765-
lsf(csmc.cliqSubFg; tagsFilter = ([:__DOWNWARD_COMMON__;])) .|> x -> ls(csmc.cliqSubFg, x)[1]
765+
lsf(csmc.cliqSubFg; whereTags = ([:__DOWNWARD_COMMON__;])) .|> x -> ls(csmc.cliqSubFg, x)[1]
766766
initorder = getCliqInitVarOrderDown(csmc.cliqSubFg, csmc.cliq, dwnkeys_)
767767
# initorder = getCliqVarInitOrderUp(csmc.tree, csmc.cliq)
768768

IncrementalInference/src/ExportAPI.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export CSMHistory,
164164
TreeBelief,
165165
LikelihoodMessage,
166166
initfg,
167-
buildSubgraph,
167+
getSubgraph,
168168
buildCliqSubgraph!,
169169
transferUpdateSubGraph!,
170170
getEliminationOrder,

IncrementalInference/src/parametric/services/ParametricUtils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ function solveConditionalsParametric(
682682
)
683683
varIds = [frontals; separators]
684684

685-
sfg = issetequal(varIds, listVariables(fg)) ? fg : buildSubgraph(fg, varIds, 1)
685+
sfg = issetequal(varIds, listVariables(fg)) ? fg : getSubgraph(fg, varIds, 1)
686686

687687
flatvar = FlatVariables(fg, varIds)
688688

@@ -941,7 +941,7 @@ function updateParametricSolution!(fg, M, labels::AbstractArray{Symbol}, vals,
941941

942942
for (i, (v, val)) in enumerate(zip(labels, vals))
943943
vnd = getState(getVariable(fg, v), solveKey)
944-
covar = isnothing(Σ) ? vnd.bw : covars[i]
944+
covar = isnothing(Σ) ? DFG.refCovariances(vnd)[1] : covars[i]
945945
# Update the variable node data value and covariance
946946
updateSolverDataParametric!(vnd, val, covar)#FIXME add cov
947947
end

IncrementalInference/src/services/AnalysisTools.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function shrinkFactorGraph(fg; upto::Int = 6)
1919
fgs = deepcopy(fg)
2020

2121
delVars = filter(x -> isSolvable(getVariable(fgs, x)) == 0, ls(fgs))
22-
todel = setdiff(lsf(fgs; solvableFilter = >=(0)), lsf(fgs; solvableFilter = >=(1)))
22+
todel = setdiff(lsf(fgs; whereSolvable = >=(0)), lsf(fgs; whereSolvable = >=(1)))
2323
delFcts = intersect(lsf(fgs), todel)
2424
allMags = filter(x -> :MAGNETOMETER in listTags(getFactor(fgs, x)), lsfPriors(fgs))
2525
union!(delFcts, filter(x -> length(ls(fgs, x)) == 0, allMags))

IncrementalInference/src/services/BayesNet.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ function buildBayesNet!(dfg::AbstractDFG, elimorder::Vector{Symbol}; solvable::I
149149
gm = FactorCompute[]
150150

151151
vert = DFG.getVariable(dfg, v)
152-
for fctId in listNeighbors(dfg, vert; solvableFilter = >=(solvable))
152+
for fctId in listNeighbors(dfg, vert; whereSolvable = >=(solvable))
153153
fct = DFG.getFactor(dfg, fctId)
154154
if (fct.state.eliminated != true)
155155
push!(fi, fctId)
156-
for sepNode in listNeighbors(dfg, fct; solvableFilter = >=(solvable))
156+
for sepNode in listNeighbors(dfg, fct; whereSolvable = >=(solvable))
157157
# TODO -- validate !(sepNode.index in Si) vs. older !(sepNode in Si)
158158
if sepNode != v && !(sepNode in Si) # Symbol comparison!
159159
push!(Si, sepNode)

IncrementalInference/src/services/GraphInit.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ See also: [`doautoinit!`](@ref), [`initAll!`](@ref)
2121
function makeSolverData!(
2222
dfg::AbstractDFG;
2323
solvable = 1,
24-
varList::AbstractVector{Symbol} = ls(dfg; solvableFilter = >=(solvable)),
24+
varList::AbstractVector{Symbol} = ls(dfg; whereSolvable = >=(solvable)),
2525
solveKey::Symbol=:default
2626
)
2727
count = 0
@@ -475,8 +475,8 @@ function ensureSolvable!(
475475
solvableFallback::Int = 0,
476476
)
477477
# workaround in case isolated variables occur
478-
solvVars = ls(dfg; solvableFilter = >=(solvableTarget))
479-
varHasFact = (x -> length(listNeighbors(dfg, x; solvableFilter = >=(solvableTarget))) == 0).(solvVars)
478+
solvVars = ls(dfg; whereSolvable = >=(solvableTarget))
479+
varHasFact = (x -> length(listNeighbors(dfg, x; whereSolvable = >=(solvableTarget))) == 0).(solvVars)
480480
blankVars = solvVars[findall(varHasFact)]
481481
if 0 < length(blankVars)
482482
@warn(
@@ -504,7 +504,7 @@ function initAll!(
504504
)
505505
#
506506
# allvarnodes = getVariables(dfg)
507-
syms = intersect(DFG.getAddHistory(dfg), ls(dfg; solvableFilter = >=(solvable)))
507+
syms = intersect(DFG.getAddHistory(dfg), ls(dfg; whereSolvable = >=(solvable)))
508508
# syms = ls(dfg, solvable=solvable) # |> sortDFG
509509

510510
# May have to first add the solveKey VNDs if they are not yet available

IncrementalInference/src/services/JunctionTreeUtils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ function getCliqFactorsFromFrontals(
999999
for fctid in ls(fgl, frsym)
10001000
fct = getFactor(fgl, fctid)
10011001
if !unused || !fct.state.potentialused
1002-
loutn = listNeighbors(fgl, fctid; solvableFilter = >=(solvable))
1002+
loutn = listNeighbors(fgl, fctid; whereSolvable = >=(solvable))
10031003
# deal with unary factors
10041004
if length(loutn) == 1
10051005
union!(usefcts, Symbol[Symbol(fct.label);])
@@ -1194,9 +1194,9 @@ function getCliqVarsWithFrontalNeighbors(
11941194
union!(syms, Symbol.(cond))
11951195

11961196
# TODO Can we trust factors are frontal connected?
1197-
ffcs = union(map(x -> listNeighbors(fgl, x; solvableFilter = >=(solvable)), frtl)...)
1197+
ffcs = union(map(x -> listNeighbors(fgl, x; whereSolvable = >=(solvable)), frtl)...)
11981198
# @show ffcs = getCliqueData(cliq).potentials
1199-
neig = union(map(x -> listNeighbors(fgl, x; solvableFilter = >=(solvable)), ffcs)...)
1199+
neig = union(map(x -> listNeighbors(fgl, x; whereSolvable = >=(solvable)), ffcs)...)
12001200
union!(syms, Symbol.(neig))
12011201
return syms
12021202
end

IncrementalInference/src/services/SolverAPI.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ function solveTree!(
393393
allk = parse.(Int, ss_)
394394
nextk = length(allk) == 0 ? 0 : maximum(allk) + 1
395395
newKey = Symbol(:default_, nextk)
396-
# DFG.cloneStates!(dfgl, newKey, :default; solvableFilter = >=(1))
397-
for vlabel in ls(dfgl; solvableFilter = >=(1))
396+
# DFG.cloneStates!(dfgl, newKey, :default; whereSolvable = >=(1))
397+
for vlabel in ls(dfgl; whereSolvable = >=(1))
398398
DFG.copytoState!(dfgl, vlabel, newKey, getState(dfgl, vlabel, :default))
399399
end
400400
# foreach(x->updateVariableSolverData!(dfgl, x, getState(getVariable(dfgl,x), :default), newKey, true, Symbol[]), ls(dfgl, solvable=1))

IncrementalInference/src/services/SolverUtilities.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function _buildGraphByFactorAndTypes!(
157157
newFactor::Bool = true,
158158
destPattern::Regex = r"x\d+",
159159
destPrefix::Symbol = match(r"[a-zA-Z_]+", destPattern.pattern).match |> Symbol,
160-
_allVars::AbstractVector{Symbol} = sortDFG(ls(dfg; labelFilter=contains(destPattern))),
160+
_allVars::AbstractVector{Symbol} = sortDFG(ls(dfg; whereLabel=contains(destPattern))),
161161
currLabel::Symbol = 0 < length(_allVars) ? _allVars[end] : Symbol(destPrefix, 0),
162162
currNumber::Integer = reverse(match(r"\d+", reverse(string(currLabel))).match) |>
163163
x -> parse(Int, x),

IncrementalInference/src/services/SubGraphFunctions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$(SIGNATURES)
44
Specialized subgraph function for cliques to build a deep subgraph copy from the DFG given a list of frontals and separators.
55
Dev notes:
6-
- TODO Since a clique should already have a list of frontals, seperators, and potentials (factors), this function should just be a light wrapper around copyGraph or buildSubgraph
6+
- TODO Since a clique should already have a list of frontals, seperators, and potentials (factors), this function should just be a light wrapper around copyGraph or getSubgraph
77
- TODO Send in clique and then extract frontals, separators and factors
88
- TODO ability to limit which solveKeys to copy.
99
"""

0 commit comments

Comments
 (0)