-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
29 lines (26 loc) · 1.01 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from ga.genetic_algorithm import *
# insert matrix in "matrix_to_use" parameter
if __name__ == "__main__":
# best parameters found after grid search
result = ga(initializer=population,
evaluator=fitness_function,
selection=tournament_selection,
crossover=order_crossover,
mutation=swap_mutation,
mutation_rate=0.1,
population_size=100,
num_generations=50,
crossover_rate=0.7,
elitism_size=2,
elitism=True,
matrix_to_use= None, # insert here list of lists, else None
matrix_seed=None,
verbose=True,
visualize=True,
dashboard=True,
fitness_sharing=True)
# if len(result) == 5 it means dashboard = True, then activate dash
if isinstance(result, tuple) and len(result) == 5:
routes, fitnesses, best_route, best_fitness, matrix = result
# call the dashboard function with the GA results only if dashboard=True
run_dashboard(routes, fitnesses, best_route, matrix)