@@ -71,7 +71,7 @@ def indices_to_values(individual_indices, tune_params):
71
71
values = []
72
72
for dim , idx in enumerate (individual_indices ):
73
73
values .append (tune_params_list [dim ][idx ])
74
- return np . array ( values )
74
+ return values
75
75
76
76
77
77
def parse_method (method ):
@@ -104,15 +104,15 @@ def generate_population(tune_params, max_idx, popsize, searchspace, constraint_a
104
104
if constraint_aware :
105
105
samples = LatinHypercube (len (tune_params )).integers (l_bounds = 0 , u_bounds = max_idx , n = popsize , endpoint = True )
106
106
population = [indices_to_values (sample , tune_params ) for sample in samples ]
107
- population = np . array ( [repair (individual , searchspace ) for individual in population ])
107
+ population = [repair (individual , searchspace ) for individual in population ]
108
108
else :
109
109
population = []
110
110
for _ in range (popsize ):
111
111
ind = []
112
112
for key in tune_params :
113
113
ind .append (random .choice (tune_params [key ]))
114
114
population .append (ind )
115
- population = np . array ( population )
115
+ population = population
116
116
return population
117
117
118
118
@@ -354,7 +354,7 @@ def binomial_crossover(donor_vector, target, CR):
354
354
# Apply crossover
355
355
trial_vector [crossover_points ] = donor_vector [crossover_points ]
356
356
357
- return trial_vector
357
+ return list ( trial_vector )
358
358
359
359
360
360
def exponential_crossover (donor_vector , target , CR ):
@@ -379,7 +379,7 @@ def exponential_crossover(donor_vector, target, CR):
379
379
trial_idx [crossover_point ] = donor_vector [crossover_point ]
380
380
l += 1
381
381
382
- return trial_idx
382
+ return list ( trial_idx )
383
383
384
384
385
385
def repair (trial_vector , searchspace ):
@@ -394,7 +394,7 @@ def repair(trial_vector, searchspace):
394
394
395
395
# if we have found valid neighboring configurations, select one at random
396
396
if len (neighbors ) > 0 :
397
- new_trial_vector = np . array ( list (random .choice (neighbors ) ))
397
+ new_trial_vector = list (random .choice (neighbors ))
398
398
print (f"Differential evolution resulted in invalid config { trial_vector = } , repaired to { new_trial_vector = } " )
399
399
return new_trial_vector
400
400
0 commit comments