@@ -22,8 +22,9 @@ mutable struct VariableNodeData{T<:InferenceVariable}
22
22
ismargin:: Bool
23
23
dontmargin:: Bool
24
24
solveInProgress:: Int
25
+ solvedCount:: Int
25
26
VariableNodeData {T} () where {T <: InferenceVariable } =
26
- new {T} (zeros (1 ,1 ), zeros (1 ,1 ), Symbol[], Int[], 0 , false , :NOTHING , Symbol[], T (), false , 0.0 , false , false , 0 )
27
+ new {T} (zeros (1 ,1 ), zeros (1 ,1 ), Symbol[], Int[], 0 , false , :NOTHING , Symbol[], T (), false , 0.0 , false , false , 0 , 0 )
27
28
VariableNodeData {T} (val:: Array{Float64,2} ,
28
29
bw:: Array{Float64,2} ,
29
30
BayesNetOutVertIDs:: Array{Symbol,1} ,
@@ -36,11 +37,12 @@ mutable struct VariableNodeData{T<:InferenceVariable}
36
37
inferdim:: Float64 ,
37
38
ismargin:: Bool ,
38
39
dontmargin:: Bool ,
39
- solveInProgress:: Int = 0 ) where T <: InferenceVariable =
40
+ solveInProgress:: Int = 0 ,
41
+ solvedCount:: Int = 0 ) where T <: InferenceVariable =
40
42
new {T} (val,bw,BayesNetOutVertIDs,dimIDs,dims,
41
43
eliminated,BayesNetVertID,separator,
42
44
softtype:: T ,initialized,inferdim,ismargin,
43
- dontmargin, solveInProgress)
45
+ dontmargin, solveInProgress, solvedCount )
44
46
end
45
47
46
48
VariableNodeData (val:: Array{Float64,2} ,
@@ -55,20 +57,21 @@ VariableNodeData(val::Array{Float64,2},
55
57
inferdim:: Float64 ,
56
58
ismargin:: Bool ,
57
59
dontmargin:: Bool ,
58
- solveInProgress:: Int = 0 ) where T <: InferenceVariable =
60
+ solveInProgress:: Int = 0 ,
61
+ solvedCount:: Int = 0 ) where T <: InferenceVariable =
59
62
VariableNodeData {T} (val,bw,BayesNetOutVertIDs,dimIDs,dims,
60
63
eliminated,BayesNetVertID,separator,
61
64
softtype:: T ,initialized,inferdim,ismargin,
62
- dontmargin, solveInProgress)
65
+ dontmargin, solveInProgress, solvedCount )
63
66
#
64
67
VariableNodeData (softtype:: T ) where T <: InferenceVariable =
65
- VariableNodeData {T} (zeros (1 ,1 ), zeros (1 ,1 ), Symbol[], Int[], 0 , false , :NOTHING , Symbol[], softtype, false , 0.0 , false , false , 0 )
68
+ VariableNodeData {T} (zeros (1 ,1 ), zeros (1 ,1 ), Symbol[], Int[], 0 , false , :NOTHING , Symbol[], softtype, false , 0.0 , false , false , 0 , 0 )
66
69
67
70
function VariableNodeData ()
68
71
st = stacktrace ()
69
72
@warn " VariableNodeData() is deprecated please use VariableNodeData{T}() or VariableNodeData(softtype::T) where T <: InferenceVariable. Enable DEBUG logging for stack trace."
70
73
@debug st
71
- VariableNodeData {InferenceVariable} (zeros (1 ,1 ), zeros (1 ,1 ), Symbol[], Int[], 0 , false , :NOTHING , Symbol[], SingletonInferenceVariable (), false , 0.0 , false , false , 0 )
74
+ VariableNodeData {InferenceVariable} (zeros (1 ,1 ), zeros (1 ,1 ), Symbol[], Int[], 0 , false , :NOTHING , Symbol[], SingletonInferenceVariable (), false , 0.0 , false , false , 0 , 0 )
72
75
end
73
76
74
77
@@ -93,6 +96,7 @@ mutable struct PackedVariableNodeData
93
96
ismargin:: Bool
94
97
dontmargin:: Bool
95
98
solveInProgress:: Int
99
+ solvedCount:: Int
96
100
PackedVariableNodeData () = new ()
97
101
PackedVariableNodeData (x1:: Vector{Float64} ,
98
102
x2:: Int ,
@@ -109,7 +113,8 @@ mutable struct PackedVariableNodeData
109
113
x13:: Float64 ,
110
114
x14:: Bool ,
111
115
x15:: Bool ,
112
- x16:: Int ) = new (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16)
116
+ x16:: Int ,
117
+ solvedCount:: Int ) = new (x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,solvedCount)
113
118
end
114
119
115
120
# AbstractPointParametricEst interface
@@ -184,7 +189,7 @@ mutable struct DFGVariableSummary <: AbstractDFGVariable
184
189
timestamp:: DateTime
185
190
tags:: Vector{Symbol}
186
191
ppeDict:: Dict{Symbol, <:AbstractPointParametricEst}
187
- softtypename:: Symbol
192
+ softtypename:: Symbol # should be removed
188
193
_internalId:: Int64
189
194
end
190
195
@@ -274,8 +279,6 @@ TODO, DO NOT USE v.softtypename in DFGVariableSummary
274
279
getSofttype (v:: DFGVariableSummary ):: Symbol = v. softtypename
275
280
276
281
277
-
278
-
279
282
"""
280
283
$SIGNATURES
281
284
@@ -298,6 +301,47 @@ Get solver data dictionary for a variable.
298
301
"""
299
302
solverDataDict (v:: DFGVariable ) = v. solverDataDict
300
303
304
+ """
305
+ $SIGNATURES
306
+
307
+ Get the number of times a variable has been inferred -- i.e. `solvedCount`.
308
+
309
+ Related
310
+
311
+ isSolved, setSolved!
312
+ """
313
+ getSolved (v:: VariableNodeData ) = v. solvedCount
314
+ getSolved (v:: VariableDataLevel2 , solveKey:: Symbol = :default ) = solverData (v, solveKey) |> getSolved
315
+ getSolved (dfg:: AbstractDFG , sym:: Symbol , solveKey:: Symbol = :default ) = getSolved (getVariable (dfg, sym), solveKey)
316
+
317
+ """
318
+ $SIGNATURES
319
+
320
+ Boolean on whether the variable has been solved.
321
+
322
+ Related
323
+
324
+ getSolved, setSolved!
325
+ """
326
+ isSolved (v:: VariableNodeData ) = 0 < v. solvedCount
327
+ isSolved (v:: VariableDataLevel2 , solveKey:: Symbol = :default ) = solverData (v, solveKey) |> isSolved
328
+ isSolved (dfg:: AbstractDFG , sym:: Symbol , solveKey:: Symbol = :default ) = isSolved (getVariable (dfg, sym), solveKey)
329
+
330
+
331
+ """
332
+ $SIGNATURES
333
+
334
+ Update/set the `solveCount` value.
335
+
336
+ Related
337
+
338
+ getSolved, isSolved
339
+ """
340
+ setSolved! (v:: VariableNodeData , val:: Int ) = v. solvedCount = val
341
+ setSolved! (v:: VariableDataLevel2 , val:: Int , solveKey:: Symbol = :default ) = setSolved! (solverData (v, solveKey), val)
342
+ setSolved! (dfg:: AbstractDFG , sym:: Symbol , val:: Int , solveKey:: Symbol = :default ) = setSolved! (getVariable (dfg, sym), solveKey, val)
343
+
344
+
301
345
"""
302
346
$SIGNATURES
303
347
0 commit comments