I'm trying to find out square root of a float number using genetic algorithm. 
I have initialized population of random numbers and a fitness function. How do I implement selection of parents from population and uniform crossover? 
SELECTION 
The function given by gilad (the one you are using) seems fine. Why not just follow a standard procedure ? You can find some ideas on wikipedia
CROSSOVER 
If you are considering a candidate as a 32 bit vector (31 actually), then doing a uniform crossover consist in choosing bits of either parent with half probability.
The idea will be :
Programmatically an efficient way of creating a child from 2 parents will be to generate a random 32 bit number r, and given parents a and b do :
 child = (r & a) | (~r & b);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With