Ejemplo n.º 1
0
        protected virtual void Select()
        {
            Parents.Clear();

            var competition = new List <IChromosome <TVertex, TEdge> >();

            while (Population.Count > 0)
            {
                competition.Clear();

                var competitionSize = Random.Next(2, 4);

                for (var i = 0; i < competitionSize && Population.Count > 0; i++)
                {
                    competition.Add(Population.First.Value);

                    Population.RemoveFirst();
                }

                competition.Sort();

                Parents.AddLast(competition.First());
            }
        }