コード例 #1
0
        /// <summary>
        /// Initializes the population of Species
        /// </summary>
        /// <returns>async Task</returns>
        protected override void Initialization()
        {
            _population = new List <Species <double> >();
            for (int i = 0; i < Settings.Size; i++)
            {
                UnitSet participants1 = new UnitSet(_stableMarriage.Units1.OrderBy(x => _random.Next()));
                UnitSet participants2 = new UnitSet(_stableMarriage.Units2.OrderBy(x => _random.Next()));

                //Randomized solution
                Solution genes   = new Solution(participants1.Zip(participants2, (x, y) => new Tuple <int, int>(x, y)).ToList());
                double   fitness = CalculateFitness(genes);

                _population.Add(new Species <double>()
                {
                    Genes   = genes,
                    Fitness = fitness
                });
            }

            _population.OrderByDescending(x => x.Fitness);
        }