コード例 #1
0
        private Population CreateInitialPopulation(TrackCollection trackCollection)
        {
            var population      = new Population();
            var randomGenerator = new Random();

            population.Add(trackCollection);
            for (var k = 1; k < _populationSize; k++)
            {
                var individual = new TrackCollection();
                individual.AddRange(trackCollection);
                for (var i = 0; i < individual.Count; i++)
                {
                    var track = individual[i];
                    individual.Remove(track);
                    individual.Insert(randomGenerator.Next(individual.Count), track);
                }
                population.Add(individual);
            }
            return(population);
        }