genetic algorithm core implementation