Newsgroups: comp.ai.genetic
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!news.acsu.buffalo.edu!news.uoregon.edu!tezcat!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!howland.erols.net!worldnet.att.net!arclight.uoregon.edu!news.bc.net!torn!kwon!watserv3.uwaterloo.ca!undergrad.math.uwaterloo.ca!eadengle
From: eadengle@dino.uwaterloo.ca (Ed "Cynwrig" Dengler)
Subject: Re: Binary chromosomes vs. Real numbered chromosomes
Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
Message-ID: <E3Ltn5.5t@undergrad.math.uwaterloo.ca>
Date: Mon, 6 Jan 1997 20:45:04 GMT
References: <5ah4gl$7l7@solaris.cc.vt.edu> <32CDBE3C.38D9@ing.sun.ac.za> <5ajflt$a6e@netnews.upenn.edu>
Nntp-Posting-Host: dino.uwaterloo.ca
Organization: University of Waterloo
Lines: 77

In article <5ajflt$a6e@netnews.upenn.edu>,
Jeffrey Taylor <jeff@adeno.wistar.upenn.edu> wrote:
>
>	For those who are unfamiliar with Gray codes, Gray coding is a binary 
>coding scheme where G(i) and G(i+1) differ in exactly one bit.  Example:
>
>Intger	Binary	Gray
>0	000	000
>1	001	001
>2	010	011
>3	011	010
>4	100	110
>5	101	111
>6	110	101
>7	111	100
>
>Using Gray codes, a point mutation will change an integer allele by plus or
>minus one.
>
>Jeff Taylor

Actually, given the standard method of generating Gray codes for numbers,
the effect of a 1 point mutation is quite interesting.  If you call
the bits as a_{n} ... a_{2} a_{1}, then flipping the bit a_{i} changes
the number to the mirror version in the current block of 2^i numbers.
For example, if we have 100 (7), and change the 1 to a 0, the current
block is 2^3=8, so we will change to the mirror number in that block
which is a 0.  Changing the a_{1} bit will always change the number
by +/-1 because we will use the mirrored number in the size 2^{1}=2 block,
but to get the opposite result will depend on where the number is in which
blocks (for example, changing 0100 (7) to 1100 (8) requires flipping the
a_{4} bit, but changing 0111 (5) to 0101 (6) requires flipping the a_{3} bit.

So, what does this all mean?  Just that gray coding allows for the possibility
of massive jumps in any direction.  However, the distance that can be
travelled is limited by the exact number.  Also,while the jumps are mirrored
(you can reverse a jump by flipping the same bit), they are not equivalent
in both directions.

For example:
    Integer    Gray    Furthest Jump   Possible jumps
    0          0000    15 (+15)                     +1 +3 +7 +15
    1          0001    14 (+13)                  -1 +1 +6 +13
    2          0011    13 (+11)                  -1 +1 +2 +11
    3          0010    12 (+9)                -3 -1 +1 +9
    4          0110    11 (+7)                   -1 +1 +3 +7
    5          0111    10 (+5)                -3 -1 +1 +5
    6          0101    1  (-5)                -5 -1 +1 +3
    7          0100    0  (-7)             -7 -3 -1 +1
    8          1100    15 (+7)                   -1 +1 +3 +7
    9          1101    14 (+5)                -3 -1 +1 +5
    10         1111    5  (-5)                -5 -1 +1 +3
    11         1110    4  (-7)             -7 -3 -1 +1
    12         1010    3  (-9)                -9 -1 +1 +3
    13         1011    2  (-11)           -11 -2 -1 +1
    14         1001    1  (-13)           -13 -6 -1 +1
    15         1000    0  (-15)       -15  -7 -3 -1

I was always wondering if it might be better to do some sort of redundent
coding that would always allow for equivalent magnitude jumping, something
like :

      b_{n} ... b_{2} b_{1}   where   b_{i} = a_{i,2} a_{i,1}
                                      b_{i} = 10     ==> +2^(i-1)
                                              01     ==> -2^(i-1)
                                              00,11  ==> +0

which would give us a range -(2^n - 1) .. (2^n - 1), if we added
a b^{n+1} component, and truncated the range to -2^n .. 2^n, we
would be able to jump the same amount no matter what the number, and
we could easily jump to max/min if need be.  Note that multiple
numbers are represented by the same code, but redundency is sometimes
nice.

Ed

 
