From 4c6d99976fc4966797d1951ac9ad4b57c516a19b Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Fri, 10 Aug 2012 15:42:21 +0200 Subject: [PATCH] Slight corrections of parameters and variables treatment --- src/daComposant/daAlgorithms/3DVAR.py | 2 +- .../daAlgorithms/NonLinearLeastSquares.py | 2 +- .../daAlgorithms/ParticleSwarmOptimization.py | 12 +++++------- src/daComposant/daAlgorithms/QuantileRegression.py | 6 +++--- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/daComposant/daAlgorithms/3DVAR.py b/src/daComposant/daAlgorithms/3DVAR.py index dbb710b..8997f3a 100644 --- a/src/daComposant/daAlgorithms/3DVAR.py +++ b/src/daComposant/daAlgorithms/3DVAR.py @@ -267,7 +267,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # # Obtention de l'analyse # ---------------------- - Xa = numpy.asmatrix(Minimum).T + Xa = numpy.asmatrix(Minimum).flatten().T logging.debug("%s Analyse Xa = %s"%(self._name, Xa)) # self.StoredVariables["Analysis"].store( Xa.A1 ) diff --git a/src/daComposant/daAlgorithms/NonLinearLeastSquares.py b/src/daComposant/daAlgorithms/NonLinearLeastSquares.py index f77ab01..cee9082 100644 --- a/src/daComposant/daAlgorithms/NonLinearLeastSquares.py +++ b/src/daComposant/daAlgorithms/NonLinearLeastSquares.py @@ -262,7 +262,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # # Obtention de l'analyse # ---------------------- - Xa = numpy.asmatrix(Minimum).T + Xa = numpy.asmatrix(Minimum).flatten().T logging.debug("%s Analyse Xa = %s"%(self._name, Xa)) # self.StoredVariables["Analysis"].store( Xa.A1 ) diff --git a/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py b/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py index 5c43edc..0f81857 100644 --- a/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py +++ b/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py @@ -35,7 +35,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): default = 50, typecast = int, message = "Nombre maximal de pas d'optimisation", - minval = -1 + minval = 1, ) self.defineRequiredParameter( name = "SetSeed", @@ -130,7 +130,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # ------------------------------ def CostFunction(x, QualityMeasure="AugmentedPonderatedLeastSquares"): _X = numpy.asmatrix(x).flatten().T - logging.debug("%s CostFunction X = %s"%(self._name, numpy.asmatrix( _X ).flatten())) + logging.debug("%s CostFunction X = %s"%(self._name, _X.A1)) _HX = Hm( _X ) _HX = numpy.asmatrix(_HX).flatten().T # @@ -164,8 +164,6 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): logging.debug("%s CostFunction J = %s"%(self._name, J)) return J # - # Paramètres de pilotage - # ---------------------- # Point de démarrage de l'optimisation : Xini = Xb # ------------------------------------ if type(Xb) is type(numpy.matrix([])): @@ -223,17 +221,17 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): if quality < qBest : Best = numpy.asmatrix(insect).flatten().A1 qBest = quality - logging.debug("%s Iteration %i : qBest = %.5f, Best = %s"%(self._name, n+1,qBest,numpy.asmatrix(Best.flatten()).A1)) + logging.debug("%s Iteration %i : qBest = %.5f, Best = %s"%(self._name, n+1,qBest,Best)) # if self._parameters["StoreInternalVariables"]: - self.StoredVariables["CurrentState"].store( numpy.asmatrix(Best.flatten()).A1 ) + self.StoredVariables["CurrentState"].store( Best ) self.StoredVariables["CostFunctionJb"].store( 0. ) self.StoredVariables["CostFunctionJo"].store( 0. ) self.StoredVariables["CostFunctionJ" ].store( qBest ) # logging.debug("%s %s Step of min cost = %s"%(self._name, self._parameters["QualityCriterion"], self._parameters["MaximumNumberOfSteps"])) logging.debug("%s %s Minimum cost = %s"%(self._name, self._parameters["QualityCriterion"], qBest)) - logging.debug("%s %s Minimum state = %s"%(self._name, self._parameters["QualityCriterion"], numpy.asmatrix(Best).flatten().T)) + logging.debug("%s %s Minimum state = %s"%(self._name, self._parameters["QualityCriterion"], Best)) logging.debug("%s %s Nb of F = %s"%(self._name, self._parameters["QualityCriterion"], (self._parameters["MaximumNumberOfSteps"]+1)*self._parameters["NumberOfInsects"]+1)) logging.debug("%s %s RetCode = %s"%(self._name, self._parameters["QualityCriterion"], 0)) # diff --git a/src/daComposant/daAlgorithms/QuantileRegression.py b/src/daComposant/daAlgorithms/QuantileRegression.py index 8e93044..616b41a 100644 --- a/src/daComposant/daAlgorithms/QuantileRegression.py +++ b/src/daComposant/daAlgorithms/QuantileRegression.py @@ -49,7 +49,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): default = 15000, typecast = int, message = "Nombre maximal de pas d'optimisation", - minval = -1 + minval = 1, ) self.defineRequiredParameter( name = "CostDecrementTolerance", @@ -120,7 +120,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # def GradientOfCostFunction(x): _X = numpy.asmatrix(x).flatten().T - logging.debug("%s GradientOfCostFunction X = %s"%(self._name, numpy.asmatrix( _X ).flatten())) + logging.debug("%s GradientOfCostFunction X = %s"%(self._name, _X.A1)) Hg = H["Tangent"].asMatrix( _X ) return Hg # @@ -158,7 +158,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # # Obtention de l'analyse # ---------------------- - Xa = numpy.asmatrix(Minimum).T + Xa = numpy.asmatrix(Minimum).flatten().T logging.debug("%s Analyse Xa = %s"%(self._name, Xa)) # self.StoredVariables["Analysis"].store( Xa.A1 ) -- 2.39.2