Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
                }
            }
        }