Skip to content

Commit 7be2d86

Browse files
committed
Merge remote-tracking branch 'origin/custom_diff_evo' into constrained_optimization_tunable
2 parents cfb67ae + b170eef commit 7be2d86

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

kernel_tuner/strategies/diff_evo.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def generate_population(tune_params, max_idx, popsize, searchspace, constraint_a
111111
for key in tune_params:
112112
ind.append(random.choice(tune_params[key]))
113113
population.append(ind)
114-
population = population
115114
return population
116115

117116

@@ -224,9 +223,8 @@ def differential_evolution(searchspace, cost_func, bounds, popsize, maxiter, F,
224223
if trial_cost <= population_cost[i]:
225224

226225
# check if trial_vector is not already in population
227-
idxs = [idx for idx in range(popsize) if idx != i]
228-
if trial_vector not in population[idxs]:
229-
population[i] = np.array(trial_vector)
226+
if population.count(trial_vector) == 0:
227+
population[i] = trial_vector
230228
population_cost[i] = trial_cost
231229
no_change = False
232230

@@ -351,7 +349,7 @@ def binomial_crossover(donor_vector, target, CR):
351349
crossover_points[np.random.randint(0, dimensions)] = True
352350

353351
# Apply crossover
354-
trial_vector[crossover_points] = donor_vector[crossover_points]
352+
trial_vector[crossover_points] = np.array(donor_vector)[crossover_points]
355353

356354
return list(trial_vector)
357355

@@ -375,7 +373,7 @@ def exponential_crossover(donor_vector, target, CR):
375373
l = 0
376374
while np.random.rand() < CR and l < dimensions:
377375
crossover_point = (start_point + l) % dimensions
378-
trial_idx[crossover_point] = donor_vector[crossover_point]
376+
trial_idx[crossover_point] = np.array(donor_vector)[crossover_point]
379377
l += 1
380378

381379
return list(trial_idx)

0 commit comments

Comments
 (0)