Genetic Algorithms

One of the things I hear frequently raised in debate by creationist apologists is the 'fact' that complexity cannot arise from simple building blocks. This is, of course, nonsense and there are many ways to show complexity emerging from very simple systems. One such example is the use of genetic algorithms, which are increasingly used in engineering to arrive at solutions for complex problems. The basic approach is taken from evolution - the algorithm is designed to breed elements of a solution, killing-off unfit elements and allowing fit elements to reproduce with slight modifications. The fascinating thing about this approach is that it will often throw up solutions which could never have been designed but which function better than any designed solution could do.

Here we have a simple example.

The goal is to use a simple basic component - polygons of variable colour and size - to build a complex image. We start from random 50 polygons that are invisible. In each optimization step we randomly modify one parameter (like color components or polygon vertices) and check whether such new variant looks more like the original image. If it is, we keep it, and continue to mutate this one instead. Displayed fitness is a percentage of how close the new image is to the original one (1-current difference/maximum difference). The best possible is 100%. This new fitness is normalized so that it's easier to compare different images and different sizes.

Original
Best
Evolving
? Fitness
0 Improvements
0 Mutations
Start
Stop
0 Elapsed time
? Mutations per second

Now you can select the image to aim for. There are four 'preset' images below. Alternatively you can provide the URL for an image of your own.

Preset Images - Mona Lisa   Darwin   Velociraptor   John Koza

Or supply image URL
Please us a small image (~200x200 pixels), otherwise fitness computation is very slow.
Export DNA
Export SVG
Import DNA
[help]
Mutation
Gaussian
Soft
Medium
Hard
Initialize DNA
Color
White
Black
- 100
- 10
- 1
50 Polygons
+ 1
+ 10
+ 100

- 10
- 5
- 1
6 Vertices
+ 1
+ 5
+ 10

What is DNA import/export?
Click Export DNA to copy polygon representation of the current best image to the clipboard. You can use it to save your optimization state, for example to send it to somebody by mail or post it on the web. If you have such saved DNA string, you can later on paste it into the clipboard and click on Import DNA. This should reproduce the optimization state from the time it was saved via export.

Please note that DNA is independent of the original image. It means that if you used a custom image, you should also set this image (via image form) to reproduce a complete state. (Or you could play with switching images/DNA midway).

DNA format is very simple (all numbers are INTs except for ALPHA which is FLOAT): NUMBER_OF_VERTICES NUMBER_OF_POLYGONS R G B ALPHA X0 Y0 X1 Y1 ... XN YN ... R G B ALPHA X0 Y0 X1 Y1 ... XN YN ...

How does it look after some time?




Does it work on all images?

It depends, success varies. The best seem to be color images with well defined features.




















Requirements

Tested and works on (example mutation speed for Mona Lisa at the start of optimization on my notebook):

Credit for this goes to Roger Alsing who wrote the original code and alteredqualia.com who provided the skeleton for this page.