Skip to content

Commit b170eef

Browse files
string values compatible, for real this time
1 parent 2d41660 commit b170eef

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
@@ -112,7 +112,6 @@ def generate_population(tune_params, max_idx, popsize, searchspace, constraint_a
112112
for key in tune_params:
113113
ind.append(random.choice(tune_params[key]))
114114
population.append(ind)
115-
population = population
116115
return population
117116

118117

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

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

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

354352
# Apply crossover
355-
trial_vector[crossover_points] = donor_vector[crossover_points]
353+
trial_vector[crossover_points] = np.array(donor_vector)[crossover_points]
356354

357355
return list(trial_vector)
358356

@@ -376,7 +374,7 @@ def exponential_crossover(donor_vector, target, CR):
376374
l = 0
377375
while np.random.rand() < CR and l < dimensions:
378376
crossover_point = (start_point + l) % dimensions
379-
trial_idx[crossover_point] = donor_vector[crossover_point]
377+
trial_idx[crossover_point] = np.array(donor_vector)[crossover_point]
380378
l += 1
381379

382380
return list(trial_idx)

0 commit comments

Comments
 (0)