示例#1
0
        public IIndividual <int, int> Crossover(IIndividual <int, int> parent)
        {
            int _crossoverPoint = cache.GetRandomNext() % parent.GetGenotypeSize();
            var _childGenotype  = new List <IGene <int, int> >();

            for (int i = 0; i < GetGenotypeSize(); i++)
            {
                if (i < _crossoverPoint)
                {
                    _childGenotype.Add(new Gene <int, int>
                                           (genotype.GetGene(i).GetKey(),
                                           genotype.GetGene(i).GetValue()));
                }
                else
                {
                    _childGenotype.Add(new Gene <int, int>
                                           (parent.GetGenotype().GetGene(i).GetKey(),
                                           parent.GetGenotype().GetGene(i).GetValue()));
                }
            }
            return(new Individual(new Genotype(_childGenotype, 0, cache), cache));
        }