Exemplo n.º 1
0
 private void GeneratePopulation(int n)
 {
     population = new Imagen[n];
     for (int i = 0; i < n; i++)
     {
         population[i] = new Imagen(DistanceFactory.GetInstance(distanceType), bitmap.Height, bitmap.Width, probMutation, YES, histOption);
     }
 }
Exemplo n.º 2
0
        public void NewGeneration()
        {
            int bye = (int)(population.Length - 2 - (population.Length * 0.05));

            for (int i = population.Length - 1; i > bye; i--)
            {
                population[i] = new Imagen(DistanceFactory.GetInstance(distanceType), bitmap.Height, bitmap.Width, probMutation, YES, histOption);
            }
        }
Exemplo n.º 3
0
        public void CrossO()
        {
            Random rand = new Random();

            for (int i = 0; i < probCrossOver; i++)
            {
                int    father = rand.Next((int)(population.Length));
                int    mother = rand.Next((int)(population.Length));
                int    victim = population.Length - 1;//(int)(rand.Next(population.Length/10) + population.Length*0.8);
                Bitmap son;
                son = population[father].Crossin(population[mother].bitmap, bitmap);
                Imagen newImg = new Imagen(DistanceFactory.GetInstance(distanceType), bitmap.Height, bitmap.Width, probMutation, NO, histOption);
                newImg.bitmap = son;
                newImg.ProcessDistance(bitmap);
                population[victim] = newImg;
                Array.Sort(population);
            }
        }