Skip to content

Commit

Permalink
A list is a list
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored Jul 6, 2017
1 parent a17d425 commit 8ba74d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Solid/EvolutionaryAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def __init__(self, crossover_rate, mutation_rate, max_steps, max_fitness=None):
:param max_fitness: fitness value to stop algorithm once reached
"""
if isinstance(crossover_rate, float):
if crossover_rate >= 0 and crossover_rate <= 1:
if 0 <= crossover_rate <= 1:
self.crossover_rate = crossover_rate
else:
raise ValueError('Crossover rate must be a float between 0 and 1')
else:
raise ValueError('Crossover rate must be a float between 0 and 1')

if isinstance(mutation_rate, float):
if mutation_rate >= 0 and mutation_rate <= 1:
if 0 <= mutation_rate <= 1:
self.mutation_rate = mutation_rate
else:
raise ValueError('Mutation rate must be a float between 0 and 1')
Expand Down Expand Up @@ -105,7 +105,7 @@ def _populate_fitness(self):
:return: None
"""
self.fitnesses = list([self._fitness(x) for x in self.population])
self.fitnesses = [self._fitness(x) for x in self.population]

def _most_fit(self):
"""
Expand Down Expand Up @@ -183,7 +183,7 @@ def run(self, verbose=True):
for i in range(self.max_steps):
self.cur_steps += 1

if ((i + 1) % 100 == 0) and verbose:
if verbose and ((i + 1) % 100 == 0):
print(self)

self.population = self._select_n(num_copy)
Expand Down

0 comments on commit 8ba74d3

Please sign in to comment.