@@ -1531,8 +1531,7 @@ def cal_pop_fitness(self):
1531
1531
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 ):
1532
1532
# Return the index of the elitism from the elitism array 'self.last_generation_elitism'.
1533
1533
# 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 ))
1536
1535
# Use the returned elitism index to return its index in the last population.
1537
1536
elitism_idx = self .last_generation_elitism_indices [elitism_idx ]
1538
1537
# Use the elitism's index to return its pre-calculated fitness value.
@@ -1544,8 +1543,7 @@ def cal_pop_fitness(self):
1544
1543
# Index of the parent in the 'self.last_generation_parents' array.
1545
1544
# This is not its index within the population. It is just its index in the 'self.last_generation_parents' array.
1546
1545
# 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 ))
1549
1547
# Use the returned parent index to return its index in the last population.
1550
1548
parent_idx = self .last_generation_parents_indices [parent_idx ]
1551
1549
# Use the parent's index to return its pre-calculated fitness value.
@@ -1573,13 +1571,11 @@ def cal_pop_fitness(self):
1573
1571
solutions_indices = numpy .where (
1574
1572
numpy .array (pop_fitness ) == "undefined" )[0 ]
1575
1573
# 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 ))
1578
1575
# For each batch, get its indices and call the fitness function.
1579
1576
for batch_idx in range (num_batches ):
1580
1577
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
1583
1579
batch_indices = solutions_indices [batch_first_index :batch_last_index ]
1584
1580
batch_solutions = self .population [batch_indices , :]
1585
1581
@@ -1660,17 +1656,15 @@ def cal_pop_fitness(self):
1660
1656
# Reaching this block means that batch processing is used. The fitness values are calculated in batches.
1661
1657
1662
1658
# 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 ))
1665
1660
# Each element of the `batches_solutions` list represents the solutions in one batch.
1666
1661
batches_solutions = []
1667
1662
# Each element of the `batches_indices` list represents the solutions' indices in one batch.
1668
1663
batches_indices = []
1669
1664
# For each batch, get its indices and call the fitness function.
1670
1665
for batch_idx in range (num_batches ):
1671
1666
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
1674
1668
batch_indices = solutions_to_submit_indices [batch_first_index :batch_last_index ]
1675
1669
batch_solutions = self .population [batch_indices , :]
1676
1670
0 commit comments