X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FdaComposant%2FdaAlgorithms%2FQuantileRegression.py;h=4b0dd223528f1ad1c12dab21206bc9de2e779e0c;hb=67a9e7898a4e0455f469b63898f42e965da0b33e;hp=0d0cf2ae1f9e98afc0342e9e644423951058a4f1;hpb=4790fb60acb36159350ee1cda40107e6833ead3f;p=modules%2Fadao.git diff --git a/src/daComposant/daAlgorithms/QuantileRegression.py b/src/daComposant/daAlgorithms/QuantileRegression.py index 0d0cf2a..4b0dd22 100644 --- a/src/daComposant/daAlgorithms/QuantileRegression.py +++ b/src/daComposant/daAlgorithms/QuantileRegression.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2008-2017 EDF R&D +# Copyright (C) 2008-2019 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 @@ -21,7 +21,7 @@ # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D import logging -from daCore import BasicObjects +from daCore import BasicObjects, NumericObjects import numpy # ============================================================================== @@ -67,7 +67,20 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): default = [], typecast = tuple, message = "Liste de calculs supplémentaires à stocker et/ou effectuer", - listval = ["BMA", "OMA", "OMB", "CurrentState", "CostFunctionJ", "CostFunctionJb", "CostFunctionJo", "Innovation", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum"] + listval = [ + "Analysis", + "BMA", + "CostFunctionJ", + "CostFunctionJb", + "CostFunctionJo", + "CurrentState", + "Innovation", + "OMA", + "OMB", + "SimulatedObservationAtBackground", + "SimulatedObservationAtCurrentState", + "SimulatedObservationAtOptimum", + ] ) self.defineRequiredParameter( # Pas de type name = "Bounds", @@ -78,7 +91,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): ) 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(Parameters, R, B, Q) + self._pre_run(Parameters, Xb, Y, R, B, Q) # Hm = HO["Direct"].appliedTo # @@ -102,11 +115,11 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # ------------------------------ def CostFunction(x): _X = numpy.asmatrix(numpy.ravel( x )).T - if self._parameters["StoreInternalVariables"] or "CurrentState" in self._parameters["StoreSupplementaryCalculations"]: + if self._parameters["StoreInternalVariables"] or self._toStore("CurrentState"): self.StoredVariables["CurrentState"].store( _X ) _HX = Hm( _X ) _HX = numpy.asmatrix(numpy.ravel( _HX )).T - if "SimulatedObservationAtCurrentState" in self._parameters["StoreSupplementaryCalculations"]: + if self._toStore("SimulatedObservationAtCurrentState"): self.StoredVariables["SimulatedObservationAtCurrentState"].store( _HX ) Jb = 0. Jo = 0. @@ -131,8 +144,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # Minimisation de la fonctionnelle # -------------------------------- if self._parameters["Minimizer"] == "MMQR": - import mmqr - Minimum, J_optimal, Informations = mmqr.mmqr( + Minimum, J_optimal, Informations = NumericObjects.mmqr( func = CostFunction, x0 = Xini, fprime = GradientOfCostFunction, @@ -153,23 +165,23 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # self.StoredVariables["Analysis"].store( Xa.A1 ) # - if "OMA" in self._parameters["StoreSupplementaryCalculations"] or \ - "SimulatedObservationAtOptimum" in self._parameters["StoreSupplementaryCalculations"]: + if self._toStore("OMA") or \ + self._toStore("SimulatedObservationAtOptimum"): HXa = Hm(Xa) # # Calculs et/ou stockages supplémentaires # --------------------------------------- - if "Innovation" in self._parameters["StoreSupplementaryCalculations"]: + if self._toStore("Innovation"): self.StoredVariables["Innovation"].store( numpy.ravel(d) ) - if "BMA" in self._parameters["StoreSupplementaryCalculations"]: + if self._toStore("BMA"): self.StoredVariables["BMA"].store( numpy.ravel(Xb - Xa) ) - if "OMA" in self._parameters["StoreSupplementaryCalculations"]: + if self._toStore("OMA"): self.StoredVariables["OMA"].store( numpy.ravel(Y - HXa) ) - if "OMB" in self._parameters["StoreSupplementaryCalculations"]: + if self._toStore("OMB"): self.StoredVariables["OMB"].store( numpy.ravel(d) ) - if "SimulatedObservationAtBackground" in self._parameters["StoreSupplementaryCalculations"]: + if self._toStore("SimulatedObservationAtBackground"): self.StoredVariables["SimulatedObservationAtBackground"].store( numpy.ravel(HXb) ) - if "SimulatedObservationAtOptimum" in self._parameters["StoreSupplementaryCalculations"]: + if self._toStore("SimulatedObservationAtOptimum"): self.StoredVariables["SimulatedObservationAtOptimum"].store( numpy.ravel(HXa) ) # self._post_run(HO) @@ -177,4 +189,4 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # ============================================================================== if __name__ == "__main__": - print('\n AUTODIAGNOSTIC \n') + print('\n AUTODIAGNOSTIC\n')