Пример #1
0
        private static List <OperatingData> GenerateInitialPopulation()
        {
            var randomSolution = new RandomSolution();
            var localSearch    = new LocalSearch();
            var population     = new List <OperatingData>();

            for (var i = 0; i < DAL.PopulationSize; i++)
            {
                var solution = new OperatingData {
                    UnusedNodes = DAL.Instance.Nodes.CloneList()
                };
                localSearch.Optimize(randomSolution.FindRouteFromRandomStart(solution));

                while (population.Any(solution2 => solution2.Distance == solution.Distance))
                {
                    solution = new OperatingData {
                        UnusedNodes = DAL.Instance.Nodes.CloneList()
                    };
                    localSearch.Optimize(randomSolution.FindRouteFromRandomStart(solution));
                }

                population.Add(solution);
            }

            return(population);
        }