|
Algorithm 1. Designing Shuttle Bus Routes with Genetic Algorithm |
Input: generated shuttle stops, distance matrix, iteration epochs maxiter, crossover probability pc, mutation probability pm, population size pop_size, population selection probability p_select.
-
1
Initialize populations to the default, i.e., generate random sequences for all shuttle stops.
-
2
Based on Constraints 2-1 to 2-3, split and generate the initial sets of shuttle routes.
-
3
Calculate the length and fitness of the initial route set, fitness = 1/sum of routes length.
-
4
Randomly select an initial set of shuttle routes as the best chromosome.
-
5
Loop for maxiter iterations, in each iteration:
-
5.1
Population selection, retaining populations (shuttle routes sets) with high adaptation, i.e., route sets with short mileage.
-
5.2
If crossover conditions are satisfied ( pc and pop_size), do crossover between chromosomes of two populations:
-
5.2.1
Randomly select two crossover stops in the range “2” to “No of stops”.
//Note: The first stop is fixed, namely Shengxianhu Station.
-
5.2.2
Perform chromosome crossover and ensure that there are no duplicate stops in the same set of shuttle routes.
-
5.3
If mutation conditions are satisfied ( pm and pop_size), do mutation for each chromosome.
-
5.3.1
Choose two random numbers [a], [b] in the range “2” to “No of stops”.
-
5.3.2
Swap the values of new gene [a] and new gene [b].
-
5.4
Based on Constraints 2-1 to 2-3, split and generate a new set of shuttle routes.
-
5.5
If the fitness value of the new route set is greater than that of the best chromosome, then set best chromosome = new chromosome.
-
6
End of Loop.
Output: The best set of shuttle bus routes. |