Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit b50782c

Browse files
author
Tanguy Damart
committed
Bug fix
1 parent 67d4195 commit b50782c

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

bluepyopt/deapext/CMA_MO.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ def __init__(self,
120120
'Impossible to use scoop is providing self defined map '
121121
'function: %s' % self.map_function)
122122
from scoop import futures
123-
self.toolbox.register("map", futures.map)
124-
elif self.map_function:
125-
self.toolbox.register("map", self.map_function)
123+
self.map_function = futures.map
126124

127125
# Set termination conditions
128126
self.active = True
@@ -150,9 +148,10 @@ def hyper_volume(self, front):
150148
ref = ref[idxs]
151149

152150
# Prepare the data and send it to multiprocess
151+
to_evaluate = []
153152
for i in range(len(front)):
154153
to_evaluate.append([i, numpy.copy(wobj), numpy.copy(ref)])
155-
contrib_values = self.toolbox.map(contribution, to_evaluate)
154+
contrib_values = self.map_function(contribution, to_evaluate)
156155

157156
return list(contrib_values)
158157

bluepyopt/deapext/CMA_SO.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def update(self, population):
104104
"""Update the current covariance matrix strategy from the
105105
population"""
106106

107-
population.sort(key=lambda ind: ind.fitness.reduce_weight,
107+
population.sort(key=lambda ind: ind.fitness.weighted_reduce,
108108
reverse=True)
109109

110110
old_centroid = self.centroid

bluepyopt/deapext/optimisations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def run(self,
238238
else:
239239
pop = self.toolbox.population(n=offspring_size)
240240

241-
stats = deap.tools.Statistics(key=lambda ind: ind.fitness.sum)
241+
stats = deap.tools.Statistics(key=lambda ind: ind.fitness.reduce)
242242
import numpy
243243
stats.register("avg", numpy.mean)
244244
stats.register("std", numpy.std)

bluepyopt/deapext/optimisationsCMA.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def setup_deap(self):
168168
self.toolbox.register(
169169
"RandomInd",
170170
deap.tools.initIterate,
171-
functools.partial(WSListIndividual,
171+
functools.partial(utils.WSListIndividual,
172172
obj_size=self.ind_size,
173173
reduce_fcn=self.fitness_reduce),
174174
self.toolbox.uniformparams)

bluepyopt/deapext/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def weighted_reduce(self):
4444
return self.reduce_fcn(self.wvalues)
4545

4646
def __le__(self, other):
47-
return self.weighted_sum <= other.weighted_sum
47+
return self.weighted_reduce <= other.weighted_reduce
4848

4949
def __lt__(self, other):
50-
return self.weighted_sum < other.weighted_sum
50+
return self.weighted_reduce < other.weighted_reduce
5151

5252
def __deepcopy__(self, _):
5353
"""Override deepcopy"""
@@ -73,7 +73,8 @@ def __init__(self, *args, **kwargs):
7373
self._ps = "p", 0
7474

7575
del kwargs['obj_size']
76-
del kwargs['reduce_fcn']
76+
if 'reduce_fcn' in kwargs:
77+
del kwargs['reduce_fcn']
7778
super(WSListIndividual, self).__init__(*args, **kwargs)
7879

7980

0 commit comments

Comments
 (0)