From 0056f897e38a7d579b96ca35b124ce14828f2f15 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Fri, 10 Aug 2012 10:23:05 +0200 Subject: [PATCH] Improving Swarm as ParticleSwarmOptimization --- .../{Swarm.py => ParticleSwarmOptimization.py} | 18 +++++++++--------- .../daYacsSchemaCreator/infos_daComposant.py | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) rename src/daComposant/daAlgorithms/{Swarm.py => ParticleSwarmOptimization.py} (93%) diff --git a/src/daComposant/daAlgorithms/Swarm.py b/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py similarity index 93% rename from src/daComposant/daAlgorithms/Swarm.py rename to src/daComposant/daAlgorithms/ParticleSwarmOptimization.py index fae18f7..5c43edc 100644 --- a/src/daComposant/daAlgorithms/Swarm.py +++ b/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py @@ -29,7 +29,7 @@ import copy # ============================================================================== class ElementaryAlgorithm(BasicObjects.Algorithm): def __init__(self): - BasicObjects.Algorithm.__init__(self, "SWARM") + BasicObjects.Algorithm.__init__(self, "PARTICLESWARMOPTIMIZATION") self.defineRequiredParameter( name = "MaximumNumberOfSteps", default = 50, @@ -84,7 +84,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): def run(self, Xb=None, Y=None, H=None, M=None, R=None, B=None, Q=None, Parameters=None): """ - Swarm + Calcul de l'estimateur """ logging.debug("%s Lancement"%self._name) logging.debug("%s Taille mémoire utilisée de %.1f Mo"%(self._name, m.getUsedMemory("Mo"))) @@ -97,10 +97,10 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): BoxBounds = self._parameters["BoxBounds"] logging.debug("%s Prise en compte des bornes d'incréments de paramètres effectuee"%(self._name,)) else: - raise ValueError("Swarm global optimization requires bounds on all variables to be given.") + raise ValueError("Particle Swarm Optimization requires bounds on all variables to be given.") BoxBounds = numpy.array(BoxBounds) if numpy.isnan(BoxBounds).any(): - raise ValueError("Swarm global optimization requires bounds on all variables increments to be truly given, \"None\" is not allowed. The actual increments bounds are:\n%s"%BoxBounds) + raise ValueError("Particle Swarm Optimization requires bounds on all variables increments to be truly given, \"None\" is not allowed. The actual increments bounds are:\n%s"%BoxBounds) # Phig = float( self._parameters["GroupRecallRate"] ) Phip = 1. - Phig @@ -231,11 +231,11 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): self.StoredVariables["CostFunctionJo"].store( 0. ) self.StoredVariables["CostFunctionJ" ].store( qBest ) # - logging.debug("%s %s Step of min cost = %s"%(self._name, "SWARM", self._parameters["MaximumNumberOfSteps"])) - logging.debug("%s %s Minimum cost = %s"%(self._name, "SWARM", qBest)) - logging.debug("%s %s Minimum state = %s"%(self._name, "SWARM", numpy.asmatrix(Best).flatten().T)) - logging.debug("%s %s Nb of F = %s"%(self._name, "SWARM", (self._parameters["MaximumNumberOfSteps"]+1)*self._parameters["NumberOfInsects"]+1)) - logging.debug("%s %s RetCode = %s"%(self._name, "SWARM", 0)) + 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 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)) # # Obtention de l'analyse # ---------------------- diff --git a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py index e981375..67ddf8a 100644 --- a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py +++ b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py @@ -62,7 +62,7 @@ AssimAlgos = [ "LinearLeastSquares", "NonLinearLeastSquares", "QuantileRegression", - "Swarm", + "ParticleSwarmOptimization", ] CheckAlgos = [ "GradientTest", @@ -100,16 +100,16 @@ AlgoDataRequirements["NonLinearLeastSquares"] = [ "Observation", "ObservationError", "ObservationOperator", ] +AlgoDataRequirements["ParticleSwarmOptimization"] = [ + "Background", "BackgroundError", + "Observation", "ObservationError", + "ObservationOperator", + ] AlgoDataRequirements["QuantileRegression"] = [ "Background", "Observation", "ObservationOperator", ] -AlgoDataRequirements["Swarm"] = [ - "Background", "BackgroundError", - "Observation", "ObservationError", - "ObservationOperator", - ] AlgoDataRequirements["GradientTest"] = [ "CheckingPoint", @@ -127,8 +127,8 @@ AlgoType["EnsembleBlue"] = "Optim" AlgoType["KalmanFilter"] = "Optim" AlgoType["LinearLeastSquares"] = "Optim" AlgoType["NonLinearLeastSquares"] = "Optim" +AlgoType["ParticleSwarmOptimization"] = "Optim" AlgoType["QuantileRegression"] = "Optim" -AlgoType["Swarm"] = "Optim" # Variables qui sont partages avec le generateur de # catalogue Eficas -- 2.39.2