From 0136f23e6f087f6bbe4f9857f58cf2a06b3ed0f3 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Fri, 11 Oct 2019 17:09:26 +0200 Subject: [PATCH 01/13] update setVariablePosteriorEstimates! --- src/CliqStateMachineUtils.jl | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/CliqStateMachineUtils.jl b/src/CliqStateMachineUtils.jl index daec6a8a1..2c9b1c170 100644 --- a/src/CliqStateMachineUtils.jl +++ b/src/CliqStateMachineUtils.jl @@ -638,28 +638,29 @@ function areSiblingsRemaingNeedDownOnly(tree::BayesTree, return true end +function setVariablePosteriorEstimates!(var::DFG.DFGVariable )::Nothing -function setVariablePosteriorEstimates!(subfg::G, - sym::Symbol )::Nothing where G <: AbstractDFG - # - - var = getVariable(subfg, sym) bel = getKDE(var) ops = buildHybridManifoldCallbacks(getManifolds(var)) - @show varMax = getKDEMax(bel, addop=ops[1], diffop=ops[2]) - @show varMean = getKDEMean(bel) - # TODO: We need to populate PPE. - @show varPpe = deepcopy(varMax) #TODO + varMax = getKDEMax(bel, addop=ops[1], diffop=ops[2]) + varMean = getKDEMean(bel) + # TODO: We need to populate varModeMeans. + # varModeMeans = ... - var.estimateDict[:default] = Dict{Symbol, VariableEstimate}( - :max => VariableEstimate(:default, :max, varMax), - :mean => VariableEstimate(:default, :mean, varMean), - :ppe => VariableEstimate(:default, :ppe, varPpe)) + defaultestdict = get!(var.estimateDict, :default, Dict{Symbol, VariableEstimate}()) + defaultestdict[:max] = VariableEstimate(:default, :max, varMax) + defaultestdict[:mean] = VariableEstimate(:default, :mean, varMean) + #FIXME defaultestdict[:mode_means] = VariableEstimate(:default, softtype, varModeMeans) return nothing end +function setVariablePosteriorEstimates!(subfg::AbstractDFG, + sym::Symbol )::Nothing + setVariablePosteriorEstimates!(getVariable(subfg, sym)) +end + """ $SIGNATURES From b092a0e035ec22159a3416f6df67d264dd78d7c2 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Fri, 11 Oct 2019 17:11:56 +0200 Subject: [PATCH 02/13] call setVariablePosteriorEstimates in doautoinit! --- src/FactorGraph01.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/FactorGraph01.jl b/src/FactorGraph01.jl index b7b5cf4be..48697bfd2 100644 --- a/src/FactorGraph01.jl +++ b/src/FactorGraph01.jl @@ -737,6 +737,8 @@ function doautoinit!(dfg::T, end pts,inferdim = predictbelief(dfg, vsym, useinitfct, logger=logger) setValKDE!(xi, pts, true, inferdim) + #TODO test + setVariablePosteriorEstimates!(xi) didinit = true end end From 4b5dfae23541ccaa83c220f1ba1c1afbfd60cff9 Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Thu, 17 Oct 2019 10:43:10 +0200 Subject: [PATCH 03/13] Defautl initfg set by InMemDFGType constant --- src/FactorGraphTypes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FactorGraphTypes.jl b/src/FactorGraphTypes.jl index 0d9c5555a..c4cb739f0 100644 --- a/src/FactorGraphTypes.jl +++ b/src/FactorGraphTypes.jl @@ -156,7 +156,7 @@ end Initialize an empty in-memory DistributedFactorGraph `::DistributedFactorGraph` object. """ -function initfg(dfg::T=GraphsDFG{SolverParams}(params=SolverParams()); +function initfg(dfg::T=InMemDFGType(params=SolverParams()); sessionname="NA", robotname="", username="", From 1b1c98016b01753ba7595a748932c8d085ccb06b Mon Sep 17 00:00:00 2001 From: Johannes Terblanche Date: Fri, 25 Oct 2019 16:16:11 +0200 Subject: [PATCH 04/13] VariableEstimate -> MeanMaxPPE --- Project.toml | 2 +- src/CliqStateMachineUtils.jl | 33 +++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Project.toml b/Project.toml index cceca6646..3949030d2 100644 --- a/Project.toml +++ b/Project.toml @@ -32,7 +32,7 @@ SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [compat] ApproxManifoldProducts = "0.1, 0.2" -DistributedFactorGraphs = "0.4.1" +DistributedFactorGraphs = "0.5" Distributions = "0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25, 1" DocStringExtensions = "0.7, 0.8, 0.9, 0.10, 1" FileIO = "1.0.2, 1.1, 1.2" diff --git a/src/CliqStateMachineUtils.jl b/src/CliqStateMachineUtils.jl index 2c9b1c170..978f5c3f0 100644 --- a/src/CliqStateMachineUtils.jl +++ b/src/CliqStateMachineUtils.jl @@ -638,27 +638,36 @@ function areSiblingsRemaingNeedDownOnly(tree::BayesTree, return true end -function setVariablePosteriorEstimates!(var::DFG.DFGVariable )::Nothing +# TODO consider a more fiting name. +function setVariablePosteriorEstimates!(var::DFG.DFGVariable, solveKey::Symbol=:default)::DFG.DFGVariable + # JT TODO solve key might be needed if one only wants to update one + # I guess it would make sense that :default=>variableNodeData, goes with :default=>MeanMaxPPE - bel = getKDE(var) - ops = buildHybridManifoldCallbacks(getManifolds(var)) + vnd = solverData(var, solveKey) + + bel = getKDE(vnd) + ops = buildHybridManifoldCallbacks(getManifolds(vnd)) varMax = getKDEMax(bel, addop=ops[1], diffop=ops[2]) varMean = getKDEMean(bel) - # TODO: We need to populate varModeMeans. - # varModeMeans = ... - defaultestdict = get!(var.estimateDict, :default, Dict{Symbol, VariableEstimate}()) - defaultestdict[:max] = VariableEstimate(:default, :max, varMax) - defaultestdict[:mean] = VariableEstimate(:default, :mean, varMean) - #FIXME defaultestdict[:mode_means] = VariableEstimate(:default, softtype, varModeMeans) + #TODO in the future one can perhaps populate other solver data types here by looking at the typeof estimateDict entries + var.estimateDict[solveKey] = MeanMaxPPE(solveKey, varMax, varMean) - return nothing + return var end function setVariablePosteriorEstimates!(subfg::AbstractDFG, - sym::Symbol )::Nothing - setVariablePosteriorEstimates!(getVariable(subfg, sym)) + sym::Symbol )::DFG.DFGVariable + var = setVariablePosteriorEstimates!(getVariable(subfg, sym)) + # JT - TODO if subfg is in the cloud or from another fg it has to be updated + # it feels like a waste to update the whole vairable for one field. + # currently i could find mergeUpdateVariableSolverData() + # might be handy to use a setter such as updatePointParametricEst(dfg, variable, solverkey) + # This might also not be the correct place, if it is uncomment: + # if (subfg <: InMemoryDFGTypes) + # updateVariable!(subfg, var) + # end end """ From 16542aafeb211843c1d5f87b1be186622a593f45 Mon Sep 17 00:00:00 2001 From: dehann Date: Sun, 17 Nov 2019 15:18:24 -0500 Subject: [PATCH 05/13] expanding on variable estimates PPE --- src/CliqStateMachineUtils.jl | 32 +++++++++++++++------ src/FGOSUtils.jl | 55 ++++++++++++++++++++++++++++++++++++ src/IncrementalInference.jl | 2 ++ 3 files changed, 80 insertions(+), 9 deletions(-) diff --git a/src/CliqStateMachineUtils.jl b/src/CliqStateMachineUtils.jl index 978f5c3f0..d3a25831a 100644 --- a/src/CliqStateMachineUtils.jl +++ b/src/CliqStateMachineUtils.jl @@ -638,22 +638,35 @@ function areSiblingsRemaingNeedDownOnly(tree::BayesTree, return true end -# TODO consider a more fiting name. +""" + $SIGNATURES + +Calculate new and then set PPE estimates for variable from some distributed factor graph. + +DevNotes +- TODO solve key might be needed if one only wants to update one +- TODO consider a more fiting name. +- guess it would make sense that :default=>variableNodeData, goes with :default=>MeanMaxPPE + +Related + +calcVariablePPE +""" function setVariablePosteriorEstimates!(var::DFG.DFGVariable, solveKey::Symbol=:default)::DFG.DFGVariable - # JT TODO solve key might be needed if one only wants to update one - # I guess it would make sense that :default=>variableNodeData, goes with :default=>MeanMaxPPE vnd = solverData(var, solveKey) - bel = getKDE(vnd) - ops = buildHybridManifoldCallbacks(getManifolds(vnd)) - - varMax = getKDEMax(bel, addop=ops[1], diffop=ops[2]) - varMean = getKDEMean(bel) + # bel = getKDE(vnd) + # ops = buildHybridManifoldCallbacks(getManifolds(vnd)) + # + # varMax = getKDEMax(bel, addop=ops[1], diffop=ops[2]) + # varMean = getKDEMean(bel) #TODO in the future one can perhaps populate other solver data types here by looking at the typeof estimateDict entries - var.estimateDict[solveKey] = MeanMaxPPE(solveKey, varMax, varMean) + ## calcVariablePPE!(var.estimateDict[solveKey], var) + var.estimateDict[solveKey] = calcVariablePPE(MeanMaxPPE, var) + # var.estimateDict[solveKey] = MeanMaxPPE(solveKey, varMax, varMean) return var end @@ -670,6 +683,7 @@ function setVariablePosteriorEstimates!(subfg::AbstractDFG, # end end + """ $SIGNATURES diff --git a/src/FGOSUtils.jl b/src/FGOSUtils.jl index 6c91bd761..8ea62cedf 100644 --- a/src/FGOSUtils.jl +++ b/src/FGOSUtils.jl @@ -27,6 +27,61 @@ getDimension(var::DFGVariable) = getSofttype(var).dims getDimension(fct::DFGFactor) = solverData(fct).fnc.zDim + +""" + $SIGNATURES + +In-place memory version of `calcVariablePPE`. + +DevNotes +- TODO update for manifold subgroups. +""" +function calcVariablePPE!(retval::Vector{Float64}, + var::DFGVariable, + softt::InferenceVariable; + method::Symbol=:meanmax )::Nothing + # + @assert method == :meanmax + P = getKDE(var) + manis = getManifolds(softt) # getManifolds(vnd) + ops = buildHybridManifoldCallbacks(manis) + Pme = getKDEMean(P, addop=ops[1], diffop=ops[2]) + Pma = getKDEMax(P, addop=ops[1], diffop=ops[2]) + for i in 1:length(manis) + mani = manis[i] + if mani == :Euclid + retval[i] = Pme[i] + elseif mani == :Circular + retval[i] = Pma[i] + else + error("Unknown manifold to find PPE, $softt, $mani") + end + end + nothing +end + + +""" + $SIGNATURES + +Get the ParametricPointEstimates---based on full marginal belief estimates---of a variable in the distributed factor graph. +""" +function calcVariablePPE(var::DFGVariable, + softt::InferenceVariable; + method::Symbol=:meanmax )::Vector{Float64} + # + vect = zeros(softt.dims) + calcVariablePPE!(vect, var, softt, method=method) + return vect +end + +calcVariablePPE!(retvec::Vector{Float64}, var::DFGVariable; method::Symbol=:meanmax) = calcVariablePPE!(retvec, var, getSofttype(var), method=method) +calcVariablePPE(var::DFGVariable; method::Symbol=:meanmax) = calcVariablePPE(var, getSofttype(var), method=method) +function calcVariablePPE(dfg::AbstractDFG, sym::Symbol; method::Symbol=:meanmax) + var = getVariable(dfg, sym) + calcVariablePPE(var, getSofttype(var), method=method) +end + """ $(SIGNATURES) diff --git a/src/IncrementalInference.jl b/src/IncrementalInference.jl index d754b8868..4fe8a06d5 100644 --- a/src/IncrementalInference.jl +++ b/src/IncrementalInference.jl @@ -125,6 +125,8 @@ export ls, lsf, getVariableIds, + calcVariablePPE!, + calcVariablePPE, sortVarNested, hasOrphans, drawCopyFG, From 0c12eb12648735d72127b188f182ae93a5284ec8 Mon Sep 17 00:00:00 2001 From: dehann Date: Sun, 17 Nov 2019 15:55:21 -0500 Subject: [PATCH 06/13] upstreamed --- src/FGOSUtils.jl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/FGOSUtils.jl b/src/FGOSUtils.jl index 2f8a491c6..4e979fafc 100644 --- a/src/FGOSUtils.jl +++ b/src/FGOSUtils.jl @@ -2,10 +2,6 @@ # IIF methods should direclty detect extended types from user import # of convert in their namespace -import Base:* - -*(a::Symbol, b::AbstractString)::Symbol = Symbol(string(a,b)) - manikde!(pts::AbstractArray{Float64,2}, vartype::InferenceVariable) = manikde!(pts, getManifolds(vartype)) manikde!(pts::AbstractArray{Float64,2}, vartype::Type{<:InferenceVariable}) = manikde!(pts, getManifolds(vartype)) @@ -63,6 +59,9 @@ function calcVariablePPE!(retval::Vector{Float64}, nothing end +function calcVariablePPE() + +end """ $SIGNATURES @@ -70,8 +69,8 @@ end Get the ParametricPointEstimates---based on full marginal belief estimates---of a variable in the distributed factor graph. """ function calcVariablePPE(var::DFGVariable, - softt::InferenceVariable; - method::Symbol=:meanmax )::Vector{Float64} + softt::InferenceVariable; + method::Symbol=:meanmax )::Vector{Float64} # vect = zeros(softt.dims) calcVariablePPE!(vect, var, softt, method=method) From aa93e455e4def60d206e7fa57815cb39dcbd5c61 Mon Sep 17 00:00:00 2001 From: dehann Date: Sun, 17 Nov 2019 20:12:40 -0500 Subject: [PATCH 07/13] use MeanMaxPPE as method --- src/FGOSUtils.jl | 82 ++++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/src/FGOSUtils.jl b/src/FGOSUtils.jl index 4e979fafc..fc234aa83 100644 --- a/src/FGOSUtils.jl +++ b/src/FGOSUtils.jl @@ -30,56 +30,76 @@ getDimension(fct::DFGFactor) = solverData(fct).fnc.zDim """ $SIGNATURES -In-place memory version of `calcVariablePPE`. +Get the ParametricPointEstimates---based on full marginal belief estimates---of a variable in the distributed factor graph. DevNotes - TODO update for manifold subgroups. """ -function calcVariablePPE!(retval::Vector{Float64}, - var::DFGVariable, - softt::InferenceVariable; - method::Symbol=:meanmax )::Nothing +function calcVariablePPE(var::DFGVariable, + softt::InferenceVariable; + solverKey::Symbol=:default, + method::Type{MeanMaxPPE}=MeanMaxPPE )::MeanMaxPPE # - @assert method == :meanmax P = getKDE(var) manis = getManifolds(softt) # getManifolds(vnd) ops = buildHybridManifoldCallbacks(manis) Pme = getKDEMean(P, addop=ops[1], diffop=ops[2]) Pma = getKDEMax(P, addop=ops[1], diffop=ops[2]) + suggested = zeros(getDimension(var)) + # TODO standardize after AMP3D + @assert length(manis) == getDimension(var) for i in 1:length(manis) mani = manis[i] if mani == :Euclid - retval[i] = Pme[i] + suggested[i] = Pme[i] elseif mani == :Circular - retval[i] = Pma[i] + suggested[i] = Pma[i] else error("Unknown manifold to find PPE, $softt, $mani") end end - nothing -end - -function calcVariablePPE() - + MeanMaxPPE(solverKey, suggested, Pma, Pme, now()) end - -""" - $SIGNATURES - -Get the ParametricPointEstimates---based on full marginal belief estimates---of a variable in the distributed factor graph. -""" -function calcVariablePPE(var::DFGVariable, - softt::InferenceVariable; - method::Symbol=:meanmax )::Vector{Float64} - # - vect = zeros(softt.dims) - calcVariablePPE!(vect, var, softt, method=method) - return vect -end - -calcVariablePPE!(retvec::Vector{Float64}, var::DFGVariable; method::Symbol=:meanmax) = calcVariablePPE!(retvec, var, getSofttype(var), method=method) -calcVariablePPE(var::DFGVariable; method::Symbol=:meanmax) = calcVariablePPE(var, getSofttype(var), method=method) -function calcVariablePPE(dfg::AbstractDFG, sym::Symbol; method::Symbol=:meanmax) +# function calcVariablePPE!(retval::Vector{Float64}, +# var::DFGVariable, +# softt::InferenceVariable; +# method::Type{MeanMaxPPE}=MeanMaxPPE )::Nothing +# # +# P = getKDE(var) +# manis = getManifolds(softt) # getManifolds(vnd) +# ops = buildHybridManifoldCallbacks(manis) +# Pme = getKDEMean(P, addop=ops[1], diffop=ops[2]) +# Pma = getKDEMax(P, addop=ops[1], diffop=ops[2]) +# for i in 1:length(manis) +# mani = manis[i] +# if mani == :Euclid +# retval[i] = Pme[i] +# elseif mani == :Circular +# retval[i] = Pma[i] +# else +# error("Unknown manifold to find PPE, $softt, $mani") +# end +# end +# nothing +# end +# """ +# $SIGNATURES +# +# Get the ParametricPointEstimates---based on full marginal belief estimates---of a variable in the distributed factor graph. +# """ +# function calcVariablePPE(var::DFGVariable, +# softt::InferenceVariable; +# method::Type{<:AbstractParametricEst}=MeanMaxPPE )::Vector{Float64} +# # +# # vect = zeros(softt.dims) +# mmppe = calcVariablePPE(MeanMaxPPE, var, softt, method=method) +# return mmppe.suggested +# end + + +# calcVariablePPE!(retvec::Vector{Float64}, var::DFGVariable; method::Type{<:AbstractParametricEst}=MeanMaxPPE) = calcVariablePPE!(retvec, var, getSofttype(var), method=method) +calcVariablePPE(var::DFGVariable; method::Type{<:AbstractParametricEst}=MeanMaxPPE) = calcVariablePPE(var, getSofttype(var), method=method) +function calcVariablePPE(dfg::AbstractDFG, sym::Symbol; method::Type{<:AbstractParametricEst}=MeanMaxPPE) var = getVariable(dfg, sym) calcVariablePPE(var, getSofttype(var), method=method) end From ea1aa420a54cc99e92b01ed3ce0f56a520d878a5 Mon Sep 17 00:00:00 2001 From: dehann Date: Sun, 17 Nov 2019 20:23:24 -0500 Subject: [PATCH 08/13] updates, still to test --- src/CliqStateMachineUtils.jl | 10 +--------- src/FGOSUtils.jl | 10 +++++----- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/CliqStateMachineUtils.jl b/src/CliqStateMachineUtils.jl index 2f3a38819..937f71492 100644 --- a/src/CliqStateMachineUtils.jl +++ b/src/CliqStateMachineUtils.jl @@ -656,17 +656,9 @@ function setVariablePosteriorEstimates!(var::DFG.DFGVariable, solveKey::Symbol=: vnd = solverData(var, solveKey) - # bel = getKDE(vnd) - # ops = buildHybridManifoldCallbacks(getManifolds(vnd)) - # - # varMax = getKDEMax(bel, addop=ops[1], diffop=ops[2]) - # varMean = getKDEMean(bel) - #TODO in the future one can perhaps populate other solver data types here by looking at the typeof estimateDict entries - ## calcVariablePPE!(var.estimateDict[solveKey], var) - var.estimateDict[solveKey] = calcVariablePPE(MeanMaxPPE, var) + var.estimateDict[solveKey] = calcVariablePPE(var, method=MeanMaxPPE, solveKey=solveKey) - # var.estimateDict[solveKey] = MeanMaxPPE(solveKey, varMax, varMean) return var end diff --git a/src/FGOSUtils.jl b/src/FGOSUtils.jl index fc234aa83..3cdbbf44e 100644 --- a/src/FGOSUtils.jl +++ b/src/FGOSUtils.jl @@ -37,7 +37,7 @@ DevNotes """ function calcVariablePPE(var::DFGVariable, softt::InferenceVariable; - solverKey::Symbol=:default, + solveKey::Symbol=:default, method::Type{MeanMaxPPE}=MeanMaxPPE )::MeanMaxPPE # P = getKDE(var) @@ -58,7 +58,7 @@ function calcVariablePPE(var::DFGVariable, error("Unknown manifold to find PPE, $softt, $mani") end end - MeanMaxPPE(solverKey, suggested, Pma, Pme, now()) + MeanMaxPPE(solveKey, suggested, Pma, Pme, now()) end # function calcVariablePPE!(retval::Vector{Float64}, # var::DFGVariable, @@ -98,10 +98,10 @@ end # calcVariablePPE!(retvec::Vector{Float64}, var::DFGVariable; method::Type{<:AbstractParametricEst}=MeanMaxPPE) = calcVariablePPE!(retvec, var, getSofttype(var), method=method) -calcVariablePPE(var::DFGVariable; method::Type{<:AbstractParametricEst}=MeanMaxPPE) = calcVariablePPE(var, getSofttype(var), method=method) -function calcVariablePPE(dfg::AbstractDFG, sym::Symbol; method::Type{<:AbstractParametricEst}=MeanMaxPPE) +calcVariablePPE(var::DFGVariable; method::Type{<:AbstractParametricEst}=MeanMaxPPE, solveKey::Symbol=:default) = calcVariablePPE(var, getSofttype(var), method=method, solveKey=solveKey) +function calcVariablePPE(dfg::AbstractDFG, sym::Symbol; method::Type{<:AbstractParametricEst}=MeanMaxPPE, solveKey::Symbol=:default ) var = getVariable(dfg, sym) - calcVariablePPE(var, getSofttype(var), method=method) + calcVariablePPE(var, getSofttype(var), method=method, solveKey=solveKey) end """ From 5d98fecbda79a4b07006f0f10afcfea0d6a77ab0 Mon Sep 17 00:00:00 2001 From: dehann Date: Sun, 17 Nov 2019 20:54:25 -0500 Subject: [PATCH 09/13] fix UndefVarError: compareFactorGraphs not defined --- src/FGOSUtils.jl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/FGOSUtils.jl b/src/FGOSUtils.jl index 3cdbbf44e..c03e1a469 100644 --- a/src/FGOSUtils.jl +++ b/src/FGOSUtils.jl @@ -2,6 +2,7 @@ # IIF methods should direclty detect extended types from user import # of convert in their namespace +import DistributedFactorGraphs: AbstractPointParametricEst manikde!(pts::AbstractArray{Float64,2}, vartype::InferenceVariable) = manikde!(pts, getManifolds(vartype)) manikde!(pts::AbstractArray{Float64,2}, vartype::Type{<:InferenceVariable}) = manikde!(pts, getManifolds(vartype)) @@ -43,7 +44,7 @@ function calcVariablePPE(var::DFGVariable, P = getKDE(var) manis = getManifolds(softt) # getManifolds(vnd) ops = buildHybridManifoldCallbacks(manis) - Pme = getKDEMean(P, addop=ops[1], diffop=ops[2]) + Pme = getKDEMean(P) #, addop=ops[1], diffop=ops[2] Pma = getKDEMax(P, addop=ops[1], diffop=ops[2]) suggested = zeros(getDimension(var)) # TODO standardize after AMP3D @@ -89,7 +90,7 @@ end # """ # function calcVariablePPE(var::DFGVariable, # softt::InferenceVariable; -# method::Type{<:AbstractParametricEst}=MeanMaxPPE )::Vector{Float64} +# method::Type{<:AbstractPointParametricEst}=MeanMaxPPE )::Vector{Float64} # # # # vect = zeros(softt.dims) # mmppe = calcVariablePPE(MeanMaxPPE, var, softt, method=method) @@ -97,9 +98,9 @@ end # end -# calcVariablePPE!(retvec::Vector{Float64}, var::DFGVariable; method::Type{<:AbstractParametricEst}=MeanMaxPPE) = calcVariablePPE!(retvec, var, getSofttype(var), method=method) -calcVariablePPE(var::DFGVariable; method::Type{<:AbstractParametricEst}=MeanMaxPPE, solveKey::Symbol=:default) = calcVariablePPE(var, getSofttype(var), method=method, solveKey=solveKey) -function calcVariablePPE(dfg::AbstractDFG, sym::Symbol; method::Type{<:AbstractParametricEst}=MeanMaxPPE, solveKey::Symbol=:default ) +# calcVariablePPE!(retvec::Vector{Float64}, var::DFGVariable; method::Type{<:AbstractPointParametricEst}=MeanMaxPPE) = calcVariablePPE!(retvec, var, getSofttype(var), method=method) +calcVariablePPE(var::DFGVariable; method::Type{<:AbstractPointParametricEst}=MeanMaxPPE, solveKey::Symbol=:default) = calcVariablePPE(var, getSofttype(var), method=method, solveKey=solveKey) +function calcVariablePPE(dfg::AbstractDFG, sym::Symbol; method::Type{<:AbstractPointParametricEst}=MeanMaxPPE, solveKey::Symbol=:default ) var = getVariable(dfg, sym) calcVariablePPE(var, getSofttype(var), method=method, solveKey=solveKey) end From ab919ee5aec23e71c544a39af5751f9cd389633f Mon Sep 17 00:00:00 2001 From: dehann Date: Sun, 17 Nov 2019 21:09:20 -0500 Subject: [PATCH 10/13] remove excess export --- src/IncrementalInference.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/IncrementalInference.jl b/src/IncrementalInference.jl index 7f8fb86e6..2f1386509 100644 --- a/src/IncrementalInference.jl +++ b/src/IncrementalInference.jl @@ -126,7 +126,6 @@ export ls, lsf, getVariableIds, - calcVariablePPE!, calcVariablePPE, sortVarNested, hasOrphans, From 38a3a7bab7ca58ec0723b3dc20ccf33ec0b65b12 Mon Sep 17 00:00:00 2001 From: gearsad Date: Sun, 17 Nov 2019 20:27:32 -0600 Subject: [PATCH 11/13] Fix for tests - note that having different estimates will fail in compare --- test/testCompareVariablesFactors.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/testCompareVariablesFactors.jl b/test/testCompareVariablesFactors.jl index 305b79ca0..40b2ac07e 100644 --- a/test/testCompareVariablesFactors.jl +++ b/test/testCompareVariablesFactors.jl @@ -1,5 +1,6 @@ # using Revise +using DistributedFactorGraphs using IncrementalInference using Test @@ -52,7 +53,9 @@ x1b = getVariable(fg2, :x0) ensureAllInitialized!(fg2) -@test compareSimilarVariables(fg, fg2, skipsamples=true, skip=Symbol[:initialized;:inferdim]) +@test compareSimilarVariables(fg, fg2, skipsamples=true, skip=Symbol[:initialized;:inferdim;:estimateDict]) +# fg2 has been solved, so it should fail on the estimate dictionary +@test !compareSimilarVariables(fg, fg2, skipsamples=true, skip=Symbol[:initialized;:inferdim]) tree = wipeBuildNewTree!(fg2) @@ -60,7 +63,7 @@ tree = wipeBuildNewTree!(fg2) @test !compareSimilarFactors(fg, fg2, skipsamples=true, skipcompute=false) -@test compareFactorGraphs(fg, fg2, skipsamples=true, skipcompute=true, skip=[:initialized;:inferdim]) +@test compareFactorGraphs(fg, fg2, skipsamples=true, skipcompute=true, skip=[:initialized;:inferdim;:estimateDict]) end From 537d11e23ddec88c22fbf88fd9911f675560ca08 Mon Sep 17 00:00:00 2001 From: gearsad Date: Sun, 17 Nov 2019 20:53:15 -0600 Subject: [PATCH 12/13] Moving compare factor data to DFG --- src/DispatchPackedConversions.jl | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/DispatchPackedConversions.jl b/src/DispatchPackedConversions.jl index dc35d5ac5..7583c34f5 100644 --- a/src/DispatchPackedConversions.jl +++ b/src/DispatchPackedConversions.jl @@ -58,23 +58,6 @@ end - - -# Compare FunctionNodeData -function compare(a::GenericFunctionNodeData{T1,S},b::GenericFunctionNodeData{T2,S}) where {T1, T2, S} - # TODO -- beef up this comparison to include the gwp - TP = true - TP = TP && a.fncargvID == b.fncargvID - TP = TP && a.eliminated == b.eliminated - TP = TP && a.potentialused == b.potentialused - TP = TP && a.edgeIDs == b.edgeIDs - TP = TP && a.frommodule == b.frommodule - # TP = TP && typeof(a.fnc) == typeof(b.fnc) - return TP -end - - - function convert(::Type{PT}, ::T) where {PT <: PackedInferenceType, T <:FunctorInferenceType} getfield(T.name.module, Symbol("Packed$(T.name.name)")) end From d942aa55c7ed95ddcf675243a9b5563c61bd8b3a Mon Sep 17 00:00:00 2001 From: gearsad Date: Sun, 17 Nov 2019 21:27:14 -0600 Subject: [PATCH 13/13] Import compare before export to avoid conflict --- src/IncrementalInference.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IncrementalInference.jl b/src/IncrementalInference.jl index 2f1386509..e9eecbeca 100644 --- a/src/IncrementalInference.jl +++ b/src/IncrementalInference.jl @@ -40,7 +40,7 @@ import Distributions: sample import Random: rand, rand! import KernelDensityEstimate: getBW import ApproxManifoldProducts: kde!, manikde! -import DistributedFactorGraphs: addVariable!, addFactor!, ls, lsf, isInitialized, hasOrphans +import DistributedFactorGraphs: addVariable!, addFactor!, ls, lsf, isInitialized, hasOrphans, compare, compareAllSpecial # missing exports import DistributedFactorGraphs: PackedFunctionNodeData, FunctionNodeData