Пример #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);
        }
Пример #2
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;
 }
Пример #3
0
        public bool calcRestrict(Individuo x)
        {
            bool r1 = (-1*x.getValue()[0] <= 0);
            bool r2 = (-1*x.getValue()[1] <= 0);
            bool r3 = (x.getValue()[0] + x.getValue()[1] - 4 <= 0);

            return (r1 && r2 && r3);
        }
Пример #4
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);
 }
Пример #5
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;
 }
Пример #6
0
 private double getChance(Individuo a, Individuo b)
 {
     double c;
     if (a.getFit () < 0 || b.getFit() < 0) {
         if (a.getFit () < b.getFit ()) {
             c = 2 * Math.Abs (a.getFit ()) + Math.Abs (b.getFit ());
         } else {
             c = 2 * Math.Abs (b.getFit ()) + Math.Abs (a.getFit ());
             return ((Math.Abs (a.getFit ()) + Math.Abs (b.getFit ())) / c);
         }
     } else {
         c = a.getFit () + b.getFit ();
     }
     return (Math.Abs (a.getFit ()) / c);
 }
Пример #7
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;
 }
Пример #8
0
 public void addIndi(Individuo ind)
 {
     m_ind.Add (ind);
 }
Пример #9
0
 public double calcFitness(Individuo x)
 {
     return Math.Pow(x.getValue()[0], 2) - Math.Pow(x.getValue()[1], 2);
 }