Ejemplo n.º 1
0
        public double Calc_Error(PCFuzzySystem error_checker)
        {
            Individ temp_Best = null;
            double  min_error = double.PositiveInfinity;

            foreach (Individ indiv in the_popualate)
            {
                indiv.calc_Error(error_checker);
                if (min_error > indiv.error)
                {
                    min_error = indiv.error;
                    temp_Best = indiv;
                }
            }


            if (temp_Best != null)
            {
                if (best_individ != null)
                {
                    if (temp_Best.error < best_individ.error)
                    {
                        best_individ = temp_Best;
                    }
                }
                else
                {
                    best_individ = temp_Best;
                }
            }


            return(min_error);
        }
Ejemplo n.º 2
0
        private Individ crossover_uniform(Individ another_parent, double level_cross, Random Rand)
        {
            Individ child = new Individ(this);

            for (int i = 0; i < child.count_step_rotate; i++)
            {
                if (Rand.NextDouble() < level_cross)
                {
                    child.step_rotate[i] = another_parent.step_rotate[i];
                }
            }

            for (int i = 0; i < child.count_step_sko; i++)
            {
                if (Rand.NextDouble() < level_cross)
                {
                    child.step_sko[i] = another_parent.step_sko[i];
                }
            }


            child.hrom_vector.crossover_uniform(another_parent.hrom_vector, Rand, level_cross);

            return(child);
        }
Ejemplo n.º 3
0
        private Individ crossover_multipoint(Individ another_parent, int count_multipoint, Random Rand)
        {
            Individ child = new Individ(this);

            int size = child.step_sko.Count;

            size += child.hrom_vector.Core_Check.TermsSet.Count();

            size += child.hrom_vector.Core_Check.RulesDatabase.Count;

            List <int> trigger_cross = new List <int>(count_multipoint);

            do
            {
                trigger_cross.Add(Rand.Next(size));
                trigger_cross = trigger_cross.Distinct().ToList();
            } while (trigger_cross.Count < count_multipoint);
            trigger_cross.Sort();



            Boolean flag_reverse = false;



            /*
             * for (int i = 0; i < child.count_step_rotate; i++)
             * {
             *  if (flag_reverse)
             *  {
             *      child.step_rotate[i] = another_parent.step_rotate[i];
             *  }
             *
             * }
             */

            int current_pos = 0;


            for (int i = 0; i < child.count_step_sko; i++)
            {
                if ((trigger_cross.Count > 0) && (current_pos == trigger_cross[0]))
                {
                    flag_reverse = !flag_reverse;
                    trigger_cross.RemoveAt(0);
                }

                if (flag_reverse)
                {
                    child.step_sko[i] = another_parent.step_sko[i];
                }
                current_pos++;
            }


            child.hrom_vector.crossover_multipoint(another_parent.hrom_vector, Rand, current_pos, trigger_cross, flag_reverse);

            return(child);
        }
Ejemplo n.º 4
0
        public Individ(Individ the_individ)
        {
            hrom_vector       = new Hromosom(the_individ.hrom_vector);
            step_rotate       = new List <double>(the_individ.step_rotate);
            step_sko          = new List <double>(the_individ.step_sko);
            count_step_rotate = the_individ.count_step_rotate;

            count_step_sko = the_individ.count_step_sko;
            Data           = the_individ.Data;
        }
Ejemplo n.º 5
0
        public Individ crossover(Individ another_parent, FuzzySystem.FuzzyAbstract.learn_algorithm.conf.ESConfig.Alg_crossover type_cross, Random rand, double param)
        {
            Individ cross_hrom = null;

            switch (type_cross)
            {
            case FuzzySystem.FuzzyAbstract.learn_algorithm.conf.ESConfig.Alg_crossover.Унифицированный: cross_hrom = crossover_uniform(another_parent, param, rand); break;

            case FuzzySystem.FuzzyAbstract.learn_algorithm.conf.ESConfig.Alg_crossover.Многоточечный: cross_hrom = crossover_multipoint(another_parent, (int)param, rand); break;

            default: cross_hrom = crossover_uniform(another_parent, param, rand); break;
            }



            return(cross_hrom);
        }
Ejemplo n.º 6
0
        public void select_global()
        {
            double [] keys     = new double  [the_popualate.Count];
            int []    item_num = new int [the_popualate.Count];

            for (int i = 0; i < the_popualate.Count; i++)
            {
                item_num[i] = i;
                keys[i]     = the_popualate[i].error;
            }
            Array.Sort(keys, item_num);

            for (int i = 0; i < size_populate; i++)
            {
                Individ temp = the_popualate[i];
                the_popualate[i]           = the_popualate[item_num[i]];
                the_popualate[item_num[i]] = temp;
            }
            the_popualate.RemoveRange(size_populate, the_popualate.Count - size_populate);
        }