Skip to main content
. 2024 Jun 17;9(6):368. doi: 10.3390/biomimetics9060368
Algorithm 1 Genetic Algorithm
Input: GAP: a matrix represents the number of nodes required, P: population size, pc: crossover probability, pm: mutation probability, T: iterations
Output: Routes: dispatch routes. Cost: dispatching cost
begin
  1: Initialize population P(0) with randomly generated chromosomes using natural number encoding;
  2: t0;
  3: while (tT) do
  4:       for i1 to P do
  5:          Evaluate fitness of each chromosome in P(t);
  6:       end for
  7:       for i1 to M do
  8:         Select parent chromosomes for crossover from P(t);
  9:       end for
10:       for i1 to M/2 do
11:          Perform crossover operation on selected parent chromosomes;
12:       end for
13:       for i1 to M do
14:          Perform mutation operation on chromosomes in P(t);
15:       end for
16:       for i1 to M do
17:          Decode chromosomes in P(t) using the decoding rules;
18:          Update chromosomes in P(t) according to the decoded results;
19:       end for
20:       tt+1;
21: end while
22: end