示例#1
0
        public void Init_Rules_everyone_with_everyone(Type_Term_Func_Enum type_func, int[] count_slice__for_var)
        {
            if (Count_Rulles_Databases == 0)
            {
                Knowlege_base_ARules temp_rules = new Knowlege_base_ARules();
                rulles_database_set.Add(temp_rules);
            }
            int[][] position_of_terms = new int[Count_Vars][];
            for (int i = 0; i < Count_Vars; i++)
            {
                position_of_terms[i] = new int[count_slice__for_var[i]];
                double current_value = learn_samples_set.Attribute_Min(i);
                double coeef         = (learn_samples_set.Attribute_Scatter(i)) /
                                       (count_slice__for_var[i] - 1);
                for (int j = 0; j < count_slice__for_var[i]; j++)
                {
                    double[] parametrs = new double[Member_Function.Count_Params_For_Term(type_func)];
                    switch (type_func)
                    {
                    case Type_Term_Func_Enum.Треугольник:
                        parametrs[1] = current_value;
                        parametrs[0] = parametrs[1] - coeef;
                        parametrs[2] = parametrs[1] + coeef;
                        break;

                    case Type_Term_Func_Enum.Гауссоида:
                        parametrs[0] = current_value;
                        parametrs[1] = coeef / 3;

                        break;

                    case Type_Term_Func_Enum.Парабола:
                        parametrs[0] = current_value - coeef;
                        parametrs[1] = current_value + coeef;

                        break;

                    case Type_Term_Func_Enum.Трапеция:
                        parametrs[0] = current_value - coeef;
                        parametrs[3] = current_value + coeef;
                        parametrs[1] = parametrs[0] + 0.4 * (parametrs[3] - parametrs[0]);
                        parametrs[2] = parametrs[0] + 0.6 * (parametrs[3] - parametrs[0]);

                        break;
                    }
                    Term temp_term = new Term(parametrs, type_func, i);
                    rulles_database_set[0].Terms_Set.Add(temp_term);
                    position_of_terms[i][j] = rulles_database_set[0].Terms_Set.Count - 1;

                    current_value += coeef;
                }
            }

            int[] counter = new int[Count_Vars];
            for (int i = 0; i < Count_Vars; i++)
            {
                counter[i] = count_slice__for_var[i] - 1;
            }
            while (counter[0] >= 0)
            {
                List <Term> temp_term_set = new List <Term>();
                int[]       order         = new int[Count_Vars];
                for (int i = 0; i < Count_Vars; i++)
                {
                    temp_term_set.Add(rulles_database_set[0].Terms_Set[position_of_terms[i][counter[i]]]);
                    order[i] = position_of_terms[i][counter[i]];
                }
                double approx_Values = Nearest_Approx(temp_term_set);

                ARule temp_rule = new ARule(rulles_database_set[0].Terms_Set, order, approx_Values);
                rulles_database_set[0].Rules_Database.Add(temp_rule);
                counter = dec_count(counter, count_slice__for_var);
            }
        } //Core init method