Skip to content

Genome Value Conversions

Clifford Bohm edited this page Jun 9, 2020 · 2 revisions

WARNING! THIS SECTION IS PRETTY ESOTERIC...

Since we do not know the alphabet size of a genome when we are using it, genome handlers provide a way to insure that a value being read from or written to a genome will be compatible with that genome.

These methods include min and max values. For example, lets say that you wanted to write the value 6 to a genome and that genome had an alphabet size of 2. No problem, 6 in binary = 110. Three sites in the genome would be assigned the values 1, 1 and, 0 respectively. If you wanted to read this value back though, you would be in trouble. How many bits from the genome should you read. To solve this issue, when you wish to write 6 to the genome, you also indicate a min and max value. Lets say you indicated 11, 0, 255. This would write 11 into a bytes worth of space in the genome. If this was writing into that genome with alphabet size two (binary), the following 8 values would be written 0 0 0 0 0 1 1 0. If you wrote this into a genome with alphabet size 4 then two sites would be written (with values 1 and 2). If the alphabet size was 8 or greater then one site would be written (with value 6). Why do you need to indicate a min value. Some times it is useful to read a value in range that does not start at 0. Consider a gate with a number of inputs 1 to 4. In this case, what I need is a value from 0 to 3, to which I would add a 1. It is easier for the user to simple ask for a number in the range 1 to 4, and let the genome handler do the work.

If you are working with a genome where the site type is doubles, then things are handled a little differently. Values are ranged as they are for other genome types, but they are always read from and written to a single site as continuous values can be arbitrarily scaled. While this may sound like a nice solution, double genomes should be avoided if continuous values are not needed as they use more memory.

Clone this wiki locally