示例#1
0
        /// <summary>
        /// Returns the top count of the population based on lowest
        /// fitness value.
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public List <Chromosome> GetBottom(int count)
        {
            Solutions.Sort();
            Solutions.Reverse();

            var bottom = new Chromosome[count];

            Solutions.CopyTo(0, bottom, 0, count);

            return(bottom.ToList());
        }
示例#2
0
        /// <summary>
        /// Returns the top count of the population based on highest
        /// fitness value.
        /// </summary>
        /// <param name="count"></param>
        /// <returns>The top.</returns>
        public List <Chromosome> GetTop(int count)
        {
            if (Solutions.Count < count)
            {
                throw new PopulationException(
                          "The population is smaller than the number of chromosomes requested.");
            }

            var top = new Chromosome[count];

            Solutions.Sort();
            //Solutions.Reverse ();

            Solutions.CopyTo(0, top, 0, count);
            return(top.ToList());
        }
示例#3
0
        /// <summary>
        /// Returns a unique list representing the top unique count of
        /// the population based on highest
        /// fitness value.
        /// </summary>
        /// <param name="count"></param>
        /// <returns>The top.</returns>
        public List <Chromosome> GetUniqueTop(int count)
        {
            if (Solutions.Count < count)
            {
                throw new PopulationException(
                          "The unique population is smaller than the number of chromosomes requested.");
            }

            var top             = new Chromosome [count];
            var uniqueSolutions = this.Solutions.Distinct(new ChromosomeComparer()).ToList();

            Solutions.Sort();

            uniqueSolutions.CopyTo(0, top, 0, count);
            return(top.ToList());
        }
示例#4
0
        /// <summary>
        /// Returns the top count of the population based on highest
        /// fitness value.
        /// </summary>
        /// <param name="count"></param>
        /// <returns>The top.</returns>
        public List <Chromosome> GetTop(int count)
        {
            if (Solutions.Count < count)
            {
                throw new PopulationException(
                          "The Chromosome is not large enough to take the number of Genes specified.");
            }

            var top = new Chromosome[count];

            Solutions.Sort();
            //Solutions.Reverse ();

            Solutions.CopyTo(0, top, 0, count);
            return(top.ToList());
        }