Skip to content

Commit

Permalink
Fixed examples of optimizing the launch of a genetic algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
LebedevIlyaG committed Apr 27, 2024
1 parent defc0ae commit 2abe115
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ def calculate(self, point: Point, function_value: FunctionValue) -> FunctionValu
:param function_value: объект хранения значения целевой функции в точке
"""
mutation_prob = point.float_variables[0]
ga_tsp = GA_TSP(func=self.calc_total_distance,
ga_tsp = GA_TSP(func=lambda x: self.calc_total_distance(x),
n_dim=self.n_dim, size_pop=self.populationSize,
max_iter=self.numberOfIterations, prob_mut=mutation_prob)
best_points, best_distance = ga_tsp.run()
function_value.value = best_distance[0]
# print(best_distance[0])
return function_value
return function_value
4 changes: 2 additions & 2 deletions examples/Genetic_algorithm/TSP/_2D/Problems/ga_tsp_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def calculate(self, point: Point, function_value: FunctionValue) -> FunctionValu
if num_population % 2 != 0:
num_population -= 1

ga_tsp = GA_TSP(func=self.calc_total_distance,
ga_tsp = GA_TSP(func=lambda x: self.calc_total_distance(x),
n_dim=self.n_dim, size_pop=num_population,
max_iter=int(self.numberOfIterations), prob_mut=mutation_prob)
best_points, best_distance = ga_tsp.run()
function_value.value = best_distance[0]
print(best_distance[0])
#print(best_distance[0])
return function_value

0 comments on commit 2abe115

Please sign in to comment.