Skip to content

Commit 1c7d729

Browse files
committed
address issue #147
1 parent bca01e6 commit 1c7d729

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

src/entities/DFGVariable.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mutable struct VariableNodeData
1010
eliminated::Bool
1111
BayesNetVertID::Symbol # Union{Nothing, }
1212
separator::Array{Symbol,1}
13-
softtype
13+
softtype # Perhaps this should move up to DFGVariable level
1414
initialized::Bool
1515
inferdim::Float64
1616
ismargin::Bool
@@ -73,9 +73,20 @@ mutable struct PackedVariableNodeData
7373
x15::Bool ) = new(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15)
7474
end
7575

76+
"""
77+
$TYPEDEF
78+
79+
Data container to store Parameteric Point Estimate (PPE) from a variety of types.
80+
81+
Notes
82+
- `ppeType` is something like `:max/:mean/:modefit` etc.
83+
- `solveKey` is from super-solve concept, starting with `:default`,
84+
- `estimate` is the actual numerical estimate value,
85+
- Additional information such as how the data is represented (ie softtype) is stored alongside this data container in the `DFGVariableSummary` container.
86+
"""
7687
struct VariableEstimate
7788
solverKey::Symbol
78-
type::Symbol
89+
ppeType::Symbol
7990
estimate::Vector{Float64}
8091
lastUpdatedTimestamp::DateTime
8192
VariableEstimate(solverKey::Symbol, type::Symbol, estimate::Vector{Float64}, lastUpdatedTimestamp::DateTime=now()) = new(solverKey, type, estimate, lastUpdatedTimestamp)
@@ -142,11 +153,13 @@ mutable struct DFGVariableSummary <: AbstractDFGVariable
142153
timestamp::DateTime
143154
tags::Vector{Symbol}
144155
estimateDict::Dict{Symbol, Dict{Symbol, VariableEstimate}}
156+
softtypename::Symbol
145157
_internalId::Int64
146158
end
147159
label(v::DFGVariableSummary) = v.label
148160
timestamp(v::DFGVariableSummary) = v.timestamp
149161
tags(v::DFGVariableSummary) = v.tags
150162
estimates(v::DFGVariableSummary) = v.estimateDict
151163
estimate(v::DFGVariableSummary, key::Symbol=:default) = haskey(v.estimateDict, key) ? v.estimateDict[key] : nothing
164+
softtype(v::DFGVariableSummary)::Symbol = v.softtypename
152165
internalId(v::DFGVariableSummary) = v._internalId

src/services/DFGVariable.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,5 @@ function ==(a::VariableNodeData,b::VariableNodeData, nt::Symbol=:var)
6666
end
6767

6868
function convert(::Type{DFGVariableSummary}, v::DFGVariable)
69-
return DFGVariableSummary(v.label, v.timestamp, deepcopy(v.tags), deepcopy(v.estimateDict), v._internalId)
69+
return DFGVariableSummary(v.label, v.timestamp, deepcopy(v.tags), deepcopy(v.estimateDict), Symbol(typeof(getSofttype(v))), v._internalId)
7070
end

test/LightDFGSummaryTypes.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dfg = LightDFG{NoSolverParams, DFGVariableSummary, DFGFactorSummary}()
22

3-
DistributedFactorGraphs.DFGVariableSummary(label::Symbol) = DFGVariableSummary(label, DistributedFactorGraphs.now(), Symbol[], Dict{Symbol, VariableEstimate}(), 0)
3+
DistributedFactorGraphs.DFGVariableSummary(label::Symbol) = DFGVariableSummary(label, DistributedFactorGraphs.now(), Symbol[], Dict{Symbol, VariableEstimate}(), :NA, 0)
44

55
DistributedFactorGraphs.DFGFactorSummary(label::Symbol) = DFGFactorSummary(label, Symbol[], 0, Symbol[])
66

@@ -123,13 +123,13 @@ end
123123
estimates(newvar)[:default] = Dict{Symbol, VariableEstimate}(
124124
:max => VariableEstimate(:default, :max, [100.0]),
125125
:mean => VariableEstimate(:default, :mean, [50.0]),
126-
:ppe => VariableEstimate(:default, :ppe, [75.0]))
126+
:modefit => VariableEstimate(:default, :modefit, [75.0]))
127127
#update
128128
updateVariableSolverData!(dfg, newvar)
129129
#TODO maybe implement ==; @test newvar==var
130130
Base.:(==)(varest1::VariableEstimate, varest2::VariableEstimate) = begin
131131
varest1.lastUpdatedTimestamp == varest2.lastUpdatedTimestamp || return false
132-
varest1.type == varest2.type || return false
132+
varest1.ppeType == varest2.ppeType || return false
133133
varest1.solverKey == varest2.solverKey || return false
134134
varest1.estimate == varest2.estimate || return false
135135
return true

test/interfaceTests.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ end
115115
#TODO Should the next test work?
116116
@test_broken !isInitialized(dfg, :f1)
117117
@test_broken !isInitialized(f1)
118-
118+
119119
end
120120

121121
@testset "Updating Nodes" begin
@@ -127,13 +127,13 @@ end
127127
estimates(newvar)[:default] = Dict{Symbol, VariableEstimate}(
128128
:max => VariableEstimate(:default, :max, [100.0]),
129129
:mean => VariableEstimate(:default, :mean, [50.0]),
130-
:ppe => VariableEstimate(:default, :ppe, [75.0]))
130+
:modefit => VariableEstimate(:default, :modefit, [75.0]))
131131
#update
132132
updateVariableSolverData!(dfg, newvar)
133133
#TODO maybe implement ==; @test newvar==var
134134
Base.:(==)(varest1::VariableEstimate, varest2::VariableEstimate) = begin
135135
varest1.lastUpdatedTimestamp == varest2.lastUpdatedTimestamp || return false
136-
varest1.type == varest2.type || return false
136+
varest1.ppeType == varest2.ppeType || return false
137137
varest1.solverKey == varest2.solverKey || return false
138138
varest1.estimate == varest2.estimate || return false
139139
return true
@@ -147,7 +147,7 @@ end
147147
estimates(newvar)[:second] = Dict{Symbol, VariableEstimate}(
148148
:max => VariableEstimate(:default, :max, [10.0]),
149149
:mean => VariableEstimate(:default, :mean, [5.0]),
150-
:ppe => VariableEstimate(:default, :ppe, [7.0]))
150+
:modefit => VariableEstimate(:default, :modefit, [7.0]))
151151

152152
# Persist to the original variable.
153153
updateVariableSolverData!(dfg, newvar)
@@ -283,7 +283,11 @@ end
283283
# Check all fields are equal for all variables
284284
for v in ls(summaryGraph)
285285
for field in variableFields
286-
@test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field)
286+
if field != :softtypename
287+
@test getfield(getVariable(dfg, v), field) == getfield(getVariable(summaryGraph, v), field)
288+
else
289+
@info "skipping softtypename check"
290+
end
287291
end
288292
end
289293
for f in lsf(summaryGraph)

0 commit comments

Comments
 (0)