private void Reproduction(Generation cur) { for (int i = 0; i < ReproductionsCount; i++) { Tour tour = (Tour)LastGeneration[i].Clone(); cur.Add(tour); } }
public static Generation ResolveNextGeneration(Grid grid, Rules rules, Generation cells) { var nextGen = new Generation(); foreach (var cell in cells) { nextGen.Add(cell.Key, CellAliveNextGen(cell.Value, NeighborsCount(cell.Key, grid, cells), rules)); } return(nextGen); }
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); } } }
public void HasLiveCellsProperty() { var generation = new Generation(); Assert.IsFalse(generation.HasLiveCells); var cell = new RowCol(0, 0); generation.Add(cell, false); Assert.IsFalse(generation.HasLiveCells); generation[cell] = true; Assert.IsTrue(generation.HasLiveCells); }
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); } } }