Here, I have used the Genetic Algorithm to solve the popular TSP. You will need to give the map to the geneticAlgorithm method in form of a nested list. You can change the maximum number of iterations(number of populations), population size, probability of mutation and you can also mannually set the initial population. The algorithm terminates whenever it exceeds the iteration limit, or when the average fitness of a population does not get better after creating a new generation of population. In each iteration, two individuals of the current population are chosen based on a weighted random choice. Needless to say that their probability to be chosen is based on their fitness. Fitter they are, the less is their fit attribute(cost of the salesman search) and the higher is their chance to be chosen. Next, the two selected individuals create an offspring, using partially mapped crossover. The mentioned offspring will then go through a random mutation with a small probability and is finally ready to be added to the next population.
-
Notifications
You must be signed in to change notification settings - Fork 0
nikashahabi/TSP-with-genetic-algorithm
About
Implementing GA to solve TSP
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published