Mutation and Crossover techniques

(Note: in these examples, the indexing of "location" and "where" starts on 1. In the actual program the indexing starts on 0)

> (test 5 10 0 'mutate1)  <--An optional parameter for mutation type
                               was added to allow for specifying one
                               of the mutations.

The above function call runs the genetic algorithm for 5 
generations.  There are 10 mutations and 0 crossovers for each
generation.  The mutations are all of mutation type 1, meaning that: 
    - a random individual within the population is picked
    - a random location within the individual is picked
    - a random city is chosen and placed at the above
      random location


The cities are defined within a list.  Here there are 5 cities:

(defparameter *cities*
              '(seattle portland spokane wenatchee bellingham) )

The population consists of a collection of individuals.  Each 
individual is one path.  The initial path is a route consisting
only of one city.  The number after the path list is the 
chromosone strength of the path.

(defparameter *initial-population*
  '( ((seattle seattle seattle seattle seattle) . 0) ) )

The maximum number of individuals in a population is set to 15:

(defparameter *population-limit* 15)


1. The population is a list of individuals:
   
    ( individual1 individual2 ...  individualn )

Each of the individuals in the population is an association
  list and has the form:

    ( ( list of cities in one path ) . chromosone-strength )

    
2. The initial population consists of one individual - a path of 
   5 seattles.  

3. The minimum chromosone strength calculated is .5.  A path 
   consisting of only one city will calculate a chromosone
   strength of .5.  Here's an example calculation using
   (seattle seattle seattle seattle seattle):

  chromosone-strength = 10000/(2 * cycle-cost + 50 * non-tour-penalty)

  The cycle-cost is calculated as the length of the path from 
  the start node to the end node and then return.

  The non-tour-penalty is 100 * (length of set-difference1 +
                                 length of set-difference2)

   set-difference1 = path - *cities*
   set-difference2 = *cities* - path

  For the initial path (seattle seattle seattle seattle seattle),
     cycle-cost = 0   , the length of the path from
                        seattle to seattle = 0

     set-difference1 = path - *cities* = nil
     set-difference2 = *cities* - path 
                     = (portland spokane wenatchee bellingham)

     non-tour-penalty = 100 * (0 + 4) = 400

     chromosone-strength = 10000/(2 * 0 + 50 * 400)
                         = 10000/20000 = .5

     Therefore, .5 is the strength calculated for a path consisting
     of the same city. 

 
4. Mutate1 works by
    A. picking a random individual from the population
    B. picking a random point in within this individual
    C. picking a random city from the list of cities
    D. replacing this random city with another city in this 
       location.
    E. if the population is not full, push this new individual
       onto the population
    F. if the population is full: 
         find the minimum chromosone-strength
         if it is less than the strength of this new indivdual,
           then swap these two

 
Trace of mutate1:
 
   1. initial population:
      ( ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0) ) 

   2. mutate in location 5, new city = SPOKANE
      The new individual is:

      ((SEATTLE SEATTLE SEATTLE SEATTLE SPOKANE) . 0.6097561) 

      The updated population is

    ( ((SEATTLE SEATTLE SEATTLE SEATTLE SPOKANE) . 0.6097561)
      ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0) )

   3. Mutate ((SEATTLE SEATTLE SEATTLE SEATTLE SPOKANE) . 0.6097561)
      Remember that this individual is randomly picked.

      Mutate at position 1 with city Bellingham.

    ( (BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)


      The new population is
      ( ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
        ((SEATTLE SEATTLE SEATTLE SEATTLE SPOKANE) . 0.6097561)
        ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0) ) 

    4. Mutate ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691) 
       at position 5 with SPOKANE.  
       This is a good example of not-so-well picked "random"-ness
       
       The new individual is 
       ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691) 

      The new population is
      ( ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
        ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
        ((SEATTLE SEATTLE SEATTLE SEATTLE SPOKANE) . 0.6097561)
        ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0) ) 

    5. Mutate ((SEATTLE SEATTLE SEATTLE SEATTLE SPOKANE) . 0.6097561)
       at position 4 with PORTLAND:
       The new individual is
       ((SEATTLE SEATTLE SEATTLE PORTLAND SPOKANE) . 0.84745765)  

       The new population is
      ( ((SEATTLE SEATTLE SEATTLE PORTLAND SPOKANE) . 0.84745765)
        ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
        ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
        ((SEATTLE SEATTLE SEATTLE SEATTLE SPOKANE) . 0.6097561)
        ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0) )

      Note that the individuals are not inserted in order.

    6. After 9 generations, the population has 10 individuals
       (9 "mutated" individuals + 1 "starter" individual):
     ( ((SEATTLE SEATTLE SEATTLE SPOKANE PORTLAND) . 0.84745765)
       ((PORTLAND SEATTLE SEATTLE SEATTLE SPOKANE) . 0.84745765)
       ((SEATTLE SEATTLE SEATTLE SEATTLE PORTLAND) . 0.64102566)
       ((SEATTLE SEATTLE SEATTLE WENATCHEE SEATTLE) . 0.64935064)
       ((SEATTLE SEATTLE SPOKANE PORTLAND SPOKANE) . 0.7692308)
       ((SEATTLE SEATTLE SEATTLE PORTLAND SPOKANE) . 0.84745765)
       ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
       ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
       ((SEATTLE SEATTLE SEATTLE SEATTLE SPOKANE) . 0.6097561)
       ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0) )

    7. The individual picked to be mutated is
       ((SEATTLE SEATTLE SEATTLE SEATTLE PORTLAND) . 0.64102566) 

       at position 1 with city PORTLAND

       ((PORTLAND SEATTLE SEATTLE SEATTLE PORTLAND) . 0.64102566) 

       The lowest chromosone strength of 0 is removed, and the new
        individual is added to the top of the list:

( ((PORTLAND SEATTLE SEATTLE SEATTLE PORTLAND) . 0.64102566)
  ((SEATTLE SEATTLE SEATTLE SPOKANE PORTLAND) . 0.84745765)
  ((PORTLAND SEATTLE SEATTLE SEATTLE SPOKANE) . 0.84745765)
  ((SEATTLE SEATTLE SEATTLE SEATTLE PORTLAND) . 0.64102566)
  ((SEATTLE SEATTLE SEATTLE WENATCHEE SEATTLE) . 0.64935064)
  ((SEATTLE SEATTLE SPOKANE PORTLAND SPOKANE) . 0.7692308)
  ((SEATTLE SEATTLE SEATTLE PORTLAND SPOKANE) . 0.84745765)
  ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
  ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
  ((SEATTLE SEATTLE SEATTLE SEATTLE SPOKANE) . 0.6097561)
  ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0) )

 The above list represents the state after 1 generation (10 mutations).
 At this point there has been 1 "starter" individual:
   ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0)
 and 10 mutated individuals added "on top" of this first individual.  

8. After 2 generations, there have been 10 more mutations done on
   randomly selected individuals.  Since there can be no more than 15 
   individuals in a population, the individual with the lowest
   chromosone strength is removed and replaced with the new
   mutation (assuming the mutation has a higher strength).  The
   population evolves towards highest strength ranking.
   Here's the population after 2 generations:

(((BELLINGHAM PORTLAND SEATTLE SEATTLE SPOKANE) . 1.3812155)
  ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
  ((SEATTLE SEATTLE WENATCHEE SEATTLE SPOKANE) . 0.84745765)
  ((PORTLAND SEATTLE SEATTLE PORTLAND SPOKANE) . 0.8196721)
  ((PORTLAND SEATTLE SEATTLE SPOKANE SPOKANE) . 0.84745765)
  ((SEATTLE PORTLAND SEATTLE WENATCHEE SEATTLE) . 0.90909094)
  ((BELLINGHAM SEATTLE SEATTLE SEATTLE PORTLAND) . 0.913242)
  ((SEATTLE SEATTLE SEATTLE SPOKANE PORTLAND) . 0.84745765)
  ((PORTLAND SEATTLE SEATTLE SEATTLE SPOKANE) . 0.84745765)
  ((SEATTLE SEATTLE SEATTLE SEATTLE PORTLAND) . 0.64102566)
  ((SEATTLE SEATTLE SEATTLE WENATCHEE SEATTLE) . 0.64935064)
  ((SEATTLE SEATTLE SPOKANE PORTLAND SPOKANE) . 0.7692308)
  ((SEATTLE SEATTLE SEATTLE PORTLAND SPOKANE) . 0.84745765)
  ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
  ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691) )

9. After 3 generations, and another 10 mutations:

In generation 3, population is: 
(((PORTLAND SEATTLE SEATTLE WENATCHEE SPOKANE) . 1.459854)
  ((PORTLAND PORTLAND SEATTLE WENATCHEE SPOKANE) . 1.459854)
  ((SEATTLE SEATTLE WENATCHEE WENATCHEE SPOKANE) . 0.8733624)
  ((SEATTLE SEATTLE WENATCHEE SPOKANE SPOKANE) . 0.8733624)
  ((WENATCHEE SEATTLE SPOKANE PORTLAND SPOKANE) . 1.242236)
  ((PORTLAND SEATTLE SEATTLE WENATCHEE SPOKANE) . 1.459854)
  ((BELLINGHAM PORTLAND SEATTLE SEATTLE SPOKANE) . 1.3812155)
  ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
  ((SEATTLE PORTLAND SEATTLE WENATCHEE SEATTLE) . 0.90909094)
  ((BELLINGHAM SEATTLE SEATTLE SEATTLE PORTLAND) . 0.913242)
  ((SEATTLE SEATTLE SEATTLE SPOKANE PORTLAND) . 0.84745765)
  ((PORTLAND SEATTLE SEATTLE SEATTLE SPOKANE) . 0.84745765)
  ((SEATTLE SEATTLE SEATTLE PORTLAND SPOKANE) . 0.84745765)
  ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691)
  ((BELLINGHAM SEATTLE SEATTLE SEATTLE SPOKANE) . 0.8583691) )

10. After 5 generations, the population is:
(((BELLINGHAM SEATTLE SEATTLE WENATCHEE SPOKANE) . 1.4925373)
  ((PORTLAND SEATTLE WENATCHEE WENATCHEE SPOKANE) . 1.459854)
  ((WENATCHEE SEATTLE SPOKANE SEATTLE PORTLAND) . 1.369863)
  ((BELLINGHAM SEATTLE SEATTLE PORTLAND SPOKANE) . 1.4184397)
  ((SPOKANE SEATTLE SEATTLE WENATCHEE BELLINGHAM) . 1.4430014)
  ((PORTLAND SPOKANE SEATTLE BELLINGHAM BELLINGHAM) . 1.3986014)
  ((WENATCHEE SEATTLE SPOKANE PORTLAND PORTLAND) . 1.4084507)
  ((PORTLAND SEATTLE SEATTLE WENATCHEE BELLINGHAM) . 1.6051364)
  ((PORTLAND SEATTLE SPOKANE WENATCHEE SPOKANE) . 1.2658228)
  ((PORTLAND SEATTLE SEATTLE WENATCHEE BELLINGHAM) . 1.6051364)
  ((WENATCHEE SEATTLE SEATTLE PORTLAND SPOKANE) . 1.459854)
  ((PORTLAND SEATTLE SEATTLE WENATCHEE SPOKANE) . 1.459854)
  ((PORTLAND PORTLAND SEATTLE WENATCHEE SPOKANE) . 1.459854)
  ((PORTLAND SEATTLE SEATTLE WENATCHEE SPOKANE) . 1.459854)
  ((BELLINGHAM PORTLAND SEATTLE SEATTLE SPOKANE) . 1.3812155)
)

11. After 10 generations, the population contains individuals
    that may be maximum strength:

( ((SEATTLE SPOKANE WENATCHEE PORTLAND BELLINGHAM) . 4.3478261) 
  ((SEATTLE SPOKANE WENATCHEE PORTLAND BELLINGHAM) . 4.3478261) 
  ((WENATCHEE BELLINGHAM SEATTLE PORTLAND SPOKANE) . 4.7846890) 
  ((SEATTLE SEATTLE WENATCHEE PORTLAND BELLINGHAM) . 1.6) 
  ((SEATTLE SEATTLE WENATCHEE PORTLAND BELLINGHAM) . 1.6) 
  ((BELLINGHAM BELLINGHAM SEATTLE WENATCHEE PORTLAND) . 1.6) 
  ((SEATTLE SEATTLE WENATCHEE PORTLAND BELLINGHAM) . 1.6) 
  ((SPOKANE SEATTLE WENATCHEE PORTLAND BELLINGHAM) . 3.9370079) 
  ((WENATCHEE WENATCHEE SEATTLE PORTLAND BELLINGHAM) . 1.6051364) 
  ((SEATTLE SEATTLE WENATCHEE PORTLAND BELLINGHAM) . 1.6) 
  ((SEATTLE WENATCHEE SPOKANE PORTLAND BELLINGHAM) . 4.5454545) 
  ((SEATTLE WENATCHEE WENATCHEE PORTLAND BELLINGHAM) . 1.6) 
  ((SEATTLE BELLINGHAM PORTLAND WENATCHEE SPOKANE) . 4.3478261) 
  ((SEATTLE WENATCHEE WENATCHEE PORTLAND BELLINGHAM) . 1.6) 
  ((WENATCHEE BELLINGHAM SEATTLE PORTLAND SPOKANE) . 4.7846890))

12.  The program is run again using 20 generations.  Here is the 
   generation 20.  Note that on the previous run, a higher strength
   individual was found after only 10 generations.  Though on the 
   20th generation the average strength of all the individuals is
   higher:

( ((SEATTLE WENATCHEE SPOKANE PORTLAND BELLINGHAM) . 4.5454545) 
  ((PORTLAND SEATTLE SPOKANE WENATCHEE BELLINGHAM) . 4.3859649) 
  ((SPOKANE WENATCHEE BELLINGHAM PORTLAND SEATTLE) . 4.3859649) 
  ((SPOKANE WENATCHEE BELLINGHAM PORTLAND SEATTLE) . 4.3859649) 
  ((PORTLAND SEATTLE SPOKANE WENATCHEE BELLINGHAM) . 4.38596491) 
  ((PORTLAND SEATTLE SPOKANE WENATCHEE BELLINGHAM) . 4.38596491) 
  ((SEATTLE WENATCHEE SPOKANE PORTLAND BELLINGHAM) . 4.54545454) 
  ((PORTLAND SEATTLE SPOKANE WENATCHEE BELLINGHAM) . 4.38596491) 
  ((SPOKANE WENATCHEE BELLINGHAM PORTLAND SEATTLE) . 4.38596491) 
  ((SPOKANE WENATCHEE BELLINGHAM PORTLAND SEATTLE) . 4.38596491) 
  ((SPOKANE WENATCHEE BELLINGHAM PORTLAND SEATTLE) . 4.38596491) 
  ((SPOKANE WENATCHEE BELLINGHAM PORTLAND SEATTLE) . 4.38596491) 
  ((PORTLAND SEATTLE SPOKANE WENATCHEE BELLINGHAM) . 4.38596491) 
  ((SEATTLE WENATCHEE SPOKANE PORTLAND BELLINGHAM) . 4.54545454) 
  ((PORTLAND SEATTLE SPOKANE WENATCHEE BELLINGHAM) . 4.38596491))

13. Introducing a second form of mutation helps to vary each population
    a little more.  The second type of mutation is
       - select a random individual from the population
       - select two random cities and their locations in the 
         individual
       - swap the two cities within the individual
    
    When a mutation is done, the program randomly picks between
    mutation 1 and mutation 2.

( ((WENATCHEE BELLINGHAM WENATCHEE PORTLAND SEATTLE) . 1.5576324) 
  ((BELLINGHAM WENATCHEE WENATCHEE PORTLAND SEATTLE) . 1.6286645) 
  ((WENATCHEE BELLINGHAM WENATCHEE PORTLAND SEATTLE) . 1.5576324) 
  ((PORTLAND WENATCHEE BELLINGHAM SEATTLE SEATTLE) . 1.6286645) 
  ((SEATTLE BELLINGHAM WENATCHEE PORTLAND SEATTLE) . 1.6286645) 
  ((PORTLAND SEATTLE PORTLAND WENATCHEE BELLINGHAM) . 1.4858841) 
  ((PORTLAND SEATTLE SEATTLE WENATCHEE BELLINGHAM) . 1.6051364) 
  ((PORTLAND BELLINGHAM SEATTLE WENATCHEE SPOKANE) . 4.5454545) 
  ((PORTLAND BELLINGHAM WENATCHEE SEATTLE SEATTLE) . 1.6051364) 
  ((PORTLAND SEATTLE SEATTLE WENATCHEE SPOKANE) . 1.4598540) 
  ((PORTLAND SEATTLE SEATTLE WENATCHEE SPOKANE) . 1.4598540) 
  ((WENATCHEE SEATTLE SEATTLE PORTLAND SPOKANE) . 1.45985401) 
  ((PORTLAND SEATTLE SEATTLE WENATCHEE SPOKANE) . 1.45985401) 
  ((PORTLAND SEATTLE SEATTLE WENATCHEE BELLINGHAM) . 1.6051364) 
  ((PORTLAND SEATTLE SEATTLE WENATCHEE SPOKANE) . 1.4598540))

 The average strength may be higher.

14. Here's 20 generations using this mix of mutation schemes:

( ((SPOKANE WENATCHEE BELLINGHAM SEATTLE PORTLAND) . 4.7846870) 
  ((BELLINGHAM SPOKANE WENATCHEE SEATTLE PORTLAND) . 4.3668122) 
  ((WENATCHEE BELLINGHAM PORTLAND SEATTLE SPOKANE) . 4.3859649) 
  ((WENATCHEE SPOKANE SEATTLE PORTLAND BELLINGHAM) . 4.3859649) 
  ((SPOKANE BELLINGHAM PORTLAND SEATTLE WENATCHEE) . 4.3668122) 
  ((WENATCHEE SEATTLE BELLINGHAM PORTLAND SPOKANE) . 4.5454545) 
  ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((SEATTLE WENATCHEE SPOKANE PORTLAND BELLINGHAM) . 4.5454545) 
  ((PORTLAND BELLINGHAM SPOKANE WENATCHEE SEATTLE) . 4.3668122) 
  ((SPOKANE BELLINGHAM PORTLAND SEATTLE WENATCHEE) . 4.3668122) 
  ((WENATCHEE PORTLAND SEATTLE BELLINGHAM SPOKANE) . 4.5454545) 
  ((SPOKANE BELLINGHAM SEATTLE PORTLAND WENATCHEE) . 4.5454545) 
  ((WENATCHEE BELLINGHAM SEATTLE PORTLAND SPOKANE) . 4.7846890) 
  ((BELLINGHAM SPOKANE WENATCHEE SEATTLE PORTLAND) . 4.3668122) 
  ((WENATCHEE SPOKANE BELLINGHAM SEATTLE PORTLAND) . 4.5454545))

15.  Now introduce a crossover in addition to a mutation for
   each generation.  Crossover works as follows:

      - select two random individuals from the population
      - select a random location within individual 1
      - "crossover" individual 1 and individual 2 at the 
        above random location.
      - "crossover" means append the left part of individual 1,
        up to but not including the location, to the right part
        of individual 2, from the location to the end.
     
  (test 10 10 10)  

( ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((SEATTLE PORTLAND BELLINGHAM WENATCHEE SPOKANE) . 4.3859649) 
  ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((SEATTLE PORTLAND BELLINGHAM WENATCHEE SPOKANE) . 4.3859649) 
  ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((SEATTLE PORTLAND BELLINGHAM WENATCHEE SPOKANE) . 4.3859649) 
  ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((SEATTLE PORTLAND SPOKANE WENATCHEE BELLINGHAM) . 4.7846890) 
  ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((SEATTLE BELLINGHAM SPOKANE WENATCHEE PORTLAND) . 4.5454545) 
  ((BELLINGHAM PORTLAND SEATTLE WENATCHEE SPOKANE) . 4.3668122))

16. Here are some detailed examples of crossover and mutation.

   (test 10 10 5)   This is running 10 generations, with 10 mutations
                    and 5 crossovers per generation.
                    The mutations are done first, followed by the
                    crossovers.

After the first 10 mutations, the population is:
( ((SEATTLE SEATTLE SEATTLE SEATTLE BELLINGHAM) . 0.6510417) 
  ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.5) 
  ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.5) 
  ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.5) 
  ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.5) 
  ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.5) 
  ((WENATCHEE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.6493506) 
  ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.5) 
  ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.5) 
  ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.5) 
  ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0))

Because the population is not varied at this point, the crossovers
will not have much effect.

Crossover 1:
Individual 1:((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0)
Individual 2:((WENATCHEE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.6493506)
Where:5
New individual: ((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0)

Crossover 2:
Individual 1:((WENATCHEE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.6493506)
Individual 2:((SEATTLE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.5)
Where:5  (using index starting on 1 - the program starts on 0)
New Individual:((WENATCHEE SEATTLE SEATTLE SEATTLE SEATTLE) . 0.6493506)

etc.

After the 4th generation:

Crossover 1:
Individual 1:((SEATTLE WENATCHEE SEATTLE SEATTLE BELLINGHAM) . 0.9293680)
Individual 2:((SEATTLE SEATTLE SEATTLE WENATCHEE BELLINGHAM) . 0.9398496)
Where:2
Individual:((SEATTLE SEATTLE SEATTLE WENATCHEE BELLINGHAM) . 0.9398496)
   
Crossover 2:
Individual 1:((SEATTLE WENATCHEE BELLINGHAM SEATTLE SEATTLE) . 0.9398496)
Individual 2:((SEATTLE SEATTLE SEATTLE WENATCHEE BELLINGHAM) . 0.9398496)
Where:4
Individual:((SEATTLE WENATCHEE BELLINGHAM WENATCHEE BELLINGHAM) . 0.8960573)

Crossover 3:
Individual 1:((SEATTLE WENATCHEE BELLINGHAM WENATCHEE BELLINGHAM) . 0.8960573)
Individual 2:((WENATCHEE SEATTLE SEATTLE SPOKANE BELLINGHAM) . 1.4430014)
Where:2
Individual:((SEATTLE SEATTLE SEATTLE SPOKANE BELLINGHAM) . 0.8583691)

You can see that crossovers don't necessarily improve the individual.
The point is to add just the right amount of variation per generation.