Skip to content

Commit 1b12ad6

Browse files
committed
Adding variable and factor structures
1 parent b03c180 commit 1b12ad6

File tree

5 files changed

+73
-8
lines changed

5 files changed

+73
-8
lines changed

REQUIRE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ DocStringExtensions 0.4.1
55
Requires 0.5.2
66
JSON2
77
Graphs
8+
# Caesar/IIF specific imports
9+
Distributions

src/DistributedFactorGraphs.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module DistributedFactorGraphs
33
using Base
44
using DocStringExtensions
55
using Requires
6+
using Dates
7+
using Distributions
68

79
# Entities
810
include("entities/AbstractTypes.jl")

src/entities/DFGFactor.jl

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
"""
2+
$(TYPEDEF)
3+
"""
4+
mutable struct GenericFunctionNodeData{T, S}
5+
fncargvID::Array{Int,1}
6+
eliminated::Bool
7+
potentialused::Bool
8+
edgeIDs::Array{Int,1}
9+
frommodule::S #Union{Symbol, AbstractString}
10+
fnc::T
11+
multihypo::String # likely to moved when GenericWrapParam is refactored
12+
certainhypo::Vector{Int}
13+
GenericFunctionNodeData{T, S}() where {T, S} = new{T,S}()
14+
GenericFunctionNodeData{T, S}(x1, x2, x3, x4, x5::S, x6::T, x7::String="", x8::Vector{Int}=Int[]) where {T, S} = new{T,S}(x1, x2, x3, x4, x5, x6, x7, x8)
15+
GenericFunctionNodeData(x1, x2, x3, x4, x5::S, x6::T, x7::String="", x8::Vector{Int}=Int[]) where {T, S} = new{T,S}(x1, x2, x3, x4, x5, x6, x7, x8)
16+
# GenericFunctionNodeData(x1, x2, x3, x4, x5::S, x6::T, x7::String) where {T, S} = new{T,S}(x1, x2, x3, x4, x5, x6, x7)
17+
end
18+
119
"""
220
$(SIGNATURES)
321
Fundamental structure for a DFG factor.
422
"""
5-
mutable struct DFGFactor <: DFGNode
23+
mutable struct DFGFactor{T, S} <: DFGNode
624
label::Symbol
7-
#TODO: Populate
25+
data::GenericFunctionNodeData{T, S}
826
_internalId::Int64
9-
DFGFactor(label::Symbol) = new(label, 0)
10-
DFGFactor(label::Symbol, _internalId::Int64) = new(label, _internalId)
27+
DFGFactor{T, S}(label::Symbol) where {T, S} = new{T, S}(label, GenericFunctionNodeData{T, S}(), 0)
28+
DFGFactor{T, S}(label::Symbol, _internalId::Int64) where {T, S} = new{T, S}(label, GenericFunctionNodeData{T, S}(), _internalId)
1129
end

src/entities/DFGVariable.jl

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,55 @@
1+
"""
2+
$(TYPEDEF)
3+
"""
4+
mutable struct VariableNodeData
5+
val::Array{Float64,2}
6+
bw::Array{Float64,2}
7+
BayesNetOutVertIDs::Array{Int,1}
8+
dimIDs::Array{Int,1} # Likely deprecate
9+
dims::Int
10+
eliminated::Bool
11+
BayesNetVertID::Int
12+
separator::Array{Int,1}
13+
groundtruth::Union{Nothing, Dict{ Tuple{Symbol, Vector{Float64}} } } # not packed yet
14+
softtype
15+
initialized::Bool
16+
ismargin::Bool
17+
dontmargin::Bool
18+
VariableNodeData() = new()
19+
# function VariableNodeData(x1,x2,x3,x4,x5,x6,x7,x8,x9)
20+
# @warn "Deprecated use of VariableNodeData(11 param), use 13 parameters instead"
21+
# new(x1,x2,x3,x4,x5,x6,x7,x8,x9, nothing, true, false, false) # TODO ensure this is initialized true is working for most cases
22+
# end
23+
VariableNodeData(x1::Array{Float64,2},
24+
x2::Array{Float64,2},
25+
x3::Vector{Int},
26+
x4::Vector{Int},
27+
x5::Int,
28+
x6::Bool,
29+
x7::Int,
30+
x8::Vector{Int},
31+
x9::Union{Nothing, Dict{ Tuple{Symbol, Vector{Float64}} } },
32+
x10,
33+
x11::Bool,
34+
x12::Bool,
35+
x13::Bool) =
36+
new(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13)
37+
end
138

239
"""
340
$(SIGNATURES)
441
Fundamental structure for a DFG variable.
542
"""
643
mutable struct DFGVariable <: DFGNode
744
label::Symbol
8-
#TODO: Populate
45+
timestamp::DateTime
46+
tags::Vector{Symbol}
47+
estimates::Dict{Symbol, Vector{Float64}}
48+
variableData::VariableNodeData
49+
# variableDatas::VND
50+
smallData::Any
51+
bigData::Any
952
_internalId::Int64
10-
DFGVariable(label::Symbol) = new(label, 0)
11-
DFGVariable(label::Symbol, _internalId::Int64) = new(label, _internalId)
53+
DFGVariable(label::Symbol, _internalId::Int64) = new(label, now(), Symbol[], Dict{Symbol, Vector{Float64}}(), VariableNodeData(), nothing, nothing, _internalId)
54+
DFGVariable(label::Symbol) = new(label, now(), Symbol[], Dict{Symbol, Vector{Float64}}(), VariableNodeData(), nothing, nothing, 0)
1255
end

test/interfaceTests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dfg = testDFGAPI()
22
v1 = DFGVariable(:a)
33
v2 = DFGVariable(:b)
4-
f1 = DFGFactor(:f1)
4+
f1 = DFGFactor{Int, :Symbol}(:f1)
55
@testset "Creating Graphs" begin
66
global dfg,v1,v2,f1
77
addVariable!(dfg, v1)

0 commit comments

Comments
 (0)