Exemplo n.º 1
0
        virtual public void Crossover(IChromosome pair)
        {
            ACompositeChromosome p = (ACompositeChromosome)pair;

            CrossoverShorts(p);
            CrossoverDoubles(p);
            CrossoverMiscs(p);
        }
Exemplo n.º 2
0
 protected void CrossoverShorts(ACompositeChromosome pair)
 {
     if (shorts != null)
     {
         shorts.Crossover(pair.shorts);
         insureShortVals();
     }
 }
Exemplo n.º 3
0
 protected void CrossoverDoubles(ACompositeChromosome pair)
 {
     if (doubles != null)
     {
         doubles.Crossover(pair.doubles);
         insureDoubleVals();
     }
 }
Exemplo n.º 4
0
 protected void CrossoverMiscs(ACompositeChromosome pair)
 {
     if (miscChromosomes != null)
     {
         for (int i = 0; i < MiscCount; ++i)
         {
             miscChromosomes[i].Crossover(pair.miscChromosomes[i]);
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// clones src chromosome (and clone()s inner misc chromosomes)
        /// </summary>
        /// <param name="src"></param>
        public ACompositeChromosome(ACompositeChromosome src)
        {
            if (src.shorts != null)
            {
                shorts = new MemberShortArrayChromosome(src.shorts);
            }
            else
            {
                shorts = null;
            }

            if (src.doubles != null)
            {
                doubles = new MemberFractionArrayChsromosome(src.doubles);
            }
            else
            {
                doubles = null;
            }

            maxDoubleVals = src.maxDoubleVals;
            maxShortVals  = src.maxShortVals;
            ShortsCount   = src.ShortsCount;
            DoublesCount  = src.DoublesCount;
            Fitness       = src.Fitness;

            if (src.miscChromosomes != null)
            {
                miscChromosomes = new List <IChromosome>(src.miscChromosomes.Count);
                foreach (IChromosome c in src.miscChromosomes)
                {
                    miscChromosomes.Add(c.Clone());
                }
            }
            else
            {
                miscChromosomes = null;
            }
        }