I'm about to start writing a genetic algorithm program which will be able to find the highest/lowest/whatever else values of variables required for an equation, and have come upon a point about which I am uncertain. I do not know whether I should store and work upon the values as binary or decimal. If, for example, I had 10 variables of a value between 0 and 31, would it be better to store this as 50 individual alleles (1 bit per allele) or 10 alleles (5 bits per allele)?

I'm about to start writing a genetic algorithm program which will be able to find the highest/lowest/whatever else values of variables required for an equation, and have come upon a point about which I am uncertain. I do not know whether I should store and work upon the values as binary or decimal. If, for example, I had 10 variables of a value between 0 and 31, would it be better to store this as 50 individual alleles (1 bit per allele) or 10 alleles (5 bits per allele)?

I assume you mean that each 'candidate' is described by 10 variables of a value between 0 and 31. That is, a total of 50 bits of information. If so, you could store the information in two unsigned longs, or one unsigned long long... or a string of 50 ascii characters -- whatever suits you.

I think you're a bit confused, though, because you're questioning whether you should have 1 bit per allele or 5 bits per allele. That doesn't really make any sense to me, because isn't the number of bits used to represent an allele be an application-dependent thing? The number of common alleles is dependent on the particular gene, no?

The reason for storing something in whichever way I do is simply to enable easy crossover. If my candidates were stored as two unsigned longs, wouldn't that be much harder to work on? Also, my reason for keeping it in binary is to allow simple mutation, and whilst I know that I could convert to binary, breed & mutate, and then convert back to decimal, it seems a bit of a pointless option when I could easily keep it as it is. Then again, the fitness function will have to convert it back to decimal, and that would be the most-called function.
Regarding the number of bits per allele, I am unsure whether to allow crossover between bits (so, for example, it could occur at the 2nd bit, which is within a variable, so 1 bit per allele) or to only allow it between variables (ie occuring at the 5th bit, so 5 bits per allele). Due to the nature of the numbers, it is clear that either crossover would produce an acceptable output, but the crossover would produce a much more varied generation, possibly requiring that generation to be larger, so as not to lose good options.

Genetic Algorithm (GA) In Solving Multi Variants Problem Implemented In Ms. NET C#

Using GA in solving multi-variant problem like this need a suitable data structure to represent the problem space. Representation of chromosome and DNA (element in each chromosome) need to be designed in a way to combine different farm lands with fertilizer. By randomly pair the farm land with the fertilizer, checking the fitness value in each chromosome, performing GA operation process to obtain a best fitness value chromosome. Then, the solution set can be obtain by retrieving the information in DNA from the chromosome.

I know that I could convert to binary, breed & mutate, and then convert back to decimal

The computer is always technically in bin... even if you're using dec values in a high-level language.

The computer is always technically in bin... even if you're using dec values in a high-level language.

Indeed, I used this when I continued writing my programme. In June 2007.

This article has been dead for over six months. Start a new discussion instead.