Beispiel #1
0
 public double fittness(Individual path)
 {
     double dist = 0.0;
     int  b = path.get(0);
     for (int i = 1; i < x.Length; i++)
     {
         int a = b;
         int dx = x[a] - x[b];
         dx = dx > 0 ? dx : -dx;
         int dy = y[a] - y[b];
         dy = dy > 0 ? dy : -dy;
         b = path.get(i);
         dist += (Math.Sqrt((double)((dx*dx)+(dy*dy))));
     }
     return dist;
 }
Beispiel #2
0
 public Individual(Individual Twin)
 {
     genes = new int[Twin.size()];
     for (int i = 0; i < genes.Length; i++)
     {
         genes[i] = Twin.get(i);
     }
     fittness = 0;
     dead = Twin.dead;
 }