-
Notifications
You must be signed in to change notification settings - Fork 2
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
variable solver data concept #231
Changes from 3 commits
fe10a1a
653242f
068a2fe
7a4b3c0
e73e71d
0a43a5d
2577077
f5733fd
37f091b
0a0f924
740c675
53da464
0b9fc6f
456a35a
1cc1f2d
62ce777
6a7c1bd
221989c
5ad243d
d7d26ed
1d4b52d
1187929
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -499,6 +499,82 @@ function _copyIntoGraph!(sourceDFG::G, destDFG::H, variableFactorLabels::Vector{ | |
return nothing | ||
end | ||
|
||
#TODO UNTESTED and NOT FILLED IN, just to define function signatures | ||
""" | ||
$(SIGNATURES) | ||
""" | ||
function getVariableSolverData(dfg::AbstractDFG, variablekey::Symbol, solvekey::Symbol=:default) | ||
error("not implemented") | ||
return deepcopy(solverData(getVariable(dfg, variablekey), solvekey)) | ||
end | ||
|
||
""" | ||
$(SIGNATURES) | ||
""" | ||
function addVariableSolverData!(dfg::AbstractDFG, vnd::VariableNodeData, variablekey::Symbol, solvekey::Symbol=:default) | ||
#for InMemoryDFGTypes, cloud would update here | ||
error("not implemented") | ||
|
||
var = getVariable(dfg, variablekey) | ||
|
||
if haskey(var.solverDataDict, solvekey) | ||
error("VariableNodeData '$(solvekey)' already exists") | ||
end | ||
|
||
#var.solverDataDict[solvekey] = vnd | ||
|
||
setSolverData(var, deepcopy(vnd), key) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see updated api in master to include an |
||
|
||
end | ||
|
||
addVariableSolverData!(dfg::AbstractDFG, sourceVariable::DFGVariable, solvekey::Symbol=:default) = | ||
addVariableSolverData!(dfg, solverData(sourceVariable, solvekey), sourceVariable.label, solvekey) | ||
|
||
|
||
""" | ||
$(SIGNATURES) | ||
""" | ||
function updateVariableSolverData!(dfg::AbstractDFG, vnd::VariableNodeData, variablekey::Symbol, solvekey::Symbol=:default) | ||
error("not implemented") | ||
#This is basically just setSolverData with a copy | ||
var = getVariable(dfg, variablekey) | ||
|
||
#var.solverDataDict[solvekey] = deepcopy(vnd) | ||
#for InMemoryDFGTypes, cloud would update here | ||
setSolverData(var, deepcopy(vnd), key) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, why do a deep copy here? You think the user might accidentally point the code to the same vnd object and therefore become incorrect? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should maybe leave the ‘deepcopy’ responsibility to the user. |
||
end | ||
|
||
updateVariableSolverData!(dfg::AbstractDFG, sourceVariable::DFGVariable, solvekey::Symbol=:default) = | ||
updateVariableSolverData!(dfg, solverData(sourceVariable, solvekey), sourceVariable.label, solvekey) | ||
|
||
function updateVariableSolverData!(dfg::AbstractDFG, sourceVariables::Vector{DFGVariable}, solvekey::Symbol=:default) | ||
#I think cloud would do this in bulk for speed | ||
for var in sourceVariables | ||
updateVariableSolverData!(dfg, solverData(var, solvekey), var.label, solvekey) | ||
end | ||
end | ||
|
||
""" | ||
$(SIGNATURES) | ||
""" | ||
function deleteVariableSolverData!(dfg::AbstractDFG, variablekey::Symbol, solvekey::Symbol=:default) | ||
error("not implemented") | ||
|
||
var = getVariable(dfg, variablekey) | ||
|
||
if haskey(var.solverDataDict, solvekey) | ||
error("VariableNodeData '$(solvekey)' already exists") | ||
end | ||
|
||
vnd = pop!(var.solverDataDict, solvekey) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one seems right to me, will think on it more. |
||
|
||
return vnd | ||
end | ||
|
||
deleteVariableSolverData!(dfg::AbstractDFG, sourceVariable::DFGVariable, solvekey::Symbol=:default) = | ||
deleteVariableSolverData!(dfg, sourceVariable.label, solvekey) | ||
|
||
|
||
""" | ||
$(SIGNATURES) | ||
Merges and updates solver and estimate data for a variable (variable can be from another graph). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why a deepcopy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should verb
get
not return the original memory object?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think you are correct.