views:

50

answers:

2

My previous question belied my inexperience and was based on an assumption. Now I am much wiser. (Put 1s and 0s in a string? Pah! I laugh at the suggestion!)

My question is then, how should I encode my genomes?

On paper, they look like this:

01010011010110010

17 bits that encode (in some cases singly and in some cases as groups) the parameters to be tested.

The requirements are:

  1. Needs to be scalable. There might be 17 at the moment, but this could grow/shrink as options are added, removed or have their range modified.
  2. Each bit needs to be individually flippable, to represent spot mutations.
  3. Ideally, it should be easy to take the last X% of two genomes and switch them over (representing crossover).
  4. There must be a straightforward way of representing the genome in plaintext. Here the emphasis is on convenience rather than human translatability. (Think URL shorteners.)

Anyone got any great ideas? (If it's useful, I'm using C#.)

+3  A: 

BitArray

Andrey
+3  A: 

Like Andrey said, BitArray is probably your best answer, it meets all your requirements.

1) you can set the number of bits with the constructor

2) it allows you Set (on or off),Or,And,Xor, Not on bits

3) you can loop over your last x% to do crossover

4) there is a ToString that should allow you to output it.

JoshVarga