From 2cc2c16e29a010cd3eaba886e4688b46ed93cd4d Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Mon, 12 Nov 2012 12:48:05 +0100 Subject: [PATCH] Improving the treatment of special cases for minimum --- src/daComposant/daAlgorithms/3DVAR.py | 4 +++- src/daComposant/daAlgorithms/NonLinearLeastSquares.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/daComposant/daAlgorithms/3DVAR.py b/src/daComposant/daAlgorithms/3DVAR.py index 0cc504e..ebfd8f9 100644 --- a/src/daComposant/daAlgorithms/3DVAR.py +++ b/src/daComposant/daAlgorithms/3DVAR.py @@ -176,6 +176,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # # Minimisation de la fonctionnelle # -------------------------------- + n0 = self.StoredVariables["CostFunctionJ"].stepnumber() + # if self._parameters["Minimizer"] == "LBFGSB": Minimum, J_optimal, Informations = scipy.optimize.fmin_l_bfgs_b( func = CostFunction, @@ -238,7 +240,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): else: raise ValueError("Error in Minimizer name: %s"%self._parameters["Minimizer"]) # - StepMin = numpy.argmin( self.StoredVariables["CostFunctionJ"].valueserie() ) + StepMin = numpy.argmin( self.StoredVariables["CostFunctionJ"].valueserie()[n0:] ) MinJ = self.StoredVariables["CostFunctionJ"].valueserie(step = StepMin) # # Correction pour pallier a un bug de TNC sur le retour du Minimum diff --git a/src/daComposant/daAlgorithms/NonLinearLeastSquares.py b/src/daComposant/daAlgorithms/NonLinearLeastSquares.py index 27cec60..e39c698 100644 --- a/src/daComposant/daAlgorithms/NonLinearLeastSquares.py +++ b/src/daComposant/daAlgorithms/NonLinearLeastSquares.py @@ -206,6 +206,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # # Minimisation de la fonctionnelle # -------------------------------- + n0 = self.StoredVariables["CostFunctionJ"].stepnumber() + # if self._parameters["Minimizer"] == "LBFGSB": Minimum, J_optimal, Informations = scipy.optimize.fmin_l_bfgs_b( func = CostFunction, @@ -280,7 +282,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): else: raise ValueError("Error in Minimizer name: %s"%self._parameters["Minimizer"]) # - StepMin = numpy.argmin( self.StoredVariables["CostFunctionJ"].valueserie() ) + StepMin = numpy.argmin( self.StoredVariables["CostFunctionJ"].valueserie()[n0:] ) MinJ = self.StoredVariables["CostFunctionJ"].valueserie(step = StepMin) # # Correction pour pallier a un bug de TNC sur le retour du Minimum -- 2.39.2