Salome HOME
Updating copyright date information
[modules/adao.git] / src / daComposant / daAlgorithms / SamplingTest.py
index 67cfa2dc3519c5d80ef922dc2993fbe8387cbdc6..32ebf3fba756ac296b4b46b8bfc04b6847702128 100644 (file)
@@ -1,24 +1,24 @@
 #-*-coding:iso-8859-1-*-
 #
-#  Copyright (C) 2008-2015 EDF R&D
+# Copyright (C) 2008-2016 EDF R&D
 #
-#  This library is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU Lesser General Public
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
 #
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
 #
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 #
-#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
-#  Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
+# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
 
 import logging
 from daCore import BasicObjects
@@ -74,7 +74,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             default  = [],
             typecast = tuple,
             message  = "Liste de calculs supplémentaires à stocker et/ou effectuer",
-            listval  = ["CostFunctionJ","CurrentState","Innovation","SimulatedObservationAtCurrentState"]
+            listval  = ["CostFunctionJ","CurrentState","InnovationAtCurrentState","SimulatedObservationAtCurrentState"]
             )
         self.defineRequiredParameter(
             name     = "SetSeed",
@@ -105,7 +105,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 if len(dim) != 3:
                     raise ValueError("For dimension %i, the variable definition \"%s\" is incorrect, it should be [min,max,step]."%(i,dim))
                 else:
-                    coordinatesList.append(numpy.linspace(dim[0],dim[1],1+int(float(dim[1])-float(dim[0])/float(dim[2]))))
+                    coordinatesList.append(numpy.linspace(dim[0],dim[1],1+int((float(dim[1])-float(dim[0]))/float(dim[2]))))
             sampleList = itertools.product(*coordinatesList)
         elif len(self._parameters["SampleAsIndependantRandomVariables"]) > 0:
             coordinatesList = []
@@ -124,7 +124,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         # ----------
         BI = B.getI()
         RI = R.getI()
-        def CostFunction(x,HmX, QualityMeasure="AugmentedWeightedLeastSquares"):
+        def CostFunction(x, HmX, QualityMeasure="AugmentedWeightedLeastSquares"):
             if numpy.any(numpy.isnan(HmX)):
                 _X  = numpy.nan
                 _HX = numpy.nan
@@ -155,8 +155,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 J   = float( Jb ) + float( Jo )
             if "CurrentState" in self._parameters["StoreSupplementaryCalculations"]:
                 self.StoredVariables["CurrentState"].store( _X )
-            if "Innovation" in self._parameters["StoreSupplementaryCalculations"]:
-                self.StoredVariables["Innovation"].store( Y - _HX )
+            if "InnovationAtCurrentState" in self._parameters["StoreSupplementaryCalculations"]:
+                self.StoredVariables["InnovationAtCurrentState"].store( Y - _HX )
             if "SimulatedObservationAtCurrentState" in self._parameters["StoreSupplementaryCalculations"]:
                 self.StoredVariables["SimulatedObservationAtCurrentState"].store( _HX )
             self.StoredVariables["CostFunctionJb"].store( Jb )