genetic algorithm base implementation