This code was implemented for the graph discipline the objective is to resolve the traveling salesman problem using a genetic algorithm.
To run the code:
pythom3 main.py
These are the initial settings of the code you can change them according to your specifications.
- Population size: 10
- Probability of mutation: 0.5
- Crossover: Is defined by function mutatedGene which makes a random change between tho cities.
Current temp: 10000
Geração 1
GNOME Valor Fitness
0121213651412120 802
0121213611452120 773
0121123651412120 769
0123211651412120 753
0121213651412120 802
0121213651412120 802
0121213651412120 802
0151213621412120 752
0126213151412120 694
0121613251412120 768
Current temp: 9000.0
Geração 2
GNOME Valor Fitness
0126212151412130 667
0151213621412120 752
0213211651412120 784
0121613252412110 676
0121143651212120 796
0121413611252120 741
0121213251416120 768
0121213654112120 791
0521213611412120 764
0123211651412120 753
Current temp: 8100.0
Geração 3
GNOME Valor Fitness
0126212151412130 667
0121615232412110 686
0121413116252120 683
0151213621112420 650
0123411651212120 780
0421213611512120 773
0121213151426120 718
0211211653412120 737
0121213654111220 681
0121143151212620 688
Current temp: 7290.0
Geração 4
GNOME Valor Fitness
0151213621112420 650
0126214151212130 667
0121211654131220 698
0121413116252120 683
0121615232112140 734
0124113151212620 643
0123211151426120 652
0511211623412120 710
0426213111512120 640
0121411651232120 753
Current temp: 6561.0
Geração 5
GNOME Valor Fitness
0421213161512120 790
0124113151212620 643
0121213621115420 690
0122311151426120 575
0126214351212110 616
0121413216152120 768
0621211154131220 648
0511211223416120 675
0121615232121140 734
0121411651232210 645