Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring tree msg types (459) #654

Merged
merged 1 commit into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions src/BeliefTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,78 @@ const IntermediateSiblingMessages = Vector{Tuple{BallTreeDensity,Float64}}
const IntermediateMultiSiblingMessages = Dict{Symbol, IntermediateSiblingMessages}




"""
$(TYPEDEF)
"""
mutable struct PotProd
Xi::Symbol # Int
prev::Array{Float64,2}
product::Array{Float64,2}
potentials::Array{BallTreeDensity,1}
potentialfac::Vector{Symbol}
end
"""
$(TYPEDEF)
"""
mutable struct CliqGibbsMC
prods::Array{PotProd,1}
lbls::Vector{Symbol}
CliqGibbsMC() = new()
CliqGibbsMC(a,b) = new(a,b)
end
"""
$(TYPEDEF)
"""
mutable struct DebugCliqMCMC
mcmc::Union{Nothing, Array{CliqGibbsMC,1}}
outmsg::LikelihoodMessage
outmsglbls::Dict{Symbol, Symbol} # Int
priorprods::Vector{CliqGibbsMC}
DebugCliqMCMC() = new()
DebugCliqMCMC(a,b,c,d) = new(a,b,c,d)
end

"""
$(TYPEDEF)
"""
mutable struct UpReturnBPType
upMsgs::LikelihoodMessage
dbgUp::DebugCliqMCMC
IDvals::Dict{Symbol, TreeBelief}
keepupmsgs::LikelihoodMessage # Dict{Symbol, BallTreeDensity} # TODO Why separate upMsgs?
totalsolve::Bool
UpReturnBPType() = new()
UpReturnBPType(x1,x2,x3,x4,x5) = new(x1,x2,x3,x4,x5)
end

"""
$(TYPEDEF)

TODO refactor msgs into only a single variable
"""
mutable struct DownReturnBPType
dwnMsg::LikelihoodMessage
dbgDwn::DebugCliqMCMC
IDvals::Dict{Symbol,TreeBelief}
keepdwnmsgs::LikelihoodMessage
end


"""
$(TYPEDEF)
"""
mutable struct MsgPassType
fg::GraphsDFG
cliq::TreeClique
vid::Symbol # Int
msgs::Array{LikelihoodMessage,1}
N::Int
end



### EVERYTHING BELOW IS/SHOULD BE DEPRECATED


Expand Down
34 changes: 34 additions & 0 deletions src/CliqueTypes.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Clique types


## Cliques

"""
$(TYPEDEF)
Structure to store clique data
DEV NOTES: To replace TreeClique completely
$(FIELDS)
"""
mutable struct TreeClique
index::Int # see issue #540
label::Symbol #NOTE this is currently a label such as clique 1, # The drawing label is saved in attributes, JT I'm not sure of the current use
data::Any#BayesTreeNodeData #FIXME There is circular type usage in TreeClique, BayesTreeNodeData, CliqStateMachineContainer https://github.com/JuliaLang/julia/issues/269
attributes::Dict{String, Any} #The drawing attributes
#solveInProgress #on a clique level a "solve in progress" might be very handy
end

TreeClique(i::Int, label::Symbol) = TreeClique(i, label, emptyBTNodeData(), Dict{String,Any}())
TreeClique(i::Int, label::AbstractString) = TreeClique(i, Symbol(label))

Graphs.make_vertex(g::AbstractGraph{TreeClique}, label::AbstractString) = TreeClique(num_vertices(g) + 1, String(label))
Graphs.vertex_index(v::TreeClique) = v.index
Graphs.attributes(v::TreeClique, g::AbstractGraph) = v.attributes

#TODO the label field and label atribute is a bit confusing with accessors.
DFG.getLabel(cliq::TreeClique) = cliq.attributes["label"]
function setLabel!(cliq::TreeClique, lbl::String)
cliq.attributes["label"] = lbl
lbl
end

## end Cliques
1 change: 1 addition & 0 deletions src/IncrementalInference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ const InMemDFGType = DFG.LightDFG{SolverParams} #swap out default in v0.8.0/v0.9

include("AliasScalarSampling.jl")
include("DefaultNodeTypes.jl")
include("CliqueTypes.jl")
include("BeliefTypes.jl")
include("JunctionTreeTypes.jl")
include("FactorGraph.jl")
Expand Down
98 changes: 0 additions & 98 deletions src/JunctionTreeTypes.jl
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
using MetaGraphs

## Cliques

"""
$(TYPEDEF)
Structure to store clique data
DEV NOTES: To replace TreeClique completely
$(FIELDS)
"""
mutable struct TreeClique
index::Int # see issue #540
label::Symbol #NOTE this is currently a label such as clique 1, # The drawing label is saved in attributes, JT I'm not sure of the current use
data::Any#BayesTreeNodeData #FIXME There is circular type usage in TreeClique, BayesTreeNodeData, CliqStateMachineContainer https://github.com/JuliaLang/julia/issues/269
attributes::Dict{String, Any} #The drawing attributes
#solveInProgress #on a clique level a "solve in progress" might be very handy
end

TreeClique(i::Int, label::Symbol) = TreeClique(i, label, emptyBTNodeData(), Dict{String,Any}())
TreeClique(i::Int, label::AbstractString) = TreeClique(i, Symbol(label))

Graphs.make_vertex(g::AbstractGraph{TreeClique}, label::AbstractString) = TreeClique(num_vertices(g) + 1, String(label))
Graphs.vertex_index(v::TreeClique) = v.index
Graphs.attributes(v::TreeClique, g::AbstractGraph) = v.attributes

#TODO the label field and label atribute is a bit confusing with accessors.
DFG.getLabel(cliq::TreeClique) = cliq.attributes["label"]
function setLabel!(cliq::TreeClique, lbl::String)
cliq.attributes["label"] = lbl
lbl
end

## end Cliques

## Bayes Trees

Expand Down Expand Up @@ -336,61 +305,6 @@ end



"""
$(TYPEDEF)
"""
mutable struct PotProd
Xi::Symbol # Int
prev::Array{Float64,2}
product::Array{Float64,2}
potentials::Array{BallTreeDensity,1}
potentialfac::Vector{Symbol}
end
"""
$(TYPEDEF)
"""
mutable struct CliqGibbsMC
prods::Array{PotProd,1}
lbls::Vector{Symbol}
CliqGibbsMC() = new()
CliqGibbsMC(a,b) = new(a,b)
end
"""
$(TYPEDEF)
"""
mutable struct DebugCliqMCMC
mcmc::Union{Nothing, Array{CliqGibbsMC,1}}
outmsg::LikelihoodMessage
outmsglbls::Dict{Symbol, Symbol} # Int
priorprods::Vector{CliqGibbsMC}
DebugCliqMCMC() = new()
DebugCliqMCMC(a,b,c,d) = new(a,b,c,d)
end

"""
$(TYPEDEF)
"""
mutable struct UpReturnBPType
upMsgs::LikelihoodMessage
dbgUp::DebugCliqMCMC
IDvals::Dict{Symbol, TreeBelief}
keepupmsgs::LikelihoodMessage # Dict{Symbol, BallTreeDensity} # TODO Why separate upMsgs?
totalsolve::Bool
UpReturnBPType() = new()
UpReturnBPType(x1,x2,x3,x4,x5) = new(x1,x2,x3,x4,x5)
end

"""
$(TYPEDEF)

TODO refactor msgs into only a single variable
"""
mutable struct DownReturnBPType
dwnMsg::LikelihoodMessage
dbgDwn::DebugCliqMCMC
IDvals::Dict{Symbol,TreeBelief}
keepdwnmsgs::LikelihoodMessage
end

"""
$(TYPEDEF)
Expand All @@ -416,18 +330,6 @@ function ExploreTreeType(fgl::G,
ExploreTreeType{T}(fgl, btl, vertl, prt, msgs)
end

"""
$(TYPEDEF)
"""
mutable struct MsgPassType
fg::GraphsDFG
cliq::TreeClique
vid::Symbol # Int
msgs::Array{LikelihoodMessage,1}
N::Int
end




mutable struct PackedBayesTreeNodeData
Expand Down