### How do we route Santa?

Some things seem very simple, supposing I ask you to visit 10 friends in the shortest possible distance.

This is quite an easy problem for us to solve simply by looking at a map. But in how many different orders can you arrange the 10 visits?

The number of possible ways in which we can visit our 10 friends is calculated as ...
= (10x9x8x7x5x4x3x2x1)/2*10.

So there are 181,440 different orders we can visit our friends in!

For a simple problem such as visiting 10 friends we can easily solve the problem by looking at a map and using some common sense.

Q: What if Santa has to visit 50 houses?...

A: There would be 3041409320171337804361260816606476884437764156896051200000000000
possible routes that he can take....! If we have to visit more than a few houses it becomes impossible to check all of the possible routes, even using a computer would take a very long time.

Q: How can we solve a complex problem like this quickly?...

A: We can solve this problem using a simple computer program known as an
*Evolutionary Algorithm*.

It works like this..

OurEvolutionary Algorithm is written in a programming language called Java, it's running on a computer at Edinburgh Napier University. If you refresh this page it will show the latest state of the algorithm.

### Step 1.

The Evolutionary Algorithm has a group of posible sleigh trips, this group is known as the population. When the algorithm starts, each member of the population has the deliveries in a random order, but we can still calculate the length of each tour.

# Click here to see the lengths of the tours in the latest population

55964.10

55964.10

55964.10

55964.10

55964.10

55965.19

55964.10

192372.62

55964.10

57310.31

55964.10

55964.10

55964.10

55964.10

196765.78

55964.10

55964.10

55964.10

55964.10

56005.16

55964.10

55964.52

55967.87

55964.10

55965.61

55964.10

55964.10

55964.10

55964.10

55964.10

55966.02

55969.98

55964.10

55964.10

55986.22

55964.10

55964.10

55964.10

55964.10

55964.51

55964.10

55970.28

55966.51

55964.10

55966.51

55964.10

55964.10

55964.10

197330.61

62561.46

55964.52

55964.10

55964.94

55964.52

55964.10

55964.10

55966.51

55964.10

56176.36

55964.10

220074.41

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55968.69

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

201661.70

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.52

55964.57

55964.10

55964.10

55964.10

55964.10

55964.10

55964.57

55964.10

55964.51

55964.10

55964.10

55964.10

55965.19

Sometimes all of the tours will have the same length, this happens when a short tour has been found, but will change when new houses are added.

Step 2.

We need to create some new shorter sleigh rides. We select some of the shortest sleigh rides in our population andthey become the parents of our next generation of sleigh rides. To create a child sleigh ride we copy either a whole tour from one parent, or make a new tour by adding togther the tour from two parents. We then make a random change (swap around some of the deliveries in the child (this is known as a mutation)

# Click here to see the new children and their parents

Child, 63183.06 Parent p1,55964.10 Mutation Simple Mutate

Child, 56247.75 Parent p1,55964.10 Mutation adj Swap Mutate

Child, 57554.22 Parent p1,55964.10 Mutation Simple Mutate

Child, 68513.14 Parent p1,55964.10 Mutation Swap Mutate

Child, 56033.88 Parent p1,55964.10 Mutation NN Simple Mutate

Child, 71005.44 Parent p1,55964.10 Mutation Simple Mutate

Child, 56428.07 Parent p1,55964.10 Mutation adj Swap Mutate

Child, 63986.88 Parent p1,55964.10 Mutation Simple Mutate

Child, 55987.39 Parent p1,55964.10 Mutation Simple Mutate

Child, 57269.89 Parent p1,55964.10 Mutation Swap Mutate

Child, 68513.14 Parent p1,55964.10 Mutation Swap Mutate

Child, 55964.10 Parent p1,55964.10 Mutation Simple Mutate

Child, 65480.99 Parent p1,55964.10 Mutation Simple Mutate

Child, 57630.75 Parent p1,55964.10 Mutation Simple Mutate

Child, 58693.37 Parent p1,55964.10 Mutation Swap Mutate

Child, 57327.59 Parent p1,55964.10 Mutation Simple Mutate

Child, 56033.88 Parent p1,55964.10 Mutation NN Simple Mutate

Child, 65475.91 Parent p1,55964.10 Mutation Simple Mutate

Child, 55970.46Parents ,p1,55964.10,p2,55964.10 Mutation Swap Mutate

Child, 56227.81Parents ,p1,55964.10,p2,55964.10 Mutation NN Simple Mutate

Child, 56230.80 Parent p1,55964.10 Mutation Simple Mutate

Child, 55964.57 Parent p1,55964.10 Mutation NN Simple Mutate

Child, 59155.85 Parent p1,55964.10 Mutation Swap Mutate

Child, 55964.10 Parent p1,55964.10 Mutation NN Simple Mutate

Child, 68624.35 Parent p1,55964.10 Mutation Swap Mutate

Child, 56240.86 Parent p1,55964.10 Mutation 2 opt Mutate

Child, 71295.72 Parent p1,55964.10 Mutation 2 opt Mutate

Child, 72256.15 Parent p1,55964.10 Mutation Simple Mutate

Child, 73937.74 Parent p1,55964.10 Mutation Swap Mutate

Child, 55964.52 Parent p1,55964.10 Mutation adj Swap Mutate

Child, 64997.93 Parent p1,55964.10 Mutation Simple Mutate

Child, 63310.80 Parent p1,55964.10 Mutation Simple Mutate

Child, 55964.10 Parent p1,55964.10 Mutation NN Simple Mutate

Child, 55964.99 Parent p1,55964.52 Mutation NN Simple Mutate

Child, 59233.68 Parent p1,55964.10 Mutation Simple Mutate

Child, 57074.14 Parent p1,55964.10 Mutation Simple Mutate

Child, 68374.68 Parent p1,55964.52 Mutation Swap Mutate

Child, 68201.32 Parent p1,55964.10 Mutation Swap Mutate

Child, 59039.19 Parent p1,55964.57 Mutation Swap Mutate

Child, 63268.21 Parent p1,55986.22 Mutation Simple Mutate

Child, 61987.16Parents ,p1,55964.10,p2,55964.10 Mutation 2 opt Mutate

Child, 63917.89 Parent p1,55964.10 Mutation Swap Mutate

Child, 73465.34 Parent p1,55964.10 Mutation Swap Mutate

Child, 55987.39 Parent p1,55964.10 Mutation adj Swap Mutate

Child, 55967.87 Parent p1,55964.10 Mutation 2 opt Mutate

Child, 56251.20 Parent p1,55964.10 Mutation adj Swap Mutate

Child, 56510.82 Parent p1,55964.10 Mutation 2 opt Mutate

Child, 56230.80Parents ,p1,55964.10,p2,55964.10 Mutation Simple Mutate

Child, 55970.48Parents ,p1,55964.10,p2,55964.10 Mutation adj Swap Mutate

Child, 63419.56Parents ,p1,55964.10,p2,55964.10 Mutation Swap Mutate

### Step 3.

We would like to add some our new children into our population, to replace the longer tours. For each child we select a random member of the population, if the ride length of the population is longer, then the child replaces that member.

# Click here to see the replacement

Child 63183.06 Replaces 201661.70

Child 57269.89 Replaces 63183.06

Child 57327.59 Replaces 196765.78

Child 56033.88 Replaces 62561.46

Child 55964.57 Replaces 55965.61

Child 68624.35 Replaces 220074.41

Child 55964.52 Replaces 55967.87

Child 55964.10 Replaces 57310.31

Child 55967.87 Replaces 56005.16

Child 56230.80 Replaces 57269.89

### Step 4.

We have now added the children into the population

# Click here to see the improved population

55964.10

55964.10

55964.10

55964.10

55964.10

55965.19

55964.10

192372.62

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

57327.59

55964.10

55964.10

55964.10

55964.10

55967.87

55964.10

55964.52

55964.52

55964.10

55964.57

55964.10

55964.10

55964.10

55964.10

55964.10

55966.02

55969.98

55964.10

55964.10

55986.22

55964.10

55964.10

55964.10

55964.10

55964.51

55964.10

55970.28

55966.51

55964.10

55966.51

55964.10

55964.10

55964.10

197330.61

56033.88

55964.52

55964.10

55964.94

55964.52

55964.10

55964.10

55966.51

55964.10

56176.36

55964.10

68624.35

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55968.69

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

56230.80

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.10

55964.52

55964.57

55964.10

55964.10

55964.10

55964.10

55964.10

55964.57

55964.10

55964.51

55964.10

55964.10

55964.10

55965.19

### Check to see if any new deliveries have been added and then go back to step 2