Page 1 of 1

beginner question

PostPosted: Tue Aug 06, 2013 1:28 am
by gl2000
The library is impressive. I'm new to GA and have done some reading, but have what should be a simple question.

In your OptimizationFunction2d, you optimize 2 inputs, both having some range. This is represented in one single binary chromosome correct? It's basically 1 byte, which represents 2 numbers? How do you know which part of it represents which input? How is -1, 2 represented for example?
And if I wanted to to a 10D optimization, I would need to create a fitness function, and a crossover/mutation?

thank you.

Re: beginner question

PostPosted: Wed Aug 07, 2013 10:12 am
by andrew.kirillov
gl2000 wrote: It's basically 1 byte, which represents 2 numbers?

No. When you create binary chromosome you can specify its length in bits. Up to 64 bits length can be specified, which is 8 bytes.

gl2000 wrote: How do you know which part of it represents which input?

If you have 64 bits for 2 variables, for example, then just use lower 32 bits for the first and other 32 bits for the second variable. Check source code.

gl2000 wrote:And if I wanted to to a 10D optimization, I would need to create a fitness function, and a crossover/mutation?

For 10 variables you can try DoubleArrayChromosome - it already has mutation and crossover implemented. But you will need fitness function to do. If this chromosome does not suite your needs, then you can implement a new one with mutation/crossover for it.