Skip to content

Commit bff33dd

Browse files
committed
Fix for updateVariabeSolverData and changes to HexagonalCloud example.
1 parent 8591d3a commit bff33dd

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

src/GraphsDFG/services/GraphsDFG.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ function updateVariableSolverData!(dfg::GraphsDFG, sourceVariable::DFGVariable):
172172
if !haskey(dfg.labelDict, sourceVariable.label)
173173
error("Source variable '$(sourceVariable.label)' doesn't exist in the graph.")
174174
end
175-
dfg.g.vertices[dfg.labelDict[variable.label]].dfgNode.estimateDict = deepcopy(variable.estimateDict)
176-
dfg.g.vertices[dfg.labelDict[variable.label]].dfgNode.solverDataDict = deepcopy(variable.solverDataDict)
175+
dfg.g.vertices[dfg.labelDict[sourceVariable.label]].dfgNode.estimateDict = deepcopy(sourceVariable.estimateDict)
176+
dfg.g.vertices[dfg.labelDict[sourceVariable.label]].dfgNode.solverDataDict = deepcopy(sourceVariable.solverDataDict)
177177
return sourceVariable
178178
end
179179

test/HexagonalCloud.jl

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# using Revise
1+
using Revise
22
using Neo4j # So that DFG initializes the database driver.
33
using RoME
44
using DistributedFactorGraphs
55
using Test, Dates
6-
76
# start with an empty factor graph object
87
# fg = initfg()
98
cloudFg = CloudGraphsDFG{SolverParams}("localhost", 7474, "neo4j", "test",
@@ -34,22 +33,34 @@ end
3433
# Right, let's copy it into local memory for solving...
3534
localFg = GraphsDFG{SolverParams}(params=SolverParams())
3635
DistributedFactorGraphs._copyIntoGraph!(cloudFg, localFg, union(getVariableIds(cloudFg), getFactorIds(cloudFg)), true)
36+
# Duplicate for later
37+
localFgCopy = deepcopy(localFg)
38+
3739
# Some checks
3840
@test symdiff(getVariableIds(localFg), getVariableIds(cloudFg)) == []
3941
@test symdiff(getFactorIds(localFg), getFactorIds(cloudFg)) == []
4042
@test isFullyConnected(localFg)
4143
# Show it
4244
toDotFile(localFg, "/tmp/localfg.dot")
4345

44-
tree, smtasks = batchSolve!(localFg, treeinit=true, drawpdf=false, show=false,
45-
returntasks=true, limititers=50,
46-
upsolve=true, downsolve=true )
46+
tree, smtasks = solveTree!(localFg)
47+
48+
# solveTree!(cloudFg)
4749

48-
# Testing writing estimates
50+
# Checking estimates
4951
for variable in getVariables(localFg)
50-
means = mean(getData(variable).val, dims=2)[:]
51-
variable.estimateDict[:default] = Dict{Symbol, VariableEstimate}(:Mean => VariableEstimate(:default, :Mean, means, now()))
52+
@show variable.label
53+
@show variable.estimateDict
54+
55+
# means = mean(getData(variable).val, dims=2)[:]
56+
# variable.estimateDict[:default] = Dict{Symbol, VariableEstimate}(:Mean => VariableEstimate(:default, :Mean, means, now()))
5257
end
5358

59+
bel = getKDE(getVariable(localFg, :x0))
60+
bel
61+
5462
# Push updates back to cloud.
5563
updateGraphSolverData!(localFg, cloudFg, ls(localFg))
64+
65+
# Pull back to local
66+
updateGraphSolverData!(cloudFg, localFgCopy, ls(cloudFg))

0 commit comments

Comments
 (0)