From: Jean-Philippe ARGAUD Date: Wed, 7 Oct 2015 14:10:25 +0000 (+0200) Subject: Documentation and source correction and improvements X-Git-Tag: V7_7_0rc1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=22b0bf431af5bef677f824768583a4e416fa62cb;p=modules%2Fadao.git Documentation and source correction and improvements --- diff --git a/doc/en/ref_algorithm_3DVAR.rst b/doc/en/ref_algorithm_3DVAR.rst index 3cce818..430b0f4 100644 --- a/doc/en/ref_algorithm_3DVAR.rst +++ b/doc/en/ref_algorithm_3DVAR.rst @@ -165,8 +165,9 @@ The options of the algorithm are the following: these variables being calculated and stored by default. The possible names are in the following list: ["APosterioriCorrelations", "APosterioriCovariance", "APosterioriStandardDeviations", - "APosterioriVariances", "BMA", "CostFunctionJ", "CurrentOptimum", - "CurrentState", "IndexOfOptimum", "Innovation", "InnovationAtCurrentState", + "APosterioriVariances", "BMA", "CostFunctionJ", + "CostFunctionJAtCurrentOptimum", "CurrentOptimum", "CurrentState", + "IndexOfOptimum", "Innovation", "InnovationAtCurrentState", "MahalanobisConsistency", "OMA", "OMB", "SigmaObs2", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentOptimum", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum", @@ -283,6 +284,27 @@ The conditional outputs of the algorithm are the following: Example : ``bma = ADD.get("BMA")[-1]`` + CostFunctionJAtCurrentOptimum + *List of values*. Each element is a value of the error function :math:`J`. + At each step, the value corresponds to the optimal state found from the + beginning. + + Example : ``JACO = ADD.get("CostFunctionJAtCurrentOptimum")[:]`` + + CostFunctionJbAtCurrentOptimum + *List of values*. Each element is a value of the error function :math:`J^b`, + that is of the background difference part. At each step, the value + corresponds to the optimal state found from the beginning. + + Example : ``JbACO = ADD.get("CostFunctionJbAtCurrentOptimum")[:]`` + + CostFunctionJoAtCurrentOptimum + *List of values*. Each element is a value of the error function :math:`J^o`, + that is of the observation difference part. At each step, the value + corresponds to the optimal state found from the beginning. + + Example : ``JoACO = ADD.get("CostFunctionJoAtCurrentOptimum")[:]`` + CurrentOptimum *List of vectors*. Each element is the optimal state obtained at the current step of the optimization algorithm. It is not necessarely the last state. diff --git a/doc/en/ref_algorithm_4DVAR.rst b/doc/en/ref_algorithm_4DVAR.rst index 243e617..34eeabb 100644 --- a/doc/en/ref_algorithm_4DVAR.rst +++ b/doc/en/ref_algorithm_4DVAR.rst @@ -183,8 +183,9 @@ The options of the algorithm are the following: available at the end of the algorithm. It involves potentially costly calculations or memory consumptions. The default is a void list, none of these variables being calculated and stored by default. The possible names - are in the following list: ["BMA", "CostFunctionJ", "CurrentOptimum", - "CurrentState", "IndexOfOptimum"]. + are in the following list: ["BMA", "CostFunctionJ", + "CostFunctionJAtCurrentOptimum", "CurrentOptimum", "CurrentState", + "IndexOfOptimum"]. Example : ``{"StoreSupplementaryCalculations":["BMA", "CurrentState"]}`` @@ -232,6 +233,27 @@ The conditional outputs of the algorithm are the following: Example : ``bma = ADD.get("BMA")[-1]`` + CostFunctionJAtCurrentOptimum + *List of values*. Each element is a value of the error function :math:`J`. + At each step, the value corresponds to the optimal state found from the + beginning. + + Example : ``JACO = ADD.get("CostFunctionJAtCurrentOptimum")[:]`` + + CostFunctionJbAtCurrentOptimum + *List of values*. Each element is a value of the error function :math:`J^b`, + that is of the background difference part. At each step, the value + corresponds to the optimal state found from the beginning. + + Example : ``JbACO = ADD.get("CostFunctionJbAtCurrentOptimum")[:]`` + + CostFunctionJoAtCurrentOptimum + *List of values*. Each element is a value of the error function :math:`J^o`, + that is of the observation difference part. At each step, the value + corresponds to the optimal state found from the beginning. + + Example : ``JoACO = ADD.get("CostFunctionJoAtCurrentOptimum")[:]`` + CurrentOptimum *List of vectors*. Each element is the optimal state obtained at the current step of the optimization algorithm. It is not necessarely the last state. diff --git a/doc/en/ref_observers_requirements.rst b/doc/en/ref_observers_requirements.rst index bd4b223..f0edbd2 100644 --- a/doc/en/ref_observers_requirements.rst +++ b/doc/en/ref_observers_requirements.rst @@ -203,11 +203,11 @@ Graphically plot with Gnuplot the current value of the variable. global ifig, gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) @@ -225,11 +225,11 @@ Graphically plot with Gnuplot the value serie of the variable. global ifig, gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) @@ -248,11 +248,11 @@ Print on standard output and, in the same time, graphically plot with Gnuplot th global ifig,gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) @@ -271,11 +271,11 @@ Print on standard output and, in the same time, graphically plot with Gnuplot th global ifig,gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) @@ -304,11 +304,11 @@ Print on standard output and, in the same, time save in a file and graphically p global ifig,gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) @@ -337,11 +337,11 @@ Print on standard output and, in the same, time save in a file and graphically p global ifig,gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) diff --git a/doc/en/ref_output_variables.rst b/doc/en/ref_output_variables.rst index d8713c5..a5e35f5 100644 --- a/doc/en/ref_output_variables.rst +++ b/doc/en/ref_output_variables.rst @@ -264,6 +264,27 @@ of availability. They are the following, in alphabetical order: Example : ``Jo = ADD.get("CostFunctionJo")[:]`` + CostFunctionJAtCurrentOptimum + *List of values*. Each element is a value of the error function :math:`J`. + At each step, the value corresponds to the optimal state found from the + beginning. + + Example : ``JACO = ADD.get("CostFunctionJAtCurrentOptimum")[:]`` + + CostFunctionJbAtCurrentOptimum + *List of values*. Each element is a value of the error function :math:`J^b`, + that is of the background difference part. At each step, the value + corresponds to the optimal state found from the beginning. + + Example : ``JbACO = ADD.get("CostFunctionJbAtCurrentOptimum")[:]`` + + CostFunctionJoAtCurrentOptimum + *List of values*. Each element is a value of the error function :math:`J^o`, + that is of the observation difference part. At each step, the value + corresponds to the optimal state found from the beginning. + + Example : ``JoACO = ADD.get("CostFunctionJoAtCurrentOptimum")[:]`` + CurrentOptimum *List of vectors*. Each element is the optimal state obtained at the current step of the optimization algorithm. It is not necessarely the last state. diff --git a/doc/fr/ref_algorithm_3DVAR.rst b/doc/fr/ref_algorithm_3DVAR.rst index aad3412..2eace82 100644 --- a/doc/fr/ref_algorithm_3DVAR.rst +++ b/doc/fr/ref_algorithm_3DVAR.rst @@ -170,8 +170,9 @@ Les options de l'algorithme sont les suivantes: aucune de ces variables n'étant calculée et stockée par défaut. Les noms possibles sont dans la liste suivante : ["APosterioriCorrelations", "APosterioriCovariance", "APosterioriStandardDeviations", - "APosterioriVariances", "BMA", "CostFunctionJ", "CurrentOptimum", - "CurrentState", "IndexOfOptimum", "Innovation", "InnovationAtCurrentState", + "APosterioriVariances", "BMA", "CostFunctionJ", + "CostFunctionJAtCurrentOptimum", "CurrentOptimum", "CurrentState", + "IndexOfOptimum", "Innovation", "InnovationAtCurrentState", "MahalanobisConsistency", "OMA", "OMB", "SigmaObs2", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentOptimum", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum", @@ -290,6 +291,27 @@ Les sorties conditionnelles de l'algorithme sont les suivantes: Exemple : ``bma = ADD.get("BMA")[-1]`` + CostFunctionJAtCurrentOptimum + *Liste de valeurs*. Chaque élément est une valeur de fonctionnelle d'écart + :math:`J`. A chaque pas, la valeur correspond à l'état optimal trouvé depuis + le début. + + Exemple : ``JACO = ADD.get("CostFunctionJAtCurrentOptimum")[:]`` + + CostFunctionJbAtCurrentOptimum + *Liste de valeurs*. Chaque élément est une valeur de fonctionnelle d'écart + :math:`J^b`, c'est-à-dire de la partie écart à l'ébauche. A chaque pas, la + valeur correspond à l'état optimal trouvé depuis le début. + + Exemple : ``JbACO = ADD.get("CostFunctionJbAtCurrentOptimum")[:]`` + + CostFunctionJoAtCurrentOptimum + *Liste de valeurs*. Chaque élément est une valeur de fonctionnelle d'écart + :math:`J^o`, c'est-à-dire de la partie écart à l'observation. A chaque pas, + la valeur correspond à l'état optimal trouvé depuis le début. + + Exemple : ``JoACO = ADD.get("CostFunctionJoAtCurrentOptimum")[:]`` + CurrentOptimum *Liste de vecteurs*. Chaque élément est le vecteur d'état optimal au pas de temps courant au cours du déroulement de l'algorithme d'optimisation. Ce diff --git a/doc/fr/ref_algorithm_4DVAR.rst b/doc/fr/ref_algorithm_4DVAR.rst index 6bc6f9d..6d907b5 100644 --- a/doc/fr/ref_algorithm_4DVAR.rst +++ b/doc/fr/ref_algorithm_4DVAR.rst @@ -189,7 +189,8 @@ Les options de l'algorithme sont les suivantes: calculs ou du stockage coûteux. La valeur par défaut est une liste vide, aucune de ces variables n'étant calculée et stockée par défaut. Les noms possibles sont dans la liste suivante : ["BMA", "CostFunctionJ", - "CurrentOptimum", "CurrentState", "IndexOfOptimum"]. + "CostFunctionJAtCurrentOptimum", "CurrentOptimum", "CurrentState", + "IndexOfOptimum"]. Exemple : ``{"StoreSupplementaryCalculations":["BMA", "CurrentState"]}`` @@ -239,6 +240,27 @@ Les sorties conditionnelles de l'algorithme sont les suivantes: Exemple : ``bma = ADD.get("BMA")[-1]`` + CostFunctionJAtCurrentOptimum + *Liste de valeurs*. Chaque élément est une valeur de fonctionnelle d'écart + :math:`J`. A chaque pas, la valeur correspond à l'état optimal trouvé depuis + le début. + + Exemple : ``JACO = ADD.get("CostFunctionJAtCurrentOptimum")[:]`` + + CostFunctionJbAtCurrentOptimum + *Liste de valeurs*. Chaque élément est une valeur de fonctionnelle d'écart + :math:`J^b`, c'est-à-dire de la partie écart à l'ébauche. A chaque pas, la + valeur correspond à l'état optimal trouvé depuis le début. + + Exemple : ``JbACO = ADD.get("CostFunctionJbAtCurrentOptimum")[:]`` + + CostFunctionJoAtCurrentOptimum + *Liste de valeurs*. Chaque élément est une valeur de fonctionnelle d'écart + :math:`J^o`, c'est-à-dire de la partie écart à l'observation. A chaque pas, + la valeur correspond à l'état optimal trouvé depuis le début. + + Exemple : ``JoACO = ADD.get("CostFunctionJoAtCurrentOptimum")[:]`` + CurrentOptimum *Liste de vecteurs*. Chaque élément est le vecteur d'état optimal au pas de temps courant au cours du déroulement de l'algorithme d'optimisation. Ce diff --git a/doc/fr/ref_observers_requirements.rst b/doc/fr/ref_observers_requirements.rst index adfc3be..42b6a24 100644 --- a/doc/fr/ref_observers_requirements.rst +++ b/doc/fr/ref_observers_requirements.rst @@ -206,11 +206,11 @@ Affiche graphiquement avec Gnuplot la valeur courante de la variable. global ifig, gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) @@ -228,11 +228,11 @@ Affiche graphiquement avec Gnuplot la s global ifig, gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) @@ -251,11 +251,11 @@ Imprime sur la sortie standard et, en m global ifig,gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) @@ -274,11 +274,11 @@ Imprime sur la sortie standard et, en m global ifig,gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) @@ -307,11 +307,11 @@ Imprime sur la sortie standard et, en m global ifig,gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) @@ -340,11 +340,11 @@ Imprime sur la sortie standard et, en m global ifig,gp try: ifig += 1 - gp('set style data lines') + gp(' set style data lines') except: ifig = 0 gp = Gnuplot.Gnuplot(persist=1) - gp('set style data lines') + gp(' set style data lines') gp('set title "%s (Figure %i)"'%(info,ifig)) gp.plot( Gnuplot.Data( v, with_='lines lw 2' ) ) diff --git a/doc/fr/ref_output_variables.rst b/doc/fr/ref_output_variables.rst index 16576e3..9031463 100644 --- a/doc/fr/ref_output_variables.rst +++ b/doc/fr/ref_output_variables.rst @@ -274,6 +274,27 @@ alphab Exemple : ``Jo = ADD.get("CostFunctionJo")[:]`` + CostFunctionJAtCurrentOptimum + *Liste de valeurs*. Chaque élément est une valeur de fonctionnelle d'écart + :math:`J`. A chaque pas, la valeur correspond à l'état optimal trouvé depuis + le début. + + Exemple : ``JACO = ADD.get("CostFunctionJAtCurrentOptimum")[:]`` + + CostFunctionJbAtCurrentOptimum + *Liste de valeurs*. Chaque élément est une valeur de fonctionnelle d'écart + :math:`J^b`, c'est-à-dire de la partie écart à l'ébauche. A chaque pas, la + valeur correspond à l'état optimal trouvé depuis le début. + + Exemple : ``JbACO = ADD.get("CostFunctionJbAtCurrentOptimum")[:]`` + + CostFunctionJoAtCurrentOptimum + *Liste de valeurs*. Chaque élément est une valeur de fonctionnelle d'écart + :math:`J^o`, c'est-à-dire de la partie écart à l'observation. A chaque pas, + la valeur correspond à l'état optimal trouvé depuis le début. + + Exemple : ``JoACO = ADD.get("CostFunctionJoAtCurrentOptimum")[:]`` + CurrentOptimum *Liste de vecteurs*. Chaque élément est le vecteur d'état optimal au pas de temps courant au cours du déroulement de l'algorithme d'optimisation. Ce diff --git a/src/daComposant/daAlgorithms/3DVAR.py b/src/daComposant/daAlgorithms/3DVAR.py index 039348b..f63f190 100644 --- a/src/daComposant/daAlgorithms/3DVAR.py +++ b/src/daComposant/daAlgorithms/3DVAR.py @@ -72,7 +72,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): default = [], typecast = tuple, message = "Liste de calculs supplémentaires à stocker et/ou effectuer", - listval = ["APosterioriCorrelations", "APosterioriCovariance", "APosterioriStandardDeviations", "APosterioriVariances", "BMA", "OMA", "OMB", "CostFunctionJ", "CurrentState", "CurrentOptimum", "IndexOfOptimum", "Innovation", "InnovationAtCurrentState", "SigmaObs2", "MahalanobisConsistency", "SimulationQuantiles", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum", "SimulatedObservationAtCurrentOptimum"] + listval = ["APosterioriCorrelations", "APosterioriCovariance", "APosterioriStandardDeviations", "APosterioriVariances", "BMA", "OMA", "OMB", "CostFunctionJ", "CurrentState", "CurrentOptimum", "IndexOfOptimum", "Innovation", "InnovationAtCurrentState", "CostFunctionJAtCurrentOptimum", "SigmaObs2", "MahalanobisConsistency", "SimulationQuantiles", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum", "SimulatedObservationAtCurrentOptimum"] ) self.defineRequiredParameter( name = "Quantiles", @@ -179,6 +179,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): self.StoredVariables["CostFunctionJ" ].store( J ) if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"] or \ "CurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \ + "CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \ "SimulatedObservationAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]: IndexMin = numpy.argmin( self.StoredVariables["CostFunctionJ"][nbPreviousSteps:] ) + nbPreviousSteps if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"]: @@ -187,6 +188,10 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): self.StoredVariables["CurrentOptimum"].store( self.StoredVariables["CurrentState"][IndexMin] ) if "SimulatedObservationAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]: self.StoredVariables["SimulatedObservationAtCurrentOptimum"].store( self.StoredVariables["SimulatedObservationAtCurrentState"][IndexMin] ) + if "CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]: + self.StoredVariables["CostFunctionJbAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJb"][IndexMin] ) + self.StoredVariables["CostFunctionJoAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJo"][IndexMin] ) + self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] ) return J # def GradientOfCostFunction(x): diff --git a/src/daComposant/daAlgorithms/4DVAR.py b/src/daComposant/daAlgorithms/4DVAR.py index f05163a..82ec43e 100644 --- a/src/daComposant/daAlgorithms/4DVAR.py +++ b/src/daComposant/daAlgorithms/4DVAR.py @@ -86,7 +86,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): default = [], typecast = tuple, message = "Liste de calculs supplémentaires à stocker et/ou effectuer", - listval = ["BMA", "CurrentState", "CostFunctionJ", "IndexOfOptimum", "CurrentOptimum"] + listval = ["BMA", "CurrentState", "CostFunctionJ", "IndexOfOptimum", "CurrentOptimum", "CostFunctionJAtCurrentOptimum"] ) self.defineRequiredParameter( # Pas de type name = "Bounds", @@ -210,12 +210,17 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): self.StoredVariables["CostFunctionJo"].store( Jo ) self.StoredVariables["CostFunctionJ" ].store( J ) if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"] or \ - "CurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]: + "CurrentOptimum" in self._parameters["StoreSupplementaryCalculations"] or \ + "CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]: IndexMin = numpy.argmin( self.StoredVariables["CostFunctionJ"][nbPreviousSteps:] ) + nbPreviousSteps if "IndexOfOptimum" in self._parameters["StoreSupplementaryCalculations"]: self.StoredVariables["IndexOfOptimum"].store( IndexMin ) if "CurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]: self.StoredVariables["CurrentOptimum"].store( self.StoredVariables["CurrentState"][IndexMin] ) + if "CostFunctionJAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]: + self.StoredVariables["CostFunctionJbAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJb"][IndexMin] ) + self.StoredVariables["CostFunctionJoAtCurrentOptimum"].store( self.StoredVariables["CostFunctionJo"][IndexMin] ) + self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( self.StoredVariables["CostFunctionJ" ][IndexMin] ) return J # def GradientOfCostFunction(x): diff --git a/src/daComposant/daAlgorithms/ObserverTest.py b/src/daComposant/daAlgorithms/ObserverTest.py index 4f1007c..b1070d0 100644 --- a/src/daComposant/daAlgorithms/ObserverTest.py +++ b/src/daComposant/daAlgorithms/ObserverTest.py @@ -47,9 +47,15 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # ------------------------------------------------------------ self.StoredVariables["Analysis"].store( __Xa ) self.StoredVariables["CurrentState"].store( __Xa ) + self.StoredVariables["CurrentOptimum"].store( __Xa ) + # self.StoredVariables["CostFunctionJb"].store( 1. ) self.StoredVariables["CostFunctionJo"].store( 2. ) self.StoredVariables["CostFunctionJ" ].store( 3. ) + self.StoredVariables["CostFunctionJbAtCurrentOptimum"].store( 4. ) + self.StoredVariables["CostFunctionJoAtCurrentOptimum"].store( 5. ) + self.StoredVariables["CostFunctionJAtCurrentOptimum" ].store( 6. ) + self.StoredVariables["IndexOfOptimum"].store( 1 ) # self.StoredVariables["APosterioriCovariance"].store( numpy.diag(__Xa) ) self.StoredVariables["APosterioriVariances"].store( __Xa ) @@ -59,10 +65,15 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): self.StoredVariables["OMA"].store( __YY ) self.StoredVariables["OMB"].store( __YY ) self.StoredVariables["Innovation"].store( __YY ) + self.StoredVariables["InnovationAtCurrentState"].store( __YY ) self.StoredVariables["SigmaObs2"].store( 1. ) self.StoredVariables["SigmaBck2"].store( 1. ) self.StoredVariables["MahalanobisConsistency"].store( 1. ) self.StoredVariables["SimulationQuantiles"].store( numpy.matrix((__YY,__YY,__YY)) ) + self.StoredVariables["SimulatedObservationAtBackground"].store( __YY ) + self.StoredVariables["SimulatedObservationAtCurrentState"].store( __YY ) + self.StoredVariables["SimulatedObservationAtOptimum"].store( __YY ) + self.StoredVariables["SimulatedObservationAtCurrentOptimum"].store( __YY ) # print self._post_run() diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index 78934f7..4cd191b 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -322,6 +322,9 @@ class Algorithm(object): self.StoredVariables["CostFunctionJ"] = Persistence.OneScalar(name = "CostFunctionJ") self.StoredVariables["CostFunctionJb"] = Persistence.OneScalar(name = "CostFunctionJb") self.StoredVariables["CostFunctionJo"] = Persistence.OneScalar(name = "CostFunctionJo") + self.StoredVariables["CostFunctionJAtCurrentOptimum"] = Persistence.OneScalar(name = "CostFunctionJAtCurrentOptimum") + self.StoredVariables["CostFunctionJbAtCurrentOptimum"] = Persistence.OneScalar(name = "CostFunctionJbAtCurrentOptimum") + self.StoredVariables["CostFunctionJoAtCurrentOptimum"] = Persistence.OneScalar(name = "CostFunctionJoAtCurrentOptimum") self.StoredVariables["GradientOfCostFunctionJ"] = Persistence.OneVector(name = "GradientOfCostFunctionJ") self.StoredVariables["GradientOfCostFunctionJb"] = Persistence.OneVector(name = "GradientOfCostFunctionJb") self.StoredVariables["GradientOfCostFunctionJo"] = Persistence.OneVector(name = "GradientOfCostFunctionJo") diff --git a/src/daComposant/daCore/Templates.py b/src/daComposant/daCore/Templates.py index ca71bac..8bf8294 100644 --- a/src/daComposant/daCore/Templates.py +++ b/src/daComposant/daCore/Templates.py @@ -136,42 +136,42 @@ ObserverTemplates.store( ) ObserverTemplates.store( name = "ValueGnuPlotter", - content = """import numpy, Gnuplot\nv=numpy.array(var[-1], ndmin=1)\nglobal ifig, gp\ntry:\n ifig += 1\n gp('set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """import numpy, Gnuplot\nv=numpy.array(var[-1], ndmin=1)\nglobal ifig, gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Affiche graphiquement avec Gnuplot la valeur courante de la variable", en_EN = "Graphically plot with Gnuplot the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueSerieGnuPlotter", - content = """import numpy, Gnuplot\nv=numpy.array(var[:], ndmin=1)\nglobal ifig, gp\ntry:\n ifig += 1\n gp('set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """import numpy, Gnuplot\nv=numpy.array(var[:], ndmin=1)\nglobal ifig, gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Affiche graphiquement avec Gnuplot la série des valeurs de la variable", en_EN = "Graphically plot with Gnuplot the value serie of the variable", order = "next", ) ObserverTemplates.store( name = "ValuePrinterAndGnuPlotter", - content = """print info, var[-1]\nimport numpy, Gnuplot\nv=numpy.array(var[-1], ndmin=1)\nglobal ifig,gp\ntry:\n ifig += 1\n gp('set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """print info, var[-1]\nimport numpy, Gnuplot\nv=numpy.array(var[-1], ndmin=1)\nglobal ifig,gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Imprime sur la sortie standard et, en même temps, affiche graphiquement avec Gnuplot la valeur courante de la variable", en_EN = "Print on standard output and, in the same time, graphically plot with Gnuplot the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueSeriePrinterAndGnuPlotter", - content = """print info, var[:] \nimport numpy, Gnuplot\nv=numpy.array(var[:], ndmin=1)\nglobal ifig,gp\ntry:\n ifig += 1\n gp('set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """print info, var[:] \nimport numpy, Gnuplot\nv=numpy.array(var[:], ndmin=1)\nglobal ifig,gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Imprime sur la sortie standard et, en même temps, affiche graphiquement avec Gnuplot la série des valeurs de la variable", en_EN = "Print on standard output and, in the same time, graphically plot with Gnuplot the value serie of the variable", order = "next", ) ObserverTemplates.store( name = "ValuePrinterSaverAndGnuPlotter", - content = """print info, var[-1]\nimport numpy, re\nv=numpy.array(var[-1], ndmin=1)\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint 'Value saved in \"%s\"'%f\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal ifig,gp\ntry:\n ifig += 1\n gp('set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """print info, var[-1]\nimport numpy, re\nv=numpy.array(var[-1], ndmin=1)\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint 'Value saved in \"%s\"'%f\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal ifig,gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Imprime sur la sortie standard et, en même temps, enregistre dans un fichier et affiche graphiquement la valeur courante de la variable ", en_EN = "Print on standard output and, in the same, time save in a file and graphically plot the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueSeriePrinterSaverAndGnuPlotter", - content = """print info, var[:] \nimport numpy, re\nv=numpy.array(var[:], ndmin=1)\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint 'Value saved in \"%s\"'%f\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal ifig,gp\ntry:\n ifig += 1\n gp('set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """print info, var[:] \nimport numpy, re\nv=numpy.array(var[:], ndmin=1)\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint 'Value saved in \"%s\"'%f\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal ifig,gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Imprime sur la sortie standard et, en même temps, enregistre dans un fichier et affiche graphiquement la série des valeurs de la variable", en_EN = "Print on standard output and, in the same, time save in a file and graphically plot the value serie of the variable", order = "next",