Skip to content

Commit 79a2df2

Browse files
committed
WIP
1 parent c3e58d3 commit 79a2df2

File tree

6 files changed

+87
-87
lines changed

6 files changed

+87
-87
lines changed

src/Common.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
export sortVarNested
33
export isPrior, lsfPriors
4-
export getData
54
export getVariableType, getSofttype
65
export getFactorType, getfnctype
76
export lsTypes, lsfTypes
@@ -82,14 +81,6 @@ function sortVarNested(vars::Vector{Symbol})::Vector{Symbol}
8281
return retvars
8382
end
8483

85-
"""
86-
$SIGNATURES
87-
88-
Retrieve data structure stored in a node.
89-
"""
90-
getData(v::DFGFactor)::GenericFunctionNodeData = v.data
91-
getData(v::DFGVariable; solveKey::Symbol=:default)::VariableNodeData = v.solverDataDict[solveKey]
92-
9384
"""
9485
$SIGNATURES
9586

src/DistributedFactorGraphs.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ export InferenceType, PackedInferenceType, FunctorInferenceType, InferenceVariab
2525
export FunctorSingleton, FunctorPairwise, FunctorPairwiseMinimize
2626

2727
export DFGVariable
28-
export label, timestamp, tags, estimates, estimate, solverData, solverDataDict, id, smallData, bigData
28+
export label, timestamp, tags, estimates, estimate, solverData, getData, solverDataDict, id, smallData, bigData
2929
export setSolverData
3030
export label, data, id
3131

32+
# Services/AbstractDFG Exports
33+
export hasFactor, hasVariable, isInitialized, getFactorFunction, isVariable, isFactor
34+
3235
# Solver (IIF) Exports
3336
export VariableNodeData, PackedVariableNodeData, VariableEstimate
3437
export GenericFunctionNodeData#, FunctionNodeData
@@ -97,9 +100,7 @@ function __init__()
97100

98101
end
99102

100-
101-
# not sure where to put
103+
# To be moved as necessary.
102104
include("Common.jl")
103-
include("NeedsAHome.jl")
104105

105106
end

src/NeedsAHome.jl

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/entities/DFGFactor.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ const PackedFunctionNodeData{T} = GenericFunctionNodeData{T, <: AbstractString}
5656
PackedFunctionNodeData(x1, x2, x3, x4, x5::S, x6::T, x7::String="", x8::Vector{Int}=Int[]) where {T <: PackedInferenceType, S <: AbstractString} = GenericFunctionNodeData(x1, x2, x3, x4, x5, x6, x7, x8)
5757
const FunctionNodeData{T} = GenericFunctionNodeData{T, Symbol}
5858
FunctionNodeData(x1, x2, x3, x4, x5::Symbol, x6::T, x7::String="", x8::Vector{Int}=Int[]) where {T <: Union{FunctorInferenceType, ConvolutionObject}}= GenericFunctionNodeData{T, Symbol}(x1, x2, x3, x4, x5, x6, x7, x8)
59+
60+
"""
61+
$SIGNATURES
62+
63+
Retrieve data structure stored in a node.
64+
"""
65+
getData(v::DFGFactor)::GenericFunctionNodeData = v.data

src/entities/DFGVariable.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ struct VariableEstimate
7575
estimate::Vector{Float64}
7676
type::Symbol
7777
key::Symbol
78+
lastUpdatedTimestamp::DateTime
7879
end
7980

8081
"""
@@ -104,6 +105,7 @@ estimates(v::DFGVariable) = v.estimateDict
104105
estimate(v::DFGVariable, key::Symbol=:default) = haskey(v.estimateDict, key) ? v.estimateDict[key] : nothing
105106
#solverData(v::DFGVariable) = haskey(v.solverDataDict, :default) ? v.solverDataDict[:default] : nothing
106107
solverData(v::DFGVariable, key::Symbol=:default) = haskey(v.solverDataDict, key) ? v.solverDataDict[key] : nothing
108+
getData(v::DFGVariable; solveKey::Symbol=:default)::VariableNodeData = v.solverDataDict[solveKey]
107109
setSolverData(v::DFGVariable, data::VariableNodeData, key::Symbol=:default) = v.solverDataDict[key] = data
108110
solverDataDict(v::DFGVariable) = v.solverDataDict
109111
id(v::DFGVariable) = v._internalId

src/services/AbstractDFG.jl

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,76 @@ Get an adjacency matrix for the DFG, returned as a tuple: adjmat::SparseMatrixCS
8282
Rows are the factors, columns are the variables, with the corresponding labels in fac_labels,var_labels.
8383
"""
8484
getAdjacencyMatrixSparse(dfg::AbstractDFG) = error("getAdjacencyMatrixSparse not implemented for $(typeof(dfg))")
85+
86+
87+
"""
88+
$SIGNATURES
89+
90+
Return boolean whether a factor `label` is present in `<:AbstractDFG`.
91+
"""
92+
function hasFactor(dfg::G, label::Symbol)::Bool where {G <: AbstractDFG}
93+
return haskey(dfg.labelDict, label)
94+
end
95+
96+
"""
97+
$(SIGNATURES)
98+
99+
Return `::Bool` on whether `dfg` contains the variable `lbl::Symbol`.
100+
"""
101+
function hasVariable(dfg::G, label::Symbol)::Bool where {G <: AbstractDFG}
102+
return haskey(dfg.labelDict, label) # haskey(vertices(dfg.g), label)
103+
end
104+
105+
106+
"""
107+
$SIGNATURES
108+
109+
Returns state of vertex data `.initialized` flag.
110+
111+
Notes:
112+
- used by both factor graph variable and Bayes tree clique logic.
113+
TODO: Refactor
114+
"""
115+
function isInitialized(var::DFGVariable; key::Symbol=:default)::Bool
116+
return var.solverDataDict[key].initialized
117+
end
118+
function isInitialized(fct::DFGFactor; key::Symbol=:default)::Bool
119+
return fct.solverDataDict[key].initialized
120+
end
121+
function isInitialized(dfg::G, label::Symbol; key::Symbol=:default)::Bool where G <: AbstractDFG
122+
return isInitialized(getVariable(dfg, label), key=key)
123+
end
124+
125+
126+
"""
127+
$SIGNATURES
128+
129+
Return whether `sym::Symbol` represents a variable vertex in the graph.
130+
"""
131+
isVariable(dfg::G, sym::Symbol) where G <: AbstractDFG = hasVariable(dfg, sym)
132+
133+
"""
134+
$SIGNATURES
135+
136+
Return whether `sym::Symbol` represents a factor vertex in the graph.
137+
"""
138+
isFactor(dfg::G, sym::Symbol) where G <: AbstractDFG = hasFactor(dfg, sym)
139+
140+
"""
141+
$SIGNATURES
142+
143+
Return reference to the user factor in `<:AbstractDFG` identified by `::Symbol`.
144+
"""
145+
getFactorFunction(fcd::GenericFunctionNodeData) = fcd.fnc.usrfnc!
146+
getFactorFunction(fc::DFGFactor) = getFactorFunction(getData(fc))
147+
function getFactorFunction(dfg::G, fsym::Symbol) where G <: AbstractDFG
148+
getFactorFunction(getFactor(dfg, fsym))
149+
end
150+
151+
152+
"""
153+
$SIGNATURES
154+
155+
Display and return to console the user factor identified by tag name.
156+
"""
157+
showFactor(fgl::G, fsym::Symbol) where G <: AbstractDFG = @show getFactor(fgl,fsym)

0 commit comments

Comments
 (0)