예제 #1
0
 private void Crossover(Generation cur)
 {
     for (int i = 0; i < CrossoverTries; i++)
     {
         Tour tour = new Tour(LastGeneration, crossoverStrategy, crossoverOperator);
         tour.Improve();
         if (!cur.Contains(tour))
         {
             cur.Add(tour);
         }
     }
 }
예제 #2
0
        protected override void FirstGeneration(Generation cur)
        {
            RandomGenerate generatingAlgorithm = new RandomGenerate(Task);

            for (int tries = 0; tries < MaxTriesForFirstGeneration; tries++)
            {
                Tour tour = new Tour(generatingAlgorithm);
                tour.Improve();
                if (!cur.Contains(tour))
                {
                    cur.Add(tour);
                }
            }
            cur.Sort();
        }
예제 #3
0
        private void Mutation(Generation cur)
        {
            for (int i = 0; i < MutationTries; i++)
            {
                int index;
                mutationStrategy.Run(LastGeneration, out index);

                Tour tour = mutationOperator.Run(LastGeneration[index]);

                tour.Improve();
                if (!cur.Contains(tour))
                {
                    cur.Add(tour);
                }
            }
        }