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); } } }
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(); }
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); } } }