It's time to look into generalizing the evolution process so that the same mechanism can be used in any of a great number of different domains. I've devised an interesting approach based on something I talked about during a previous podcast episode. In the end I want to be able to grow algorithms, and I want those algorithms to be defined by strings of bits like 0100101001010101001010110110110101010.

The strategy is not to chop the bit string into equal length chunks like bytes, 16-bit words, or 32 or 64 bit words. Instead, it's more interesting to get different lengths of bits coming out of the "genetic code", and I should eventually be able to demonstrate why.

I would like to introduce the "Nuance" concept. It's as simple as could be because a Nuance is just an immutable truth value, which can be false or true or anything in between. The code for the nuance specifies only an interface which allows you to extract the value by specifying the domain:

public interface Nuance {
    int precision();
    int value(int low, int high);
    float value(float low, float high);
    long value(long low, long high);
    double value(double low, double high);
}

By calling one of the value functions you can use the nuance for any numerical purpose that makes sense. As we continue, you will understand why this is the basis of the evolution system.

Just one nuance is not enough to make for some interesting genes, so there is something called a nuance stream which provides for reading nuances one after the other out of some source. You use the nuance, and then move to the next one.

public interface NuanceStream extends Nuance {
    boolean next();
}

So now comes the fun part. Remember how the Fibonacci binary code worked? It was all about using the two-bit delimiter 11 to signify the end of one word and the beginning of the next. Call it a "space". Random strings of bits will have 11 appear fairly frequently, of course, and the words left over between these spaces never contain the 11 so not every bit sequence comes out as a word.

That's why I used the name Fibonacci. There is 1 entry of zero length, 1 entry of one-length, 2 of length 2, 3 of length 3, 5 of length 4, 8 of length 5 and so on all the way down the fib sequence. 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, ...

When you put these possible bit strings in order you can make a nuance by deciding which of bit strings you're looking at. The first one is "false", the last one is "true" and the other ones in between are variations on "maybe". Longer sequences are more "nuanced" because there are more maybe values.

This is just the first step in this development, but I've set this up as a new project in the Subversion repository using Maven2.


http://fluidiom.svn.sourceforge.net/viewvc/fluidiom/nuance-engine/

We're going to take this step by step, and the first step for me was to create this first layer in the nuance-engine code. The main bit of code builds the bridge between the Fibonacci delimiter code and the idea of a Nuance. It's called a NuanceInputStream and it takes an input stream of bits and reveals the successive nuances that come out from between the delimiters.

NuanceInputStream.java - read bits and produce nuances

Imagine this input stream eating ones and zeros on the one end, effectively reading the genome, and then producing nuances on the other end. The next step will be to apply these nuances to executing an algorithm in general: nuanced instruction sets. Stay tuned. The first thing I want to apply this to is building structures.

Technorati Tags: