Implementation of a basic genetic algorithm.