]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Minor internal clarification and performance improvements
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Wed, 29 Sep 2021 19:13:29 +0000 (21:13 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Wed, 29 Sep 2021 20:22:49 +0000 (22:22 +0200)
bin/AdaoCatalogGenerator.py
src/daComposant/daAlgorithms/LinearLeastSquares.py
src/daComposant/daAlgorithms/NonLinearLeastSquares.py
src/daComposant/daCore/Interfaces.py
src/daSalome/daGUI/daGuiImpl/adaoGuiManager.py

index 9b1037dc1d194454ede616700437b327a8aca414..5a183d47bb91c3d23a61a2dfe9a48236d811b477 100644 (file)
@@ -546,7 +546,7 @@ for algo in all_names:
         elif pt is float:
             algo_parameters += """        %s = SIMP(statut="f", typ="R"%s%s, min=1, max=1, defaut=%s, fr="%s"),\n"""%(pn,vi,vs,float(pd),pm)
         elif pt is bool:
-            algo_parameters += """        %s = SIMP(statut="f", typ="I", min=1, max=1, defaut=%s, fr="%s"),\n"""%(pn,int(pd),pm)
+            algo_parameters += """        %s = SIMP(statut="f", typ="I", into=(0, 1), min=1, max=1, defaut=%s, fr="%s"),\n"""%(pn,int(pd),pm)
         elif pt is str and "listval" in par_dict[pn]:
             algo_parameters += """        %s = SIMP(statut="f", typ="TXM", min=1, max=1, defaut="%s", into=%s, fr="%s"),\n"""%(pn,pd,par_dict[pn]["listval"],pm)
         elif pt is tuple and "listval" in par_dict[pn]:
index 8e34142b693c30d5b1938b2d10515ca10235e33e..2da26a48547626736318d05616fcaa29ed8686a0 100644 (file)
@@ -56,7 +56,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 ]
             )
         self.requireInputArguments(
-            mandatory= ("Y", "HO", "R"),
+            mandatory= ("Y", "HO"),
+            optional = ("R"),
             )
         self.setAttributes(tags=(
             "Optimization",
@@ -72,13 +73,16 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         Ha = HO["Adjoint"].asMatrix(Xb)
         Ha = Ha.reshape(-1,Y.size) # ADAO & check shape
         #
-        RI = R.getI()
+        if R is None:
+            RI = 1.
+        else:
+            RI = R.getI()
         #
         # Calcul de la matrice de gain et de l'analyse
         # --------------------------------------------
         K = (Ha * RI * Hm).I * Ha * RI
         Xa =  K * Y
-        self.StoredVariables["Analysis"].store( Xa.A1 )
+        self.StoredVariables["Analysis"].store( Xa )
         #
         # Calcul de la fonction coût
         # --------------------------
@@ -109,19 +113,19 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         # Calculs et/ou stockages supplémentaires
         # ---------------------------------------
         if self._parameters["StoreInternalVariables"] or self._toStore("CurrentState"):
-            self.StoredVariables["CurrentState"].store( numpy.ravel(Xa) )
+            self.StoredVariables["CurrentState"].store( Xa )
         if self._toStore("CurrentOptimum"):
-            self.StoredVariables["CurrentOptimum"].store( numpy.ravel(Xa) )
+            self.StoredVariables["CurrentOptimum"].store( Xa )
         if self._toStore("OMA"):
-            self.StoredVariables["OMA"].store( numpy.ravel(oma) )
+            self.StoredVariables["OMA"].store( oma )
         if self._toStore("SimulatedObservationAtBackground"):
-            self.StoredVariables["SimulatedObservationAtBackground"].store( numpy.ravel(HXb) )
+            self.StoredVariables["SimulatedObservationAtBackground"].store( HXb )
         if self._toStore("SimulatedObservationAtCurrentState"):
-            self.StoredVariables["SimulatedObservationAtCurrentState"].store( numpy.ravel(HXa) )
+            self.StoredVariables["SimulatedObservationAtCurrentState"].store( HXa )
         if self._toStore("SimulatedObservationAtCurrentOptimum"):
-            self.StoredVariables["SimulatedObservationAtCurrentOptimum"].store( numpy.ravel(HXa) )
+            self.StoredVariables["SimulatedObservationAtCurrentOptimum"].store( HXa )
         if self._toStore("SimulatedObservationAtOptimum"):
-            self.StoredVariables["SimulatedObservationAtOptimum"].store( numpy.ravel(HXa) )
+            self.StoredVariables["SimulatedObservationAtOptimum"].store( HXa )
         #
         self._post_run(HO)
         return 0
index aad66fc737b92a4dac264863d8522024f8a2e278..d0afe68cb1debd0e80fcefe08cb09e84c1ca255e 100644 (file)
@@ -107,7 +107,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             message  = "État initial imposé (par défaut, c'est l'ébauche si None)",
             )
         self.requireInputArguments(
-            mandatory= ("Xb", "Y", "HO", "R"),
+            mandatory= ("Xb", "Y", "HO"),
+            optional = ("R"),
             )
         self.setAttributes(tags=(
             "Optimization",
@@ -135,11 +136,13 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         if max(Y.shape) != max(HXb.shape):
             raise ValueError("The shapes %s of observations Y and %s of observed calculation H(X) are different, they have to be identical."%(Y.shape,HXb.shape))
         #
-        # Précalcul des inversions de B et R
-        # ----------------------------------
-        RI = R.getI()
-        if self._parameters["Minimizer"] == "LM":
-            RdemiI = R.choleskyI()
+        if R is None:
+            RI = 1.
+            RdemiI = 1.
+        else:
+            RI = R.getI()
+            if self._parameters["Minimizer"] == "LM":
+                RdemiI = R.choleskyI()
         #
         # Définition de la fonction-coût
         # ------------------------------
@@ -321,7 +324,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         # ----------------------
         Xa = numpy.asmatrix(numpy.ravel( Minimum )).T
         #
-        self.StoredVariables["Analysis"].store( Xa.A1 )
+        self.StoredVariables["Analysis"].store( Xa )
         #
         if self._toStore("OMA") or \
             self._toStore("SimulatedObservationAtOptimum"):
@@ -339,17 +342,17 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             self._toStore("OMB"):
             d  = Y - HXb
         if self._toStore("Innovation"):
-            self.StoredVariables["Innovation"].store( numpy.ravel(d) )
+            self.StoredVariables["Innovation"].store( d )
         if self._toStore("BMA"):
             self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
         if self._toStore("OMA"):
             self.StoredVariables["OMA"].store( numpy.ravel(Y) - numpy.ravel(HXa) )
         if self._toStore("OMB"):
-            self.StoredVariables["OMB"].store( numpy.ravel(d) )
+            self.StoredVariables["OMB"].store( d )
         if self._toStore("SimulatedObservationAtBackground"):
-            self.StoredVariables["SimulatedObservationAtBackground"].store( numpy.ravel(HXb) )
+            self.StoredVariables["SimulatedObservationAtBackground"].store( HXb )
         if self._toStore("SimulatedObservationAtOptimum"):
-            self.StoredVariables["SimulatedObservationAtOptimum"].store( numpy.ravel(HXa) )
+            self.StoredVariables["SimulatedObservationAtOptimum"].store( HXa )
         #
         self._post_run(HO)
         return 0
index 725a9c0cd43b4546d1af636193534e3d4a39b2f4..f567763bda1a880e15f560b81e5f4ba3026579ab 100644 (file)
@@ -183,6 +183,8 @@ class _COMViewer(GenericCaseViewer):
         "Transformation d'enregistrement(s) en commande(s) individuelle(s)"
         __suppparameters = {}
         if __multilines is not None:
+            if 'adaoBuilder' in __multilines:
+                raise ValueError("Impossible to load given content as an ADAO COMM one (Hint: it's perhaps not a COMM input, but a TUI one).")
             if "ASSIMILATION_STUDY" in __multilines:
                 __suppparameters.update({'StudyType':"ASSIMILATION_STUDY"})
                 __multilines = __multilines.replace("ASSIMILATION_STUDY","dict")
index a7aeb4512f6f63f68ca67121fa9109ac5e55d20b..8a9e05b31d0296622e969ce5eabec3387992c673 100644 (file)
@@ -449,34 +449,34 @@ class AdaoGuiUiComponentBuilder:
         a = sgPyQt.createAction( UI_ELT_IDS.NEW_ADAOCASE_ID, "New case", "New case", "Create a new ADAO case", "eficas_new.png" )
         sgPyQt.createMenu(a, mid)
         sgPyQt.createTool(a, tid)
-        a = sgPyQt.createAction( UI_ELT_IDS.OPEN_ADAOCASE_ID, "Open case", "Open case", "Open an ADAO case", "eficas_open.png" )
+        a = sgPyQt.createAction( UI_ELT_IDS.OPEN_ADAOCASE_ID, "Open a case", "Open a case", "Open an ADAO case", "eficas_open.png" )
         sgPyQt.createMenu(a, mid)
         sgPyQt.createTool(a, tid)
-        a = sgPyQt.createAction( UI_ELT_IDS.SAVE_ADAOCASE_ID, "Save case", "Save case", "Save an ADAO case", "eficas_save.png" )
+        a = sgPyQt.createAction( UI_ELT_IDS.SAVE_ADAOCASE_ID, "Save the case", "Save the case", "Save the ADAO case", "eficas_save.png" )
         sgPyQt.createMenu(a, mid)
         sgPyQt.createTool(a, tid)
-        a = sgPyQt.createAction( UI_ELT_IDS.SAVE_AS_ADAOCASE_ID, "Save as case", "Save as case", "Save an ADAO case as", "eficas_saveas.png" )
+        a = sgPyQt.createAction( UI_ELT_IDS.SAVE_AS_ADAOCASE_ID, "Save the case as", "Save the case as", "Save the ADAO case as", "eficas_saveas.png" )
         sgPyQt.createMenu(a, mid)
         sgPyQt.createTool(a, tid)
-        a = sgPyQt.createAction( UI_ELT_IDS.VALIDATE_ADAOCASE_ID, "Validate case", "Validate case", "Validate an ADAO case", "eficas_valid.png" )
+        a = sgPyQt.createAction( UI_ELT_IDS.VALIDATE_ADAOCASE_ID, "Validate the case", "Validate the case", "Validate the ADAO case", "eficas_valid.png" )
         sgPyQt.createMenu(a, mid)
         sgPyQt.createTool(a, tid)
         a = sgPyQt.createAction( UI_ELT_IDS.SHOWTREE_ADAOCASE_ID, "Show tree", "Show tree", "Show the commands tree", "eficas_tree.png" )
         sgPyQt.createMenu(a, mid)
         sgPyQt.createTool(a, tid)
-        a = sgPyQt.createAction( UI_ELT_IDS.TUI_EXPORT_ID, "Export to TUI", "Export to TUI", "Generate an ADAO TUI version of this case", "eficas_totui.png" )
+        a = sgPyQt.createAction( UI_ELT_IDS.TUI_EXPORT_ID, "Export the case to TUI", "Export the case to TUI", "Generate the ADAO TUI version of this case", "eficas_totui.png" )
         sgPyQt.createMenu(a, mid)
         sgPyQt.createTool(a, tid)
-        a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close an ADAO case", "eficas_close.png" )
+        a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close the case", "Close the case", "Close the ADAO case", "eficas_close.png" )
         sgPyQt.createMenu(a, mid)
         sgPyQt.createTool(a, tid)
-        a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_ID, "Export to YACS", "Export to YACS", "Generate a YACS graph executing this case", "eficas_yacs.png" )
+        a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_ID, "Export the case to YACS", "Export the case to YACS", "Generate the YACS graph to execute this case", "eficas_yacs.png" )
         sgPyQt.createMenu(a, mid)
         sgPyQt.createTool(a, tid)
 
         # the following action are used in context popup
-        a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close case", "Close case", "Close the selected case", "" )
-        a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_ID, "Export to YACS", "Export to YACS", "Generate a YACS graph executing this case", "" )
+        a = sgPyQt.createAction( UI_ELT_IDS.CLOSE_ADAOCASE_ID, "Close the case", "Close the case", "Close the ADAO case", "" )
+        a = sgPyQt.createAction( UI_ELT_IDS.YACS_EXPORT_ID, "Export the case to YACS", "Export the case to YACS", "Generate the YACS graph to execute this case", "" )
 
     def createPopupMenuOnItem(self,popup,item): # salomeSudyId, item):
         if adaoStudyEditor.isValidAdaoCaseItem(item): # Attention : appel ancien avec un coquille (StudyId) : (salomeSudyId, item):