Beispiel #1
0
        public bool calcRestrict(Individuo x)
        {
            bool r1 = (-1 * x.getValueIndex (0) <= 0);
            bool r2 = (-1 * x.getValueIndex (1) <= 0);
            bool r3 = (x.getValueIndex (0) + x.getValueIndex (1) - 4 <= 0);

            return (r1 && r2 && r3);
        }
Beispiel #2
0
 public double calcFitness(Individuo x)
 {
     double fit = 418.9829 * x.getValue().Length;
     double sum = 0;
     for (int i = 0; i < x.getValue ().Length; i++) {
         sum += -x.getValueIndex (i) * Math.Sin (Math.Sqrt (Math.Abs (x.getValueIndex (i))));
     }
     return (fit + sum);
 }
Beispiel #3
0
 public double calcFitness(Individuo x)
 {
     double sum = 0;
     for (int i = 0; i < x.getValue ().Length; i++) {
         sum += Math.Pow (x.getValueIndex (i), 2);
     }
     return sum;
 }
Beispiel #4
0
 public List<Individuo> cruceI(Individuo i, Individuo j)
 {
     int index = (int) (RNG.RandomNumber () * (i.getValue ().Length - 1)) + 1;
     List<Individuo> ind = new List<Individuo>(2);
     ind.Add (i); ind.Add (j);
     for(int k = index; k < i.getValue ().Length; k++){
         ind [0].setValueIndex (k, j.getValueIndex (k));
         ind [1].setValueIndex (k, i.getValueIndex (k));
     }
     return ind;
 }
Beispiel #5
0
 public double calcFitness(Individuo x)
 {
     double value = 0;
     if (it < 100) {
         for (int i = 0; i < x.getValue ().Length; i++) {
             value += Math.Pow (x.getValueIndex (i), 2) + x.getValueIndex (i) + 3;
         }
     } else {
         if (it < 200) {
             for (int i = 0; i < x.getValue ().Length; i++) {
                 value += Math.Pow (x.getValueIndex (i), 3) - (2 * Math.Pow (x.getValueIndex (i), 2)) + 3;
             }
         } else {
             for (int i = 0; i < x.getValue ().Length; i++) {
                 value = Math.Pow (x.getValueIndex (i), 2) - (3 * x.getValueIndex (i)) + 2;
             }
         }
     }
     return value;
 }