solving TSP with genetic algorithm
- in parameters.txt there is an analysis for each parameter.
- My analysis is also for hte bayg29. I ran the code for 1000 times and made average and best case for each parameter.
- you can change the cities if you like. but notice you have to change "size" too.
run the code with python 2.
- We consider every path as gene like this : [0,1,3,2,0]
- each gene starts from city 0 and come back to it at the end of the cycle. and between the two zeros we have every number from 1 to 20(the number of the cities.).
- first we make 40 Genes randomly and sort them by their fitness and select the best 50% of them.
- in each generation we make a mutation in every gene.
- this is how the mutation work: it takes two random number between 1 and 20. if the numbers are different it swap the to indexes in the gene so that a new gene creates.
- we will add each new gene to our population.
- after the mutations we take the best N% genes sorted with their fitnesses.
- we stop the algorithm when the best fitness doesn't change for 1000 times.