Evolution as algorithm

by Marcus Loane


Evolution can be regarded as an algorithm, that is, a set of steps like the rules for long division, which if implemented, guarantee an outcome. An algorithm works regardless of the medium it is implemented in. The rules for long division can be implemented by a person using pencil and paper or by a computer. The rules themselves have no intelligence yet they perform a task which appears intelligent. Evolution also works regardless of the medium. Evolution does not mean change, it means change due to a particular algorithmic process. Here is how it works:

IF you have something that makes copies of itself and sometimes the copies are not quite exact copies
THEN evolutionary change results.

That is a simplification of the more accurate description: replication with variation plus selection. Yet another way of stating it is differential survival of imperfect replicators. Say we have an object. It could be a molecule, but it could be anything at all that can make copies of itself. There are molecules that are observed doing this. However they know not what they do - it is just a result of the laws of physics and chemistry that some molecules replicate in certain environments. This object will copy itself and soon the whole world will be full of these objects since the copies make more copies and so on. This does not happen in practice because the material to make the copies is limited. Resources are finite. Now if some of the copies have random changes from the original (the laws of physics mean that is inevitable), some of them will be better (faster/more accurate) at making copies than the original. Soon there will be more of the changed version than the original. This is an on going process and every "generation" there is the potential for change due to the "competition" between imperfect copies. Once it starts it is practically unstoppable! It leads to change, change and more change. Think about it and you will see it is inevitable.

Say an object makes 1000 copies of itself and 100 of those are slightly imperfect copies. 99 of them are worse at copying themselves. There is one copy that is better at making copies than the original "parent". It will be the one that dominates in the succeeding "generations" in the competition for copy-making materials. The better-copier makes "children" that are themselves better-copiers. That is natural selection - it weeds out the worse and keeps the better (even if the better is out numbered), like a kind of filter. Each generation ratchets up a notch, tending to keep what works and discarding what doesn't.

Biological evolution started with simple molecules. It eventually evolved into the more complex DNA molecule.

Organisms also fit the description of objects which replicate with variation, with selection being exerted by the environment. The DNA molecule builds bodies through embryology. The bodies produce offspring containing more DNA. Random changes to DNA (mutations mostly) exert random changes on the bodies they build. Some bodies will be better at surviving and reproducing and some (most) will be worse. The better ones are more likely to have children and their particular DNA is inherited and becomes more common in the next generation. That is a formula for constant change in the bodies that DNA builds.

Gazelles and lions

Selection is exerted by the environment and the environment includes other organisms (prey and predators). Say we have a population of gazelles. Given enough time, random changes to gazelle DNA should lead to some DNA building gazelles that are slower and some that are faster. The slower ones will tend to be caught by lions so the slow-DNA (eg. DNA for shorter legs) ends up as lion dinner. The faster gazelles avoid being caught by lions and survive to produce offspring which inherit their fast-DNA. Down the generations the gazelles will get ever faster and better at avoiding lions. However at the same time the lions that are better at catching gazelles are less likely to starve so the gazelle-catching-DNA (eg.DNA for bigger muscles or keener eyesight) gets passed down the lion generations. There is a kind of evolutionary arms race between gazelles and lions with both sides becoming ever more efficient at the art of surviving. Note: A limit will be reached. If a gazelle's legs become too long they will be prone to injury so there is a trade off between advantages and disadvantages.

Natural selection

Natural Selection is such a common expression that I have included a short section on it. It is usually only used when discussing biological evolution (there are other types). Natural selection is the term used to describe the fact that some organisms die without reproducing, and the implications of this. Natural selection is an observed fact. In addition, an irrefutable argument can be put together which shows why natural selection is a component of evolutionary change. It goes as follows:

A] Organisms inherit traits from their parent(s) but sometimes are not exact copies of them (variation). That is an easy observation for anyone to make.

B] If organisms often produce more than one child per parent (and they do) then a population of organisms will keep increasing.

C] It is impossible for a population to keep increasing forever because eventually there will not be enough room or food to keep them all alive.

D] It follows that a time will be reached when some will survive to reproduce and some will die without reproducing. That is an inevitable consequence of B] and C].

E] Due to A], any variation that an organism just happens to have that gives it an advantage over its peers, will make it more likely to survive and pass on that variation as an inherited trait to its offspring. This is easier to understand by using examples. I have already given an example of the faster gazelles being more likely to live than their slower peers.
This leads to changes in the characteristics of organisms down the generations.
The advantageous variations get "selected" and inherited by the offspring, and the less advantageous variations tend to end up dead before reproducing. This only has to happen on average, not in every case - a tiny advantage can eventually sweep through the population after many generations and this has been confirmed by experiments and also by computer simulations.

Now A] B] and C] are all true and cannot be disputed so D] and E] which follow from them are also true. Darwin formed a similar argument in Origin Of The Species before heredity was even understood. The later discovery of DNA showed how characteristics are inherited and also how random variation gets introduced by various mechanisms.

Natural selection is inevitable given the premises A], B] and C] above.
Although not part of the argument it is worth pointing out that natural selection has been observed in the lab and in the wild, and the mechanisms of heredity are now understood.

Now just to reiterate, the conclusion is that:

There are changes in the characteristics of organisms down the generations and the changes are on average, advantageous at the time they were selected. It cannot be any other way.

Even without the physical evidence (and there is a lot of it) that conclusion means evolutionary change due to natural selection is inevitable.

The tone of this section on natural selection might have surprised some readers who think I have just stated the obvious, but it is for the benefit of the anti-evolution lobby who do still exist. I would hope that they understand the logic. It is difficult for me to choose how detailed to make the argument. If I keep it brief it is clearer but then some readers think they can spot flaws in it. To avoid the latter I need to include qualifications but then some readers get lost in the detail and miss the main thrust. Perhaps I should write two versions or use footnotes.


Human DNA builds a human baby in 9 months. That is a marvelous thing but it is not a miracle. Every atom, every molecule in the developing foetus is blindly obeying the laws of physics the same as they would anywhere else in the universe. Building a baby is a purely mechanical process at the molecular level. The DNA builds a human, and the human usually produces children containing more DNA. The human is a 20-30 year diversion in the process of replicating a piece of DNA. That may sound devaluing and bleak but it is the truth. We do not get to choose the truth based on its attractiveness to us. Personally, I think we can take comfort from the fact that each of us is a unique combination of DNA + life experiences. Also the mechanism which created us should not be the deciding factor on whether we feel we can have meaningful lives.

The road from simple self replicating molecule to human is tortuous; 4 billion years long and depends on such a vast number of factors (including for example, random asteroid impacts). If the process were started over again the chance of it resulting in humans plus the other millions of current species, is close to zero. If the process were started over again it could result in millions of species but they would be different species from what we observe today. Humans are just one out of a truly VAST number of possible outcomes. DNA is so versatile that it can code for trillions of trillions of....(say that a lot of times) different species, intelligent or otherwise.

Someone wins the lottery every week
yet the probability of a particular person,
specified in advance, winning it is 1 in 14 million.

Compare with the lottery:
Marcus Loane winning the lottery is unlikely, but somebody winning the lottery is likely. If you are that somebody you think it is a miracle even though it is not.
If specified in advance, humans evolving is unlikely, but something complex evolving is likely. If you are that something you think it is a miracle even though it is not.

Humans are just one out of many trillions of trillions of trillions of possible outcomes. Evolution has no foresight or no future goal. It is not some ladder whose ultimate aim was to produce us.

We should not imagine that evolution has stopped or that we are somehow the pinnacle. 99% of species that have ever lived have gone extinct. If we go on destroying the environment we could easily join them. Then there are the very real threats of asteroid impacts or new deadly diseases. It is only by boldy confronting these possibilities that we have a chance of preventing them.

Body morphing and overcoming intuition

Some people have difficulty accepting that one species can change into another. This can be overcome by realising that species are not well defined. There are no hard boundaries between them. There are many "species" that are so similar we have trouble saying if they are separate or not. This is exactly what we would expect if species form by subsets of a population gradually becoming more genetically different. This is illustrated beautifully by so called ring species. The Greenish Warbler lives in a ring shaped area around the Himalayas. If you work your way around the ring you find greenish warblers that are gradually different from their neighbours. By the time you have gone right around the ring the birds are quite different from the ones you started with and they do not interbreed at the join. At that location they are two different species yet there is a continous gradual range from one species to the other if we go around the ring the long way (and they interbreed the long way round). The same phenomena is observed in gulls living around the Arctic circle. There is a continous range of them interbreeding the "long way" around the ring. At the join they are sufficiently different to be described as Herring Gulls and Lesser Black Backed Gulls and they do not interbreed at the join.

When species have changed a lot then it becomes obvious that they are different like chimpanzees and humans, but there is no magic moment when it happens, only gradual genetic divergence.

If you have trouble thinking that a body can morph from one shape to another, there are examples in biology. Now bodies changing shape within one lifetime is not the same as evolution but thinking about it can help overcome the intuitive block that many possess. A single cell turns into a human baby in 9 months. Try and visualise that. Even in that short time, viewing the developing embryo is too slow for us to observe the changes in real time. Evolution had longer than 9 months. It had 4 billion years. While on the topic of human embryology, at one stage the embryo possesses fish gills, a slightly disconcerting remnant from our evolutionary past.

Say we had a tiny mouse like mammal which on average increased in size by 0.1% per generation. This is such a tiny increase (1/1000) that it would not be noticeable. However if it were repeated for 5000 generations (a geological instant) the end result would be something larger than an elephant. Our intuitions are usually wildy off the mark when dealing with very long time periods and this may be another reason that some have trouble accepting evolutionary theory.

A good example of changing shape and size down the generations is man's best friend. From a wolf ancestor we have the huge Irish Wolfhound and also the tiny Chihuahua. Now these are still both labelled "dog" by us but that is just our arbitrary convention. Irish Wolfhounds and Chihuahuas would not interbreed - it may not even be physically possible (if fertilisation did manage to occur, the huge embryo could kill the Chihuahua). They were produced in a few thousand years from a common ancestor. With billions of years available, much greater changes are possible.

Evolution in action

Evolution is observed every time bacteria mutates into a new strain that is resistant to antibiotics. This is a very real problem for the future. Bring out new drugs and new strains evolve with resistance to them - they are the "fittest" in an antibiotic environment.

A much faster execution of the evolutionary algorithm is used in our immune responses. This evolution occurs inside one organism and within the lifetime of the organism. Do not confuse this with evolution between organisms over many generations. The lymphocytes (white blood cells) evolve in days to produce the most suitable antibodies to fight invading pathogens. It is the reason why vaccines can work. I do not use the word "evolve" here, loosely to just mean change. It means replication, variation and selection within the immune system - it is a well studied mechanism and evidence of the power of the evolutionary algorithm to create novelty that matches some aspect of the environment (in this case - invading pathogens).

Evidence for evolution and common descent

There are thousands of pieces of evidence for evolution. They come from a wide range of subject areas: fossils, morphology, biochemistry, genetics, ethology, geology and geographical distribution of species. Never have so many disparate facts been explained by one simple principle. A document, not authored by me, summarising some of the evidence for the common descent (all life coming from one ancestor) aspect of evolution is here.

Universal evolution

Because evolution is an algorithm, it will work regardless of the medium it is implemented in. It does not need DNA. It has been shown to produce artefacts that appear designed, in computer simulations and in practical computer applications (more on that below).

The algorithm using replication, variation and selection is at work in more than one arena. It is responsible for producing the diversity of life. I have also mentioned it is at work in a very speeded up form (days) in our immune systems. Culture is also the product of replication of ideas with variation and selection by human brains - see my article on imitation and memetic evolution. Language is subject to the evolutionary algorithm as well - it is a subset of memetic evolution. Words are replicated , they vary and some are preferred over others (selection). Languages around the world can be arranged into hierarchies of heredity.

There are parallels between the evolutionary algorithm and learning (for example a baby learning to walk). Both use a trial and error approach. Random variations (of muscle contractions in the case of the baby) are tried and what fails is discarded and what works is retained. Further progress is then built on variations of what has been retained.

It has been suggested that even thought production is the result of an evolutionary process that takes place in seconds or milliseconds inside our own skulls. It goes as follows. The brain, randomly and unconsciously generates multiple fragments of thoughts (patterns of neural activation). These fragments then replicate, mutate, combine and "compete", repeatedly. By "compete" I mean provide the best match to current sense data using previous matches stored in memory. After several rounds the winner (the "fittest") will be the one that makes the best match with current sense data, and gets to be consciously experienced as a thought. There have been some clever experiments that are consistent with the hypothesis. It is postulated that during dreaming the matching with sense data cannot occur, so disjointed fantasy is generated. Conscious thought is not what an other worldly Self creates, but rather what is left over after the more nonsensical drafts have been eliminated. It is generated by a trial and error process but one that is invisible to introspection. It is a Darwinian process of randomness plus selection over many rounds, generating more and more complexity. Philosopher Daniel Dennett calls this model "multiple drafts" and neurophysiologist William H Calvin calls it "scenario spinning". If you are interested, there is a book expounding on this hypothesis, by William Calvin, freely available to read online. Gary Cziko's "Without Miracles" also explains the brain in terms of competing neural processes.

There is a picture emerging here. Much of what we value is the product of a blind algorithm. It is the algorithm that produces complexity from simplicity. In fact the only reason we have value, meaning and mattering is because of evolutionary algorithms to build us, to generate our thoughts and to culturally condition us.

Practical use of the evolutionary algorithm

Knowledge of the evolutionary algorithm has been valuable in understanding how infectious diseases evolve resistance to drugs. It has also been useful in studying how pests evolve resistance to pesticides. It is useful for understanding how our immune systems work. Therefore it has practical benefits in medicine, agriculture and environmental studies. It has become increasingly important in sociology. It is useful for studying the evolution of language and religious and political movements in history.

The evolutionary algorithm has had practical uses outside of biology showing that it works in different media. The principles are being used in computer science and engineering. Here is a simplified example to illustrate the concept. Suppose we need a computer program to solve a particular problem but it is not known how to do it. We can write a program which does not work satisfactorily to solve the problem. We then make 1000 copies (replication) of that program with one random change to each copy (variation). Each of the 1000 copies is run and we pick the one which is nearest to solving the problem (selection). It only has to very slightly nearer to solving the problem - if there is no obvious favourite, one can be picked at random. We then "breed" 1000 copies from that one and so on. The whole process could be automated over many "generations". What can result is a program which solves the problem even though noone understands how it works! All we have done to achieve this is replication with random variation plus selection. It is interesting to note that this approach works best with programs that attempt to mimic biological functions such as facial recognition or software for autonomous robots capable of learning from experience.

The evolutionary algorithm is smarter than us. We should not be too surprised. It built us.

Marcus Loane

News report on use of evolutionary algorithms in robotics.