How much of computer programming now is, um 'evolutionary'

This is GenJam a genetic software that plays jazz.

This is not "canned" music, but the software improvises and "interacts" in real time with the musician.



Many other artistic application of GA like in architecture are discussed by Manuel De Landa in this video:

http://www.youtube.com/watch?v=50-d_J0hKz0
 
Last edited:
That doesn't seem right to me. For the "selection" aspect of evolutionariy programming to work the unit tests have to exist. The QA has to be well defined up front for this method to have any chance at working.

One of the issues is that you can still come up with a solution that fits the fitness functions perfectly, but since you may never have actually tested that outcome in a production environment, QA could be at risk.

There are certainly applications where this is acceptable. But not always.
 
What's a genetic algorithm?

obitko.com/tutorials/ GENETIC ALGORITHMS
These pages introduce some fundamentals of genetic algorithms.

Pages are intended to be used for learning about genetic algorithms without any previous knowledge from this area.

Only some knowledge of computer programming is assumed. You can find here several interactive Java applets demonstrating work of genetic algorithms.

Outline of the Basic Genetic Algorithm
  1. [Start] Generate random population of n chromosomes (suitable solutions for the problem)
  2. [Fitness] Evaluate the fitness f(x) of each chromosome x in the population
  3. [New population] Create a new population by repeating following steps until the new population is complete
    1. [Selection] Select two parent chromosomes from a population according to their fitness (the better fitness, the bigger chance to be selected)
    2. [Crossover] With a crossover probability cross over the parents to form a new offspring (children). If no crossover was performed, offspring is an exact copy of parents.
    3. [Mutation] With a mutation probability mutate new offspring at each locus (position in chromosome).
    4. [Accepting] Place new offspring in a new population
  4. [Replace] Use new generated population for a further run of algorithm
  5. [Test] If the end condition is satisfied, stop, and return the best solution in current population
  6. [Loop] Go to step 2




Here's one simple yet superbly illustrative:
Basically, I simulate clocks as living organisms. Selective pressure is focused on their ability to accurately tell time. NO goal is imposed on the design (you can tell this because every simulation ends with a differently constructed clock). And it works. Clocks evolve through a series of transitional forms: Pendulum, Proto-clock, 1-handed Clock, 2-handed Clock, 3-handed Clock, and 4-handed Clock. Gradually the complexity is built up.

These labels I have assigned to the transitional forms have nothing to do with the simulation itself. They are names I assigned so that we could analyze what the population was doing. The clocks are just clocks, living in their world, trying to tell time as accurately as possible.

One thing I wanted to address but didn't have time in the video is how rapid the transitional period can be. In some simulations the population goes from pendulums to 3-handed Clocks in a hundred or so generations. And the transitions between the transitional forms are even more rapid, happening in about ten generations. Chances are none or a very limited representation of that transition will be preserved in the fossil record.

One thing I should add. The program does not draw the clocks. It maintains, mates, and simulates them, but the drawing must be done manually from the genome matrix.

The program is written in MatLab.

<snip/>
To download the program go to:
www.mediafire.com/?1umdtnwayyp

The download is a 7kB zip file containing 5 MatLab files (total 23kB unzipped) that you can read in any text editor (e.g. Notepad, or my favourite: SciTE)


clocktest.m
PHP:
function output = clocktest(ck)
/*
%   This is not a completely rigorous simulation of physics.  Since the
%   components are simple and can only connect to each other in defined
%   ways we dont need to perform a full simulation to see what happens.
%   The simulation progresses looking for more and more complex structures.
%   If at any time it finds it is impossible for the clock to tell time,
%   i.e. the gears bind up, there is no spring attached, etc., the
%   simulation stops.  This saves cpu time.

%Structure of a clock matrix
%30 gears:  r 1:30,     c 1:40 connectivity
%           1=connected by teeth
%           2=fused at axil
%           r 1:30,     c 41:100 sum = number teeth
%7 hands:   r 31:37,    c 1:40 connectivity
%1 ratchet  r 38,       c 1:40 connectivity
%1 spring:  r 39,       c 1:40 connectivity
%1 base:    r 40,       c 1:40 connectivity
%
*/
warning('off','all');

output{1} = [];
output{2} = [];
output{3} = [];
output{4} = [];
output{5} = [];

conn = ck(1:40,1:40);
/*
%   Connectivity is bidirectional, make sure the matrix is so.
%   This is just a physical fact of the universe.  If A touches B, B must
%   touch A.  
*/
 
One of the issues is that you can still come up with a solution that fits the fitness functions perfectly, but since you may never have actually tested that outcome in a production environment, QA could be at risk.

There are certainly applications where this is acceptable. But not always.
How is that different from human generated code?
 
This is GenJam a genetic software that plays jazz.

This is not "canned" music, but the software improvises and "interacts" in real time with the musician.



Many other artistic application of GA like in architecture are discussed by Manuel De Landa in this video:

http://www.youtube.com/watch?v=50-d_J0hKz0

I found this fascinating.

Just by listening, once:

The machine was presumably pre-programmed to do a sax solo, then trade 8's with the trumpet. It's hard to tell how it's interactive.

The only 'improvising' the software is doing is the soprano-saxish part. The notes it's playing fit the changes all right, but they're no really jazz lines--as in idiomatic--and they're not all that musical, though they're not bad.

There's a lack of chromatic approach-notes and of rhythmic variety. The soprano sax lines sounded slightly swung, but a little stiff anyway.

It plays like someone who never really heard latin jazz--more like a Martian who heard Joe Zawinal a few times, and figured out the general rules. (It made me think of Zawinal because he used to play some odd lines that sounded vaguely like that. Chord-scale based, but not deviating from that.

Fascinating stuff.

As in real jazz, most of the parts aren't really improvising but playing parts.

The machine would have no way of knowing how to play idiomatic chord-voicings--which the piano parts in fact were--so someone programmed them, in a sense.

But this is all secondary to the main purpose of the thread, here, and I'm just listening and guessing.

I'd be interested to see something written about it.
 
How is that different from human generated code?

Generally, human generated code (well, even GAs results are indirectly human generated...) is easier to determine and test for all the reasonably possible inputs and outputs. There are no absolutes here, but this is from what I've seen.

I think it is largely a matter of planning, resources, and time. For example, you have a bed of equipment, with multiple buses, and you want to tune the buses to best support all the potential traffic from all the configurations of the equipment. A human might provide some routines and know immediately what the limits are on the outcomes, selecting only those configuration details they see as obviously useful. A GA, especially a very useful one, might be programmed with so many of the details of the bus command structure, and be able to try so many of the combination that a human might have not considered, that it may come up with some extremely novel outcomes, using details no one had the time or foresight (or motivation) to consider.

A QA functionary may look at the human's scope of testing, and feel ok with it, but then look at the GA's scope, and feel it is outside their resources to test. It's not one can't be done, and the other can. One could just take much more work, or by not taking that extra effort, could pose more risk.
 
The other issue with testing is that some standards require specific code coverage, e.g. tests must cover 80%, 90% or more of code. With genetic-algorithm generated code, I believe it could be difficult to determine how to achieve this; furthermore, it's quite possible that there would be "dead code" (code that serves no useful purpose, like the [popular view of] the human appendix).

Other standards often include code reviews (having another developer examine one's code before it's included in the product). How does one review GA code?

Worse, if the code is in critical systems - flight control software, medical software, and so forth - it will be held to a higher standard of QA.

As mentioned, though, I see no problem with using a GA to find an algorithm and incorporating it manually in hand-written code.
 
Other standards often include code reviews (having another developer examine one's code before it's included in the product). How does one review GA code?
Not sure if you do not mean genetic programming here.

Genetic algorithm generates a population of solutions to a problem. Like best parameters for an avaluation function in a chess program.

Genetic programming evolves computer programs.
 
Worse, if the code is in critical systems - flight control software, medical software, and so forth - it will be held to a higher standard of QA.

As mentioned, though, I see no problem with using a GA to find an algorithm and incorporating it manually in hand-written code.
Likewise

I'm curious to know if there are there are any 'mission critical' business (or similarly 'important') apps written otherwise
 
Actually all programming undergoes evolution. Methods, approaches, languages .. all is based on previous ones (it. there is some kind of inheritance), it undergoes mutation (though often not random), it undergoes selection. Even the environment does change and programming has to follow (for example accent on multiprocessing these days as we have troubles making simple cores run faster).

I am programmer for 20 years.
As for genetic programming, automatic evolution of code itself .. I've only heard about it once, and it was 'random' LISP code generating images, and people (on some exhibition) selected the most pretty ones.
Also I don't know about any real application of genetic algorithm firsthand. Even in some areas where it could be applicable, people preferred classical approach. You have to understand it so you can fix it.
 
Application of genetic programming is mostly in search and optimization problems.
 
In my current work I'm using a genetic algorithm to optimize lens mass density distributions to model gravitational lens systems. The optimization is really quite elegant, and tends to thoroughly explore the parameter space of the lens models. GAs have advantages over other types of optimization schemes since they are global and not local optimizers. They don't depend on gradient information in the parameter space to find optimal areas and are much less prone to becoming stuck in local minima than other routines because of this.

Another interesting optimizer is known as a Particle Swarm Optimizer (PSO). I have used these routines as well but they don't explore parameter spaces nearly as well as evolution does.
 
Last edited:
My question for computer programmers here: How much of computer programming today uses methods like this?
Not much.

What kinds of programs?
The broader category of machine learningWP is used by some search engines, spam classifiers, recommendation programs, and so forth. I don't know whether genetic or evolutionary algorithms are used in those applications.
 
Compounding this is the problem of maintenance. The initial development & testing of code is often a small part of its life-cycle cost; a successful app may be in use for decades and go through dozens of iterations and upgrades. Maintaining code is painful enough when it's written by a human; adding features to incomprehensible code would be . . . nearly impossible.

Is it possible to add new "selective pressures" that might produce the desired upgrade?
 

Back
Top Bottom