X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FdaComposant%2FdaAlgorithms%2FSamplingTest.py;h=f71d9f46b6890db28f09be7368fd1d15a67caad8;hb=59c9144c3b491494cb2beeb10093f232a5e13f2a;hp=41d0bfab0c91fc452bd1c8dce20e17dcd22f093a;hpb=e5d72c98fe0d01217729d498408c6f6b2180969b;p=modules%2Fadao.git diff --git a/src/daComposant/daAlgorithms/SamplingTest.py b/src/daComposant/daAlgorithms/SamplingTest.py index 41d0bfa..f71d9f4 100644 --- a/src/daComposant/daAlgorithms/SamplingTest.py +++ b/src/daComposant/daAlgorithms/SamplingTest.py @@ -1,24 +1,24 @@ -#-*-coding:iso-8859-1-*- +# -*- coding: utf-8 -*- # -# Copyright (C) 2008-2015 EDF R&D +# Copyright (C) 2008-2020 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 @@ -32,31 +32,31 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): name = "SampleAsnUplet", default = [], typecast = tuple, - message = "Points de calcul définis par une liste de n-uplet", + message = "Points de calcul définis par une liste de n-uplet", ) self.defineRequiredParameter( name = "SampleAsExplicitHyperCube", default = [], typecast = tuple, - message = "Points de calcul définis par un hyper-cube dont on donne la liste des échantillonages de chaque variable comme une liste", + message = "Points de calcul définis par un hyper-cube dont on donne la liste des échantillonages de chaque variable comme une liste", ) self.defineRequiredParameter( name = "SampleAsMinMaxStepHyperCube", default = [], typecast = tuple, - message = "Points de calcul définis par un hyper-cube dont on donne la liste des échantillonages de chaque variable par un triplet [min,max,step]", + message = "Points de calcul définis par un hyper-cube dont on donne la liste des échantillonages de chaque variable par un triplet [min,max,step]", ) self.defineRequiredParameter( name = "SampleAsIndependantRandomVariables", default = [], typecast = tuple, - message = "Points de calcul définis par un hyper-cube dont les points sur chaque axe proviennent de l'échantillonage indépendant de la variable selon la spécification ['distribution',[parametres],nombre]", + message = "Points de calcul définis par un hyper-cube dont les points sur chaque axe proviennent de l'échantillonage indépendant de la variable selon la spécification ['distribution',[parametres],nombre]", ) self.defineRequiredParameter( name = "QualityCriterion", default = "AugmentedWeightedLeastSquares", typecast = str, - message = "Critère de qualité utilisé", + message = "Critère de qualité utilisé", listval = ["AugmentedWeightedLeastSquares","AWLS","AugmentedPonderatedLeastSquares","APLS","DA", "WeightedLeastSquares","WLS","PonderatedLeastSquares","PLS", "LeastSquares","LS","L2", @@ -67,25 +67,36 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): name = "SetDebug", default = False, typecast = bool, - message = "Activation du mode debug lors de l'exécution", + message = "Activation du mode debug lors de l'exécution", ) self.defineRequiredParameter( name = "StoreSupplementaryCalculations", default = [], typecast = tuple, - message = "Liste de calculs supplémentaires à stocker et/ou effectuer", - listval = ["CostFunctionJ","CurrentState","Innovation","SimulatedObservationAtCurrentState"] + message = "Liste de calculs supplémentaires à stocker et/ou effectuer", + listval = [ + "CostFunctionJ", + "CostFunctionJb", + "CostFunctionJo", + "CurrentState", + "InnovationAtCurrentState", + "SimulatedObservationAtCurrentState", + ] ) self.defineRequiredParameter( name = "SetSeed", typecast = numpy.random.seed, - message = "Graine fixée pour le générateur aléatoire", + message = "Graine fixée pour le générateur aléatoire", ) + self.requireInputArguments( + mandatory= ("Xb", "HO"), + ) + self.setAttributes(tags=( + "Checking", + )) def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None): - self._pre_run() - # - self.setParameters(Parameters) + self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q) # Hm = HO["Direct"].appliedTo # @@ -105,7 +116,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 = [] @@ -153,11 +164,11 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): Jo = numpy.max( numpy.abs(Y - _HX) ) # J = float( Jb ) + float( Jo ) - if "CurrentState" in self._parameters["StoreSupplementaryCalculations"]: + if self._toStore("CurrentState"): self.StoredVariables["CurrentState"].store( _X ) - if "Innovation" in self._parameters["StoreSupplementaryCalculations"]: - self.StoredVariables["Innovation"].store( Y - _HX ) - if "SimulatedObservationAtCurrentState" in self._parameters["StoreSupplementaryCalculations"]: + if self._toStore("InnovationAtCurrentState"): + self.StoredVariables["InnovationAtCurrentState"].store( Y - _HX ) + if self._toStore("SimulatedObservationAtCurrentState"): self.StoredVariables["SimulatedObservationAtCurrentState"].store( _HX ) self.StoredVariables["CostFunctionJb"].store( Jb ) self.StoredVariables["CostFunctionJo"].store( Jo ) @@ -193,4 +204,4 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # ============================================================================== if __name__ == "__main__": - print '\n AUTODIAGNOSTIC \n' + print('\n AUTODIAGNOSTIC\n')