@@ -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
# #------------------------------------------------------------------------------
@@ -684,47 +673,38 @@ Get variable solverdata for a given solve key.
684
673
"""
685
674
function getVariableState (
686
675
dfg:: AbstractDFG ,
687
- variablekey :: Symbol ,
688
- solvekey :: Symbol = :default ,
676
+ variableLabel :: Symbol ,
677
+ label :: Symbol ,
689
678
)
690
- v = getVariable (dfg, variablekey )
691
- ! haskey (v. solverDataDict, solvekey ) && throw (LabelNotFoundError (" State" , solvekey ))
692
- return v. solverDataDict[solvekey ]
679
+ v = getVariable (dfg, variableLabel )
680
+ ! haskey (v. solverDataDict, label ) && throw (LabelNotFoundError (" State" , label ))
681
+ return v. solverDataDict[label ]
693
682
end
694
683
695
- function getVariableStates (dfg:: AbstractDFG , variablekey :: Symbol )
696
- v = getVariable (dfg, variablekey )
684
+ function getVariableStates (dfg:: AbstractDFG , variableLabel :: Symbol )
685
+ v = getVariable (dfg, variableLabel )
697
686
return collect (values (v. solverDataDict))
698
687
end
699
688
700
689
"""
701
690
$(SIGNATURES)
702
691
Add variable solver data, errors if it already exists.
703
692
"""
704
- function addVariableState! (dfg:: AbstractDFG , variablekey:: Symbol , vnd :: VariableState )
693
+ function addVariableState! (dfg:: AbstractDFG , variablekey:: Symbol , state :: VariableState )
705
694
var = getVariable (dfg, variablekey)
706
- if haskey (var. solverDataDict, vnd . solveKey)
707
- throw (LabelExistsError (" VariableState" , vnd . solveKey))
695
+ if haskey (var. solverDataDict, state . solveKey)
696
+ throw (LabelExistsError (" VariableState" , state . solveKey))
708
697
end
709
- var. solverDataDict[vnd . solveKey] = vnd
710
- return vnd
698
+ var. solverDataDict[state . solveKey] = state
699
+ return state
711
700
end
712
701
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
- )
702
+ function addVariableState! (v, state:: VariableState )
703
+ if haskey (v. solverDataDict, state. solveKey)
704
+ throw (LabelExistsError (" VariableState" , state. solveKey))
705
+ end
706
+ v. solverDataDict[state. solveKey] = state
707
+ return state
728
708
end
729
709
730
710
"""
@@ -747,6 +727,17 @@ function mergeVariableState!(dfg::AbstractDFG, variablekey::Symbol, vnd::Variabl
747
727
return 1
748
728
end
749
729
730
+ function mergeVariableState! (v:: VariableCompute , vnd:: VariableState )
731
+
732
+ if ! haskey (v. solverDataDict, vnd. solveKey)
733
+ addVariableState! (v, vnd)
734
+ else
735
+ v. solverDataDict[vnd. solveKey] = vnd
736
+ end
737
+
738
+ return 1
739
+ end
740
+
750
741
function copytoVariableState! (
751
742
dfg:: AbstractDFG ,
752
743
variableLabel:: Symbol ,
@@ -797,12 +788,12 @@ end
797
788
798
789
"""
799
790
$(SIGNATURES)
800
- Delete variable solver data, returns the deleted element .
791
+ Delete variable solver data, returns the number of deleted elements .
801
792
"""
802
793
function deleteVariableState! (
803
794
dfg:: AbstractDFG ,
804
795
variablekey:: Symbol ,
805
- solveKey:: Symbol = :default ,
796
+ solveKey:: Symbol ,
806
797
)
807
798
var = getVariable (dfg, variablekey)
808
799
@@ -815,12 +806,12 @@ end
815
806
816
807
"""
817
808
$(SIGNATURES)
818
- Delete variable solver data, returns the deleted element .
809
+ Delete variable solver data, returns the number of deleted elements .
819
810
"""
820
811
function deleteVariableState! (
821
812
dfg:: AbstractDFG ,
822
813
sourceVariable:: VariableCompute ,
823
- solveKey:: Symbol = :default ,
814
+ solveKey:: Symbol ,
824
815
)
825
816
return deleteVariableState! (dfg, sourceVariable. label, solveKey)
826
817
end
@@ -838,28 +829,6 @@ function listVariableStates(dfg::AbstractDFG, variablekey::Symbol)
838
829
return collect (keys (v. solverDataDict))
839
830
end
840
831
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
832
# #==============================================================================
864
833
# # Point Parametric Estimates
865
834
# #==============================================================================
0 commit comments