private void ensureInitialized() { if (precedenceTree == null) { precedenceTree = new PathTree(paths); evaluator = new TravelCostEvaluator(precedenceTree); selector = new RouletteWheelSelector(); IMutator mutator = new ReverseSequenceMutator(); procreator = new SexualProcreator(new ShortestTravelCrossover(precedenceTree), mutator, 0.5); Population genesis = new Population(); Individual individual0 = genesis.Append(); IReadOnlyList <PathNode> nodes = precedenceTree.NearestNeighborTraversal(); List <int> chromosome0 = individual0.GetChromosome(); chromosome0.AddRange(nodes.Select(node => node.Id)); //chromosome0.AddRange(Enumerable.Range(0, precedenceTree.Nodes.Count)); evaluator.Baseline(chromosome0); //List<int> lastChromosome = chromosome0; for (int i = 1; i < 100; i++) { List <int> chromosome = genesis.Append().GetChromosome(); chromosome.AddRange(chromosome0); //chromosome.AddRange(lastChromosome); mutator.Mutate(chromosome, random); //lastChromosome = chromosome; } genesis.Freeze(evaluator); optimizer = new GeneticOptimizer(genesis); maxFitness = double.MinValue; optimalPriorities = new List <int>(); } }