Esempio n. 1
0
 private void StartPop()
 {
     Genoms     = new Genom[PopulationSize];
     _tmpGenoms = new Genom[PopulationSize];
     for (int i = 0; i < Genoms.Length; i++)
     {
         Genoms[i]     = new Genom(RandomGenomCode(GenomLength));
         _tmpGenoms[i] = new Genom();
     }
 }
Esempio n. 2
0
        private bool[] Recombine(Genom one, Genom two, out bool[] resultTwo)
        {
            bool[] codeOne = new bool[GenomLength];
            bool[] codeTwo = new bool[GenomLength];

            int skip = r.Next(0, GenomLength);

            for (int i = 0; i < GenomLength; i++)
            {
                if (i > skip)
                {
                    codeOne[i] = two.Code[i];
                    codeTwo[i] = one.Code[i];
                }
                else
                {
                    codeOne[i] = one.Code[i];
                    codeTwo[i] = two.Code[i];
                }
            }
            resultTwo = codeTwo;
            return(codeOne);
        }