@@ -16,58 +16,92 @@ Data container for solver-specific data.
16
16
Fields:
17
17
$(TYPEDFIELDS)
18
18
"""
19
- mutable struct VariableNodeData{T<: InferenceVariable }
20
- val:: Array{Float64,2}
21
- bw:: Array{Float64,2}
22
- BayesNetOutVertIDs:: Array{Symbol,1}
23
- dimIDs:: Array{Int,1} # Likely deprecate
19
+ mutable struct VariableNodeData{T<: InferenceVariable , P}
20
+ val:: Vector{P}
21
+ bw:: Matrix{Float64}
22
+ BayesNetOutVertIDs:: Vector{Symbol}
23
+ dimIDs:: Vector{Int} # Likely deprecate
24
+
24
25
dims:: Int
25
26
eliminated:: Bool
26
27
BayesNetVertID:: Symbol # Union{Nothing, }
27
- separator:: Array{Symbol,1}
28
+ separator:: Vector{Symbol}
29
+
28
30
variableType:: T
29
31
initialized:: Bool
30
32
inferdim:: Float64
31
33
ismargin:: Bool
34
+
32
35
dontmargin:: Bool
33
36
solveInProgress:: Int
34
37
solvedCount:: Int
35
38
solveKey:: Symbol
39
+
36
40
events:: Dict{Symbol,Threads.Condition}
37
- VariableNodeData {T} (; solveKey :: Symbol = :default ) where {T <: InferenceVariable } =
38
- new {T} ( zeros ( 1 , 1 ), zeros ( 1 , 1 ), Symbol[], Int[], 0 , false , :NOTHING , Symbol[], T (), false , 0.0 , false , false , 0 , 0 , solveKey, Dict {Symbol,Threads.Condition} () )
39
- VariableNodeData {T} (val :: Array{Float64,2} ,
40
- bw :: Array{Float64,2} ,
41
- BayesNetOutVertIDs :: Array{Symbol,1} ,
42
- dimIDs :: Array{Int,1} ,
43
- dims :: Int ,eliminated :: Bool ,
44
- BayesNetVertID :: Symbol ,
45
- separator :: Array{Symbol,1} ,
46
- variableType :: T ,
47
- initialized :: Bool ,
48
- inferdim :: Float64 ,
49
- ismargin :: Bool ,
50
- dontmargin :: Bool ,
51
- solveInProgress :: Int = 0 ,
52
- solvedCount :: Int = 0 ,
53
- solveKey :: Symbol = :default ,
54
- events :: Dict{Symbol,Threads.Condition} = Dict {Symbol,Threads.Condition} ()) where T <: InferenceVariable =
55
- new {T} (val,bw,BayesNetOutVertIDs,dimIDs,dims,
56
- eliminated,BayesNetVertID,separator,
57
- variableType :: T ,initialized,inferdim,ismargin,
58
- dontmargin, solveInProgress, solvedCount, solveKey, events)
41
+
42
+ # VariableNodeData{T,P}() = new{T,P}( )
43
+ VariableNodeData {T,P} (w ... ) where {T <: InferenceVariable , P} = new {T,P} (w ... )
44
+ VariableNodeData {T,P} (;solveKey :: Symbol = :default ) where {T <: InferenceVariable , P} = new {T,P} (
45
+ Vector {P} (),
46
+ zeros ( 0 , 0 ),
47
+ Symbol[],
48
+ Int[],
49
+ 0 ,
50
+ false ,
51
+ :NOTHING ,
52
+ Symbol[],
53
+ T (),
54
+ false ,
55
+ 0.0 ,
56
+ false ,
57
+ false ,
58
+ 0 ,
59
+ 0 ,
60
+ solveKey,
61
+ Dict {Symbol,Threads.Condition} () )
62
+ #
59
63
end
60
64
61
65
# #------------------------------------------------------------------------------
62
66
# # Constructors
63
67
64
- VariableNodeData (val:: Array{Float64,2} ,
65
- bw:: Array{Float64,2} ,
66
- BayesNetOutVertIDs:: Array{Symbol,1} ,
67
- dimIDs:: Array{Int,1} ,
68
- dims:: Int ,eliminated:: Bool ,
68
+ VariableNodeData {T} (;solveKey:: Symbol = :default ) where T <: InferenceVariable = VariableNodeData {T, getPointType(T)} (solveKey= solveKey)
69
+
70
+ VariableNodeData ( val:: Vector{P} ,
71
+ bw:: Matrix{<:Real} ,
72
+ BayesNetOutVertIDs:: AbstractVector{Symbol} ,
73
+ dimIDs:: AbstractVector{Int} ,
74
+ dims:: Int ,
75
+ eliminated:: Bool ,
76
+ BayesNetVertID:: Symbol ,
77
+ separator:: Array{Symbol,1} ,
78
+ variableType:: T ,
79
+ initialized:: Bool ,
80
+ inferdim:: Float64 ,
81
+ ismargin:: Bool ,
82
+ dontmargin:: Bool ,
83
+ solveInProgress:: Int = 0 ,
84
+ solvedCount:: Int = 0 ,
85
+ solveKey:: Symbol = :default ,
86
+ events:: Dict{Symbol,Threads.Condition} = Dict {Symbol,Threads.Condition} ()
87
+ ) where {T <: InferenceVariable , P} = VariableNodeData {T,P} (
88
+ val,bw,BayesNetOutVertIDs,dimIDs,dims,
89
+ eliminated,BayesNetVertID,separator,
90
+ variableType,initialized,inferdim,ismargin,
91
+ dontmargin, solveInProgress, solvedCount, solveKey, events )
92
+ #
93
+
94
+
95
+ #
96
+
97
+ VariableNodeData (val:: Vector{P} ,
98
+ bw:: Matrix{<:Real} ,
99
+ BayesNetOutVertIDs:: AbstractVector{Symbol} ,
100
+ dimIDs:: AbstractVector{Int} ,
101
+ dims:: Int ,
102
+ eliminated:: Bool ,
69
103
BayesNetVertID:: Symbol ,
70
- separator:: Array {Symbol,1 } ,
104
+ separator:: AbstractVector {Symbol} ,
71
105
variableType:: T ,
72
106
initialized:: Bool ,
73
107
inferdim:: Float64 ,
@@ -76,16 +110,26 @@ VariableNodeData(val::Array{Float64,2},
76
110
solveInProgress:: Int = 0 ,
77
111
solvedCount:: Int = 0 ,
78
112
solveKey:: Symbol = :default
79
- ) where T <: InferenceVariable =
80
- VariableNodeData {T} (val,bw,BayesNetOutVertIDs,dimIDs,dims,
81
- eliminated,BayesNetVertID,separator,
82
- variableType:: T ,initialized,inferdim,ismargin,
83
- dontmargin, solveInProgress, solvedCount,
84
- solveKey)
85
-
86
-
87
- VariableNodeData (variableType:: T ; solveKey:: Symbol = :default ) where T <: InferenceVariable =
88
- VariableNodeData {T} (zeros (1 ,1 ), zeros (1 ,1 ), Symbol[], Int[], 0 , false , :NOTHING , Symbol[], variableType, false , 0.0 , false , false , 0 , 0 , solveKey)
113
+ ) where {T <: InferenceVariable , P} =
114
+ VariableNodeData {T,P} ( val,bw,BayesNetOutVertIDs,dimIDs,dims,
115
+ eliminated,BayesNetVertID,separator,
116
+ variableType,initialized,inferdim,ismargin,
117
+ dontmargin, solveInProgress, solvedCount,
118
+ solveKey )
119
+ #
120
+
121
+ function VariableNodeData (variableType:: T ; solveKey:: Symbol = :default ) where T <: InferenceVariable
122
+ #
123
+ # p0 = getPointIdentity(T)
124
+ P0 = Vector {getPointType(T)} ()
125
+ # P0[1] = p0
126
+ BW = zeros (0 ,0 )
127
+ # BW[1] = zeros(getDimension(T))
128
+ VariableNodeData ( P0, BW, Symbol[], Int[],
129
+ 0 , false , :NOTHING , Symbol[],
130
+ variableType, false , 0.0 , false ,
131
+ false , 0 , 0 , solveKey )
132
+ end
89
133
90
134
# #==============================================================================
91
135
# # PackedVariableNodeData.jl
@@ -237,7 +281,7 @@ struct DFGVariable{T<:InferenceVariable} <: AbstractDFGVariable
237
281
ppeDict:: Dict{Symbol, <: AbstractPointParametricEst}
238
282
""" Dictionary of solver data. May be a subset of all solutions if a solver key was specified in the get call.
239
283
Accessors: [`addVariableSolverData!`](@ref), [`updateVariableSolverData!`](@ref), and [`deleteVariableSolverData!`](@ref)"""
240
- solverDataDict:: Dict{Symbol, VariableNodeData{T}}
284
+ solverDataDict:: Dict{Symbol, <: VariableNodeData{T}}
241
285
""" Dictionary of small data associated with this variable.
242
286
Accessors: [`getSmallData`](@ref), [`setSmallData!`](@ref)"""
243
287
smallData:: Dict{Symbol, SmallDataTypes}
@@ -261,10 +305,10 @@ function DFGVariable(label::Symbol, variableType::T;
261
305
nstime:: Nanosecond = Nanosecond (0 ),
262
306
tags:: Set{Symbol} = Set {Symbol} (),
263
307
estimateDict:: Dict{Symbol, <: AbstractPointParametricEst} = Dict {Symbol, MeanMaxPPE} (),
264
- solverDataDict:: Dict{Symbol, VariableNodeData{T}} = Dict {Symbol, VariableNodeData{T}} (),
308
+ solverDataDict:: Dict{Symbol, VariableNodeData{T,P }} = Dict {Symbol, VariableNodeData{T,getPointType(T) }} (),
265
309
smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} (),
266
310
dataDict:: Dict{Symbol, AbstractDataEntry} = Dict {Symbol,AbstractDataEntry} (),
267
- solvable:: Int = 1 ) where {T <: InferenceVariable }
311
+ solvable:: Int = 1 ) where {T <: InferenceVariable , P }
268
312
269
313
if timestamp isa DateTime
270
314
DFGVariable {T} (label, ZonedDateTime (timestamp, localzone ()), nstime, tags, estimateDict, solverDataDict, smallData, dataDict, Ref (solvable))
@@ -280,12 +324,13 @@ function DFGVariable(label::Symbol,
280
324
tags:: Set{Symbol} = Set {Symbol} (),
281
325
estimateDict:: Dict{Symbol, <: AbstractPointParametricEst} = Dict {Symbol, MeanMaxPPE} (),
282
326
smallData:: Dict{Symbol, SmallDataTypes} = Dict {Symbol, SmallDataTypes} (),
283
- dataDict:: Dict{Symbol, AbstractDataEntry} = Dict {Symbol,AbstractDataEntry} (),
327
+ dataDict:: Dict{Symbol, <: AbstractDataEntry} = Dict {Symbol,AbstractDataEntry} (),
284
328
solvable:: Int = 1 ) where {T <: InferenceVariable }
329
+ #
285
330
if timestamp isa DateTime
286
- DFGVariable {T} (label, ZonedDateTime (timestamp, localzone ()), nstime, tags, estimateDict, Dict {Symbol, VariableNodeData{T}} (:default => solverData), smallData, dataDict, Ref (solvable))
331
+ DFGVariable {T} (label, ZonedDateTime (timestamp, localzone ()), nstime, tags, estimateDict, Dict {Symbol, VariableNodeData{T, getPointType(T) }} (:default => solverData), smallData, dataDict, Ref (solvable))
287
332
else
288
- DFGVariable {T} (label, timestamp, nstime, tags, estimateDict, Dict {Symbol, VariableNodeData{T}} (:default => solverData), smallData, dataDict, Ref (solvable))
333
+ DFGVariable {T} (label, timestamp, nstime, tags, estimateDict, Dict {Symbol, VariableNodeData{T, getPointType(T) }} (:default => solverData), smallData, dataDict, Ref (solvable))
289
334
end
290
335
end
291
336
0 commit comments