private Population runAlgorithem(Population population, int amountOfGenerations)
        {
            const double crossoverProbability = 0.65;
            const double mutationProbability  = 0.08;
            const int    elitismPercentage    = 5;

            //create the genetic operators
            var elite = new Elite(elitismPercentage);

            var crossover = new Crossover(crossoverProbability, true)
            {
                CrossoverType = CrossoverType.SinglePoint
            };

            var mutation = new SwapPlayerMutation(mutationProbability, this.players, this.groupedPlayers);

            //create the GA itself
            var ga = new GeneticAlgorithm(population, evaluateFitness);

            //subscribe to the GAs Generation Complete event
            ga.OnGenerationComplete += this.getOnGenerationComplete();

            //add the operators to the ga process pipeline
            ga.Operators.Add(elite);
            ga.Operators.Add(crossover);
            ga.Operators.Add(mutation);

            //run the GA
            ga.Run(GetTerminateFunction(amountOfGenerations));

            this.performanceMonitor.SavePerformanceLog("./results");

            return(ga.Population);
        }
        public IEnumerable <Player> FindSolution()
        {
            const double crossoverProbability = 0.65;
            const double mutationProbability  = 0.08;
            const int    elitismPercentage    = 5;

            //create the population
            var population = new Population();

            Random rnd = new Random();

            //create the chromosomes
            for (var p = 0; p < 100; p++)
            {
                var chromosome = new Chromosome();
                for (var g = 0; g < 11; g++)
                {
                    chromosome.Genes.Add(new Gene(rnd.Next(0, this.players.Count())));
                }

                chromosome.Genes.ShuffleFast();
                population.Solutions.Add(chromosome);
            }


            //create the genetic operators
            var elite = new Elite(elitismPercentage);

            var crossover = new Crossover(crossoverProbability, true)
            {
                CrossoverType = CrossoverType.SinglePoint
            };

            var mutation = new SwapPlayerMutation(0.02, this.players);

            //create the GA itself
            var ga = new GeneticAlgorithm(population, evaluateFitness);

            //subscribe to the GAs Generation Complete event
            ga.OnGenerationComplete += ga_OnGenerationComplete;

            //add the operators to the ga process pipeline
            ga.Operators.Add(elite);
            ga.Operators.Add(crossover);
            ga.Operators.Add(mutation);

            //run the GA
            ga.Run(TerminateAlgorithm);

            var topSolution = this.getPlayersFromChromosome(ga.Population.GetTop(1).First());

            this.calculator.PrintFitnessDetails(topSolution);

            return(topSolution.OrderBy(p => p.type));
        }