Skip to content

Commit d28af66

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b740c01 commit d28af66

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

genetic_algorithm/function_optimization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def parse_function(user_input):
2424
raise ValueError("Invalid function format. Please use 'f(x, y) = ...'.")
2525

2626
# Replace variable names and power operator
27-
expression = expression.replace('^', '**').replace('x', 'x[0]').replace('y', 'x[1]')
27+
expression = expression.replace("^", "**").replace("x", "x[0]").replace("y", "x[1]")
2828

2929
# Create the fitness function
3030
def fitness(x):
@@ -90,7 +90,7 @@ def genetic_algorithm(user_fitness_function) -> None:
9090

9191
# Selection
9292
selected_parents = population[rng.choice(population_size, population_size)]
93-
93+
9494
# Crossover
9595
offspring = []
9696
for i in range(0, population_size - 1, 2): # Ensure even number of parents
@@ -139,4 +139,4 @@ def genetic_algorithm(user_fitness_function) -> None:
139139
except (SyntaxError, ValueError) as e:
140140
print(f"Error: {e}")
141141
except NameError as e:
142-
print(f"Error: {e}")
142+
print(f"Error: {e}")

0 commit comments

Comments
 (0)