@@ -88,7 +88,6 @@ def _ind_convert_space(ind, convert_fcn):
8888
8989
9090class DEAPOptimisationCMA (bluepyopt .optimisations .Optimisation ):
91-
9291 """CMA based optimisation class"""
9392
9493 def __init__ (self ,
@@ -140,8 +139,8 @@ def __init__(self,
140139 elif self .selector_name == 'multi_objective' :
141140 self .cma_creator = CMA_MO
142141 else :
143- raise Exception ("The selector_name has to be 'single_objective' or "
144- "'multi_objective'. Not "
142+ raise Exception ("The selector_name has to be 'single_objective' "
143+ "or 'multi_objective'. Not "
145144 "{}" .format (self .selector_name ))
146145
147146 # Number of objective values
@@ -167,21 +166,22 @@ def __init__(self,
167166 self .to_space = []
168167 for r , m in zip (bounds_radius , bounds_mean ):
169168 self .to_norm .append (
170- functools .partial (lambda param , bm , br : (param - bm ) / br , bm = m , br = r ))
169+ functools .partial (lambda param , bm , br : (param - bm ) / br ,
170+ bm = m , br = r ))
171171 self .to_space .append (
172- functools .partial (lambda param , bm , br : (param * br ) + bm , bm = m , br = r ))
172+ functools .partial (lambda param , bm , br : (param * br ) + bm ,
173+ bm = m , br = r ))
173174
174175 # Overwrite the bounds with -1. and 1.
175176 self .lbounds = numpy .full (self .problem_size , - 1. )
176177 self .ubounds = numpy .full (self .problem_size , 1. )
177-
178+
178179 self .setup_deap ()
179180
180181 # In case initial guesses were provided, rescale them to the norm space
181182 if self .centroids is not None :
182- self .centroids = [self .toolbox .Individual (_ind_convert_space (ind ,
183- self .to_norm ))
184- for ind in centroids ]
183+ self .centroids = [self .toolbox .Individual (
184+ _ind_convert_space (ind , self .to_norm )) for ind in centroids ]
185185
186186 def setup_deap (self ):
187187 """Set up optimisation"""
@@ -191,8 +191,8 @@ def setup_deap(self):
191191 numpy .random .seed (self .seed )
192192
193193 # Register the 'uniform' function
194- self .toolbox .register ("uniformparams" ,
195- utils .uniform ,
194+ self .toolbox .register ("uniformparams" ,
195+ utils .uniform ,
196196 self .lbounds ,
197197 self .ubounds ,
198198 self .ind_size )
@@ -224,7 +224,7 @@ def setup_deap(self):
224224
225225 # Register the evaluation function for the individuals
226226 self .toolbox .register ("evaluate" , self .evaluator .evaluate_with_lists )
227-
227+
228228 import copyreg
229229 import types
230230 copyreg .pickle (types .MethodType , utils .reduce_method )
@@ -268,7 +268,7 @@ def run(self,
268268 numpy .random .set_state (cp ["np_rndstate" ])
269269 CMA_es = cp ["CMA_es" ]
270270 CMA_es .map_function = self .map_function
271-
271+
272272 else :
273273 history = deap .tools .History ()
274274 logbook = deap .tools .Logbook ()
@@ -291,7 +291,7 @@ def run(self,
291291 CMA_es .set_fitness_parents (fitness )
292292
293293 gen = 1
294-
294+
295295 # Run until a termination criteria is met
296296 while CMA_es .active :
297297 logger .info ("Generation {}" .format (gen ))
@@ -338,9 +338,8 @@ def run(self,
338338 CMA_es .map_function = temp_mf
339339
340340 gen += 1
341-
342- return pop , self .hof , logbook , history
343341
342+ return pop , self .hof , logbook , history
344343
345344 def get_stats (self ):
346345 """Get the stats that will be saved during optimisation"""
0 commit comments