@@ -538,26 +538,15 @@ getSolverDataDict(v::VariableCompute) = v.solverDataDict
538
538
539
539
Retrieve solver data structure stored in a variable.
540
540
"""
541
- function getVariableState (v:: VariableCompute , key:: Symbol = :default )
542
- # TODO this does not fit in with some of the other error behaviour. but its used so added @error
543
- vnd = if haskey (getSolverDataDict (v), key)
544
- return getSolverDataDict (v)[key]
541
+ function getVariableState (v:: VariableCompute , label:: Symbol )
542
+ vnd = if haskey (getSolverDataDict (v), label)
543
+ return getSolverDataDict (v)[label]
545
544
else
546
- throw (LabelNotFoundError (" State" , key ))
545
+ throw (LabelNotFoundError (" State" , label ))
547
546
end
548
547
return vnd
549
548
end
550
549
551
- # TODO Repeated functionality? same as update
552
- """
553
- $SIGNATURES
554
- Set solver data structure stored in a variable.
555
- """
556
- function setSolverData! (v:: VariableCompute , data:: VariableState , key:: Symbol = :default )
557
- @assert key == data. solveKey " VariableState.solveKey=:$(data. solveKey) does not match requested :$(key) "
558
- return v. solverDataDict[key] = data
559
- end
560
-
561
550
# #------------------------------------------------------------------------------
562
551
# # Variable Metadata
563
552
# #------------------------------------------------------------------------------
@@ -682,49 +671,36 @@ end
682
671
$(SIGNATURES)
683
672
Get variable solverdata for a given solve key.
684
673
"""
685
- function getVariableState (
686
- dfg:: AbstractDFG ,
687
- variablekey:: Symbol ,
688
- solvekey:: Symbol = :default ,
689
- )
690
- v = getVariable (dfg, variablekey)
691
- ! haskey (v. solverDataDict, solvekey) && throw (LabelNotFoundError (" State" , solvekey))
692
- return v. solverDataDict[solvekey]
674
+ function getVariableState (dfg:: AbstractDFG , variableLabel:: Symbol , label:: Symbol )
675
+ v = getVariable (dfg, variableLabel)
676
+ ! haskey (v. solverDataDict, label) && throw (LabelNotFoundError (" State" , label))
677
+ return v. solverDataDict[label]
693
678
end
694
679
695
- function getVariableStates (dfg:: AbstractDFG , variablekey :: Symbol )
696
- v = getVariable (dfg, variablekey )
680
+ function getVariableStates (dfg:: AbstractDFG , variableLabel :: Symbol )
681
+ v = getVariable (dfg, variableLabel )
697
682
return collect (values (v. solverDataDict))
698
683
end
699
684
700
685
"""
701
686
$(SIGNATURES)
702
687
Add variable solver data, errors if it already exists.
703
688
"""
704
- function addVariableState! (dfg:: AbstractDFG , variablekey:: Symbol , vnd :: VariableState )
689
+ function addVariableState! (dfg:: AbstractDFG , variablekey:: Symbol , state :: VariableState )
705
690
var = getVariable (dfg, variablekey)
706
- if haskey (var. solverDataDict, vnd . solveKey)
707
- throw (LabelExistsError (" VariableState" , vnd . solveKey))
691
+ if haskey (var. solverDataDict, state . solveKey)
692
+ throw (LabelExistsError (" VariableState" , state . solveKey))
708
693
end
709
- var. solverDataDict[vnd . solveKey] = vnd
710
- return vnd
694
+ var. solverDataDict[state . solveKey] = state
695
+ return state
711
696
end
712
697
713
- """
714
- $(SIGNATURES)
715
- Add a new solver data entry from a deepcopy of the source variable solver data.
716
- NOTE: Copies the solver data.
717
- """
718
- function addVariableState! (
719
- dfg:: AbstractDFG ,
720
- sourceVariable:: VariableCompute ,
721
- solveKey:: Symbol = :default ,
722
- )
723
- return addVariableState! (
724
- dfg,
725
- sourceVariable. label,
726
- deepcopy (getVariableState (sourceVariable, solveKey)),
727
- )
698
+ function addVariableState! (v, state:: VariableState )
699
+ if haskey (v. solverDataDict, state. solveKey)
700
+ throw (LabelExistsError (" VariableState" , state. solveKey))
701
+ end
702
+ v. solverDataDict[state. solveKey] = state
703
+ return state
728
704
end
729
705
730
706
"""
@@ -747,6 +723,16 @@ function mergeVariableState!(dfg::AbstractDFG, variablekey::Symbol, vnd::Variabl
747
723
return 1
748
724
end
749
725
726
+ function mergeVariableState! (v:: VariableCompute , vnd:: VariableState )
727
+ if ! haskey (v. solverDataDict, vnd. solveKey)
728
+ addVariableState! (v, vnd)
729
+ else
730
+ v. solverDataDict[vnd. solveKey] = vnd
731
+ end
732
+
733
+ return 1
734
+ end
735
+
750
736
function copytoVariableState! (
751
737
dfg:: AbstractDFG ,
752
738
variableLabel:: Symbol ,
797
783
798
784
"""
799
785
$(SIGNATURES)
800
- Delete variable solver data, returns the deleted element .
786
+ Delete variable solver data, returns the number of deleted elements .
801
787
"""
802
- function deleteVariableState! (
803
- dfg:: AbstractDFG ,
804
- variablekey:: Symbol ,
805
- solveKey:: Symbol = :default ,
806
- )
788
+ function deleteVariableState! (dfg:: AbstractDFG , variablekey:: Symbol , solveKey:: Symbol )
807
789
var = getVariable (dfg, variablekey)
808
790
809
791
if ! haskey (var. solverDataDict, solveKey)
@@ -815,12 +797,12 @@ end
815
797
816
798
"""
817
799
$(SIGNATURES)
818
- Delete variable solver data, returns the deleted element .
800
+ Delete variable solver data, returns the number of deleted elements .
819
801
"""
820
802
function deleteVariableState! (
821
803
dfg:: AbstractDFG ,
822
804
sourceVariable:: VariableCompute ,
823
- solveKey:: Symbol = :default ,
805
+ solveKey:: Symbol ,
824
806
)
825
807
return deleteVariableState! (dfg, sourceVariable. label, solveKey)
826
808
end
@@ -838,28 +820,6 @@ function listVariableStates(dfg::AbstractDFG, variablekey::Symbol)
838
820
return collect (keys (v. solverDataDict))
839
821
end
840
822
841
- """
842
- $(SIGNATURES)
843
- Merges and updates solver and estimate data for a variable (variable can be from another graph).
844
- If the same key is present in another collection, the value for that key will be the value it has in the last collection listed (updated).
845
- Note: Makes a copy of the estimates and solver data so that there is no coupling between graphs.
846
- """
847
- function mergeVariableSolverData! (
848
- destVariable:: VariableCompute ,
849
- sourceVariable:: VariableCompute ,
850
- )
851
- # We don't know which graph this came from, must be copied!
852
- merge! (destVariable. solverDataDict, deepcopy (sourceVariable. solverDataDict))
853
- return destVariable
854
- end
855
-
856
- function mergeVariableSolverData! (dfg:: AbstractDFG , sourceVariable:: VariableCompute )
857
- return mergeVariableSolverData! (
858
- getVariable (dfg, getLabel (sourceVariable)),
859
- sourceVariable,
860
- )
861
- end
862
-
863
823
# #==============================================================================
864
824
# # Point Parametric Estimates
865
825
# #==============================================================================
0 commit comments