Logo Search packages:      
Sourcecode: gaffitter version File versions  Download package

float GeneticAlgorithm::NonUniformFiller ( float  x  )  const [private]

This function makes the probability of choosing gene "1" varying between 0% and 100%. However it is biased (non uniform), making most probabilities near to 0.5 (50%).

The first created individuals contain several '0's (very sparse). On the other hand, the last individuals contain several '1's.

Definition at line 193 of file GeneticAlgorithm.cc.

Referenced by InitPopulation().

{
   const float p1 = 0.2;    // ends r'
   const float p2 = 0.8;    // begins r"
   const float angle = 0.1; // r inclination

   /*    ^
        1|                           (1,1)
         |                            /
         |                          /
         |      y2      r      y1 /  r"
   yo 0.5-       o_______------o/
         |  r'  /.             .
         |    /  .             .
         |  /    .             .
         |/      .             .
       0 ----------------|----------------> x
         |0      p1     0.5    p2       1
                        xo

       General Equations:

       - one point (yo,xo) and inclination (k):

         y = k (x - xo) + yo

       - two points (y2,x2;y1,x1):
       
             y2 - y1
         y = ------- (x-x1) + y1
             x2 - x1
   */

   if (x<=p1) // r'
   {
      /* r': 

             y2
       y = x --
             p1 
      */
      const float y2 = angle*(p1-0.5)+0.5;

      return x*y2/p1;
   }

   if (x>=p2) // r"
   {
      /* r":
       
           1-y1 
       y = ---- (x-p2) + y1
           1-p2
      */
      const float y1 = angle*(p2-0.5)+0.5;
      
      return (1.0-y1)/(1.0-p2)*(x-p2)+y1;
   }

   // r
   /* (p1<x<p2)
      r: y = k (x - xo) + yo */
   return angle*(x-0.5)+0.5;
}


Generated by  Doxygen 1.6.0   Back to index