Exemple #1
0
        /// <summary>
        /// Recalculate the specie centroid based on the genomes currently in the specie.
        /// </summary>
        private CoordinateVector CalculateSpecieCentroid(Specie <TGenome> specie)
        {
            // Special case - 1 genome in specie (its position *is* the specie centroid).
            if (1 == specie.GenomeList.Count)
            {
                return(new CoordinateVector(specie.GenomeList[0].Position.CoordArray));
            }

            // Create a temp list containing all of the genome positions.
            List <TGenome>          genomeList = specie.GenomeList;
            int                     count      = genomeList.Count;
            List <CoordinateVector> coordList  = new List <CoordinateVector>(count);

            for (int i = 0; i < count; i++)
            {
                coordList.Add(genomeList[i].Position);
            }

            // The centroid calculation is a function of the distance metric.
            return(_distanceMetric.CalculateCentroidParallel(coordList));
        }