예제 #1
0
        public Individual Select(Individual[] individuals, int size)
        {
            Individual[] contestans = new Individual[size];

            for (int i = 0; i < contestans.Length; i++)
            {
                contestans[i] = individuals[ENVIRONMENT.random.Next(individuals.Length - 1)];
            }

            Individual best        = individuals[0];
            double     minDistance = DistanceHelper.CountDistance(contestans[0].Cities);

            for (int i = 1; i < contestans.Length; i++)
            {
                double currentDistance = DistanceHelper.CountDistance(contestans[i].Cities);
                if (minDistance > currentDistance)
                {
                    minDistance = currentDistance;
                    best        = contestans[i];
                }
            }
            return(best);
        }
예제 #2
0
 public void SetTotalDistance()
 {
     TotalDistance = DistanceHelper.CountDistance(Cities);
 }