@@ -1531,8 +1531,7 @@ def cal_pop_fitness(self):
15311531 elif (self .keep_elitism > 0 ) and (self .last_generation_elitism is not None ) and (len (self .last_generation_elitism ) > 0 ) and (list (sol ) in last_generation_elitism_as_list ):
15321532 # Return the index of the elitism from the elitism array 'self.last_generation_elitism'.
15331533 # This is not its index within the population. It is just its index in the 'self.last_generation_elitism' array.
1534- elitism_idx = last_generation_elitism_as_list .index (
1535- list (sol ))
1534+ elitism_idx = last_generation_elitism_as_list .index (list (sol ))
15361535 # Use the returned elitism index to return its index in the last population.
15371536 elitism_idx = self .last_generation_elitism_indices [elitism_idx ]
15381537 # Use the elitism's index to return its pre-calculated fitness value.
@@ -1544,8 +1543,7 @@ def cal_pop_fitness(self):
15441543 # Index of the parent in the 'self.last_generation_parents' array.
15451544 # This is not its index within the population. It is just its index in the 'self.last_generation_parents' array.
15461545 # parent_idx = numpy.where(numpy.all(self.last_generation_parents == sol, axis=1))[0][0]
1547- parent_idx = last_generation_parents_as_list .index (
1548- list (sol ))
1546+ parent_idx = last_generation_parents_as_list .index (list (sol ))
15491547 # Use the returned parent index to return its index in the last population.
15501548 parent_idx = self .last_generation_parents_indices [parent_idx ]
15511549 # Use the parent's index to return its pre-calculated fitness value.
@@ -1573,13 +1571,11 @@ def cal_pop_fitness(self):
15731571 solutions_indices = numpy .where (
15741572 numpy .array (pop_fitness ) == "undefined" )[0 ]
15751573 # Number of batches.
1576- num_batches = int (numpy .ceil (
1577- len (solutions_indices ) / self .fitness_batch_size ))
1574+ num_batches = int (numpy .ceil (len (solutions_indices ) / self .fitness_batch_size ))
15781575 # For each batch, get its indices and call the fitness function.
15791576 for batch_idx in range (num_batches ):
15801577 batch_first_index = batch_idx * self .fitness_batch_size
1581- batch_last_index = (batch_idx + 1 ) * \
1582- self .fitness_batch_size
1578+ batch_last_index = (batch_idx + 1 ) * self .fitness_batch_size
15831579 batch_indices = solutions_indices [batch_first_index :batch_last_index ]
15841580 batch_solutions = self .population [batch_indices , :]
15851581
@@ -1660,17 +1656,15 @@ def cal_pop_fitness(self):
16601656 # Reaching this block means that batch processing is used. The fitness values are calculated in batches.
16611657
16621658 # Number of batches.
1663- num_batches = int (numpy .ceil (
1664- len (solutions_to_submit_indices ) / self .fitness_batch_size ))
1659+ num_batches = int (numpy .ceil (len (solutions_to_submit_indices ) / self .fitness_batch_size ))
16651660 # Each element of the `batches_solutions` list represents the solutions in one batch.
16661661 batches_solutions = []
16671662 # Each element of the `batches_indices` list represents the solutions' indices in one batch.
16681663 batches_indices = []
16691664 # For each batch, get its indices and call the fitness function.
16701665 for batch_idx in range (num_batches ):
16711666 batch_first_index = batch_idx * self .fitness_batch_size
1672- batch_last_index = (batch_idx + 1 ) * \
1673- self .fitness_batch_size
1667+ batch_last_index = (batch_idx + 1 ) * self .fitness_batch_size
16741668 batch_indices = solutions_to_submit_indices [batch_first_index :batch_last_index ]
16751669 batch_solutions = self .population [batch_indices , :]
16761670
0 commit comments