Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function preUpSolve_StateMachine(csmc::CliqStateMachineContainer)
logCSM(
csmc,
"CSM-2a messages for up";
upmsg = lsf(csmc.cliqSubFg; tagsFilter = ⊇([:__LIKELIHOODMESSAGE__])),
upmsg = lsf(csmc.cliqSubFg; whereTags = ⊇([:__LIKELIHOODMESSAGE__])),
)

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

Expand Down
2 changes: 1 addition & 1 deletion IncrementalInference/src/ExportAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export CSMHistory,
TreeBelief,
LikelihoodMessage,
initfg,
buildSubgraph,
getSubgraph,
buildCliqSubgraph!,
transferUpdateSubGraph!,
getEliminationOrder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ function solveConditionalsParametric(
)
varIds = [frontals; separators]

sfg = issetequal(varIds, listVariables(fg)) ? fg : buildSubgraph(fg, varIds, 1)
sfg = issetequal(varIds, listVariables(fg)) ? fg : getSubgraph(fg, varIds, 1)

flatvar = FlatVariables(fg, varIds)

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

for (i, (v, val)) in enumerate(zip(labels, vals))
vnd = getState(getVariable(fg, v), solveKey)
covar = isnothing(Σ) ? vnd.bw : covars[i]
covar = isnothing(Σ) ? DFG.refCovariances(vnd)[1] : covars[i]
# Update the variable node data value and covariance
updateSolverDataParametric!(vnd, val, covar)#FIXME add cov
end
Expand Down
2 changes: 1 addition & 1 deletion IncrementalInference/src/services/AnalysisTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function shrinkFactorGraph(fg; upto::Int = 6)
fgs = deepcopy(fg)

delVars = filter(x -> isSolvable(getVariable(fgs, x)) == 0, ls(fgs))
todel = setdiff(lsf(fgs; solvableFilter = >=(0)), lsf(fgs; solvableFilter = >=(1)))
todel = setdiff(lsf(fgs; whereSolvable = >=(0)), lsf(fgs; whereSolvable = >=(1)))
delFcts = intersect(lsf(fgs), todel)
allMags = filter(x -> :MAGNETOMETER in listTags(getFactor(fgs, x)), lsfPriors(fgs))
union!(delFcts, filter(x -> length(ls(fgs, x)) == 0, allMags))
Expand Down
4 changes: 2 additions & 2 deletions IncrementalInference/src/services/BayesNet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ function buildBayesNet!(dfg::AbstractDFG, elimorder::Vector{Symbol}; solvable::I
gm = FactorCompute[]

vert = DFG.getVariable(dfg, v)
for fctId in listNeighbors(dfg, vert; solvableFilter = >=(solvable))
for fctId in listNeighbors(dfg, vert; whereSolvable = >=(solvable))
fct = DFG.getFactor(dfg, fctId)
if (fct.state.eliminated != true)
push!(fi, fctId)
for sepNode in listNeighbors(dfg, fct; solvableFilter = >=(solvable))
for sepNode in listNeighbors(dfg, fct; whereSolvable = >=(solvable))
# TODO -- validate !(sepNode.index in Si) vs. older !(sepNode in Si)
if sepNode != v && !(sepNode in Si) # Symbol comparison!
push!(Si, sepNode)
Expand Down
8 changes: 4 additions & 4 deletions IncrementalInference/src/services/GraphInit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ See also: [`doautoinit!`](@ref), [`initAll!`](@ref)
function makeSolverData!(
dfg::AbstractDFG;
solvable = 1,
varList::AbstractVector{Symbol} = ls(dfg; solvableFilter = >=(solvable)),
varList::AbstractVector{Symbol} = ls(dfg; whereSolvable = >=(solvable)),
solveKey::Symbol=:default
)
count = 0
Expand Down Expand Up @@ -475,8 +475,8 @@ function ensureSolvable!(
solvableFallback::Int = 0,
)
# workaround in case isolated variables occur
solvVars = ls(dfg; solvableFilter = >=(solvableTarget))
varHasFact = (x -> length(listNeighbors(dfg, x; solvableFilter = >=(solvableTarget))) == 0).(solvVars)
solvVars = ls(dfg; whereSolvable = >=(solvableTarget))
varHasFact = (x -> length(listNeighbors(dfg, x; whereSolvable = >=(solvableTarget))) == 0).(solvVars)
blankVars = solvVars[findall(varHasFact)]
if 0 < length(blankVars)
@warn(
Expand Down Expand Up @@ -504,7 +504,7 @@ function initAll!(
)
#
# allvarnodes = getVariables(dfg)
syms = intersect(DFG.getAddHistory(dfg), ls(dfg; solvableFilter = >=(solvable)))
syms = intersect(DFG.getAddHistory(dfg), ls(dfg; whereSolvable = >=(solvable)))
# syms = ls(dfg, solvable=solvable) # |> sortDFG

# May have to first add the solveKey VNDs if they are not yet available
Expand Down
6 changes: 3 additions & 3 deletions IncrementalInference/src/services/JunctionTreeUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ function getCliqFactorsFromFrontals(
for fctid in ls(fgl, frsym)
fct = getFactor(fgl, fctid)
if !unused || !fct.state.potentialused
loutn = listNeighbors(fgl, fctid; solvableFilter = >=(solvable))
loutn = listNeighbors(fgl, fctid; whereSolvable = >=(solvable))
# deal with unary factors
if length(loutn) == 1
union!(usefcts, Symbol[Symbol(fct.label);])
Expand Down Expand Up @@ -1194,9 +1194,9 @@ function getCliqVarsWithFrontalNeighbors(
union!(syms, Symbol.(cond))

# TODO Can we trust factors are frontal connected?
ffcs = union(map(x -> listNeighbors(fgl, x; solvableFilter = >=(solvable)), frtl)...)
ffcs = union(map(x -> listNeighbors(fgl, x; whereSolvable = >=(solvable)), frtl)...)
# @show ffcs = getCliqueData(cliq).potentials
neig = union(map(x -> listNeighbors(fgl, x; solvableFilter = >=(solvable)), ffcs)...)
neig = union(map(x -> listNeighbors(fgl, x; whereSolvable = >=(solvable)), ffcs)...)
union!(syms, Symbol.(neig))
return syms
end
Expand Down
4 changes: 2 additions & 2 deletions IncrementalInference/src/services/SolverAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ function solveTree!(
allk = parse.(Int, ss_)
nextk = length(allk) == 0 ? 0 : maximum(allk) + 1
newKey = Symbol(:default_, nextk)
# DFG.cloneStates!(dfgl, newKey, :default; solvableFilter = >=(1))
for vlabel in ls(dfgl; solvableFilter = >=(1))
# DFG.cloneStates!(dfgl, newKey, :default; whereSolvable = >=(1))
for vlabel in ls(dfgl; whereSolvable = >=(1))
DFG.copytoState!(dfgl, vlabel, newKey, getState(dfgl, vlabel, :default))
end
# foreach(x->updateVariableSolverData!(dfgl, x, getState(getVariable(dfgl,x), :default), newKey, true, Symbol[]), ls(dfgl, solvable=1))
Expand Down
2 changes: 1 addition & 1 deletion IncrementalInference/src/services/SolverUtilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function _buildGraphByFactorAndTypes!(
newFactor::Bool = true,
destPattern::Regex = r"x\d+",
destPrefix::Symbol = match(r"[a-zA-Z_]+", destPattern.pattern).match |> Symbol,
_allVars::AbstractVector{Symbol} = sortDFG(ls(dfg; labelFilter=contains(destPattern))),
_allVars::AbstractVector{Symbol} = sortDFG(ls(dfg; whereLabel=contains(destPattern))),
currLabel::Symbol = 0 < length(_allVars) ? _allVars[end] : Symbol(destPrefix, 0),
currNumber::Integer = reverse(match(r"\d+", reverse(string(currLabel))).match) |>
x -> parse(Int, x),
Expand Down
2 changes: 1 addition & 1 deletion IncrementalInference/src/services/SubGraphFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$(SIGNATURES)
Specialized subgraph function for cliques to build a deep subgraph copy from the DFG given a list of frontals and separators.
Dev notes:
- 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
- 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
- TODO Send in clique and then extract frontals, separators and factors
- TODO ability to limit which solveKeys to copy.
"""
Expand Down
8 changes: 4 additions & 4 deletions IncrementalInference/src/services/TreeMessageUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ function _findSubgraphsFactorType(
# 1. count separtor connectivity in UPWARD_DIFFERENTIAL
sepsCount = Dict{Symbol, Int}()
map(x -> (sepsCount[x] = 0), separators)
# tagsFilter = [:__LIKELIHOODMESSAGE__;]
# tflsf = lsf(fg, tags=tagsFilter)
# whereTags = [:__LIKELIHOODMESSAGE__;]
# tflsf = lsf(fg, tags=whereTags)
for likl in jointrelatives
for vari in likl.variables
sepsCount[vari] += 1
Expand Down Expand Up @@ -168,7 +168,7 @@ function _findSubgraphsFactorType(
dfg_,
key1,
key2;
typeFilterFactors = x -> x <: defaultFct,
whereFactorType = x -> x <: defaultFct,
initialized = true,
)
# check if connected to existing subClass
Expand Down Expand Up @@ -614,7 +614,7 @@ function deleteMsgFactors!(
tags::Vector{Symbol} = [:__LIKELIHOODMESSAGE__],
)
# remove msg factors that were added to the subfg
facs = lsf(subfg; tagsFilter = !isdisjoint(tags))
facs = lsf(subfg; whereTags = !isdisjoint(tags))
deleteFactor!.(subfg, facs)
return facs
end
Expand Down
2 changes: 1 addition & 1 deletion IncrementalInference/test/testCompareVariablesFactors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ addFactor!(fg, [:x1;:x2], LinearRelative(Normal(4.0, 0.1)))
addVariable!(fg, :l1, ContinuousScalar)
addFactor!(fg, [:x1;:l1], LinearRelative(Rayleigh()))

sfg = buildSubgraph(fg, [:x0;:x1], 1) # distance=1 to include factors
sfg = getSubgraph(fg, [:x0;:x1], 1) # distance=1 to include factors

#FIXME JT - this doesn't make sense to pass, it is a subgraph so should it not rather be ⊂ [subset]?
# compareDFG(fg1, fg2, by=⊂, skip=...)
Expand Down
4 changes: 2 additions & 2 deletions IncrementalInference/test/testDeadReckoningTether.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ drec = MutableLinearRelative(Normal(0.0,0.1))
addFactor!(fg, [:x0; :deadreckon_x0], drec, solvable=0)

#
@test length(map( x->x.label, getVariables(fg, solvableFilter = >=(1)))) == 8
@test length(map( x->x.label, getVariables(fg, solvableFilter = >=(0)))) == 9
@test length(map( x->x.label, getVariables(fg, whereSolvable = >=(1)))) == 8
@test length(map( x->x.label, getVariables(fg, whereSolvable = >=(0)))) == 9
#
# # make sure
@test length(getEliminationOrder(fg, solvable=1)) == 8
Expand Down
2 changes: 1 addition & 1 deletion IncrementalInference/test/testDefaultDeconv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ addLikelihoodsDifferential!.(tfg, values(msg))
@show ls(tfg)
@test issetequal(ls(tfg), [:x2,:x4,:x6])
@test lsf(tfg) |> length == 2
@test lsf(tfg, tagsFilter = ⊇([:__UPWARD_DIFFERENTIAL__])) |> length == 2
@test lsf(tfg, whereTags = ⊇([:__UPWARD_DIFFERENTIAL__])) |> length == 2

##

Expand Down
8 changes: 4 additions & 4 deletions IncrementalInference/test/testJointEnforcement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ tp2_ = [ :x0;:x0x3f1;:x3;:x2x3f1;:x2]
pth = findShortestPathDijkstra(fg, :x0, :x2)
@test pth == tp1_ || pth == tp2_

pth = findShortestPathDijkstra(fg, :x0, :x2, typeFilterFactors = x -> x <: LinearRelative)
pth = findShortestPathDijkstra(fg, :x0, :x2, whereFactorType = x -> x <: LinearRelative)
@test pth == tp1_

# different path
pth = findShortestPathDijkstra(fg, :x0, :x2, typeFilterFactors = x -> x <: EuclidDistance)
pth = findShortestPathDijkstra(fg, :x0, :x2, whereFactorType = x -> x <: EuclidDistance)
@test pth == tp2_


Expand Down Expand Up @@ -160,11 +160,11 @@ tp2_ = [ :x0;:x0x3f1;:x3;:x2x3f1;:x2]
pth = findShortestPathDijkstra(fg, :x0, :x2)
@test pth == tp1_ || pth == tp2_

pth = findShortestPathDijkstra(fg, :x0, :x2, typeFilterFactors = x -> x <: LinearRelative)
pth = findShortestPathDijkstra(fg, :x0, :x2, whereFactorType = x -> x <: LinearRelative)
@test pth == tp1_ || pth == tp2_

# different path
pth = findShortestPathDijkstra(fg, :x0, :x2, typeFilterFactors = x -> x <: EuclidDistance)
pth = findShortestPathDijkstra(fg, :x0, :x2, whereFactorType = x -> x <: EuclidDistance)
@test pth == Symbol[]


Expand Down
2 changes: 1 addition & 1 deletion attic/CSMCommon_Consolidate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function buildCliqSubgraphForDown_StateMachine(csmc::CliqStateMachineContainer)
# build a local subgraph for inference operations
syms = getCliqAllVarIds(csmc.cliq)
infocsm(csmc, "2r, build subgraph syms=$(syms)")
csmc.cliqSubFg = buildSubgraph(csmc.dfg, syms, 1; verbose=false)
csmc.cliqSubFg = getSubgraph(csmc.dfg, syms, 1; verbose=false)

opts = getSolverParams(csmc.dfg)
# store the cliqSubFg for later debugging
Expand Down
Loading