Ejemplo n.º 1
0
        public Knowlege_base_ARules(Knowlege_base_ARules source, List <bool> used_rules = null)
        {
            for (int i = 0; i < source.Terms_Set.Count; i++)
            {
                Term temp_term = new Term(source.terms_set[i]);
                terms_set.Add(temp_term);
            }


            for (int j = 0; j < source.Rules_Database.Count; j++)
            {
                if ((used_rules == null) || (used_rules[j]))
                {
                    int[] order = new int[source.arules_database[j].Term_of_Rule_Set.Count];
                    for (int k = 0; k < source.arules_database[j].Term_of_Rule_Set.Count; k++)
                    {
                        Term temp_term = source.arules_database[j].Term_of_Rule_Set[k];
                        order[k] = source.Terms_Set.FindIndex(x => x == temp_term);
                    }
                    double temp_approx_Values = source.arules_database[j].Kons_approx_Value;
                    ARule  temp_rule          = new ARule(terms_set, order, temp_approx_Values);
                    arules_database.Add(temp_rule);
                }
            }
        }
Ejemplo n.º 2
0
        public void constuct__and_add_the_Rule(List <Term> terms, a_Fuzzy_System FS)
        {
            ARule Result;

            int[] order_of_terms = new int[terms.Count()];
            for (int i = 0; i < terms.Count(); i++)
            {
                order_of_terms[i] = terms_set.Count;
                terms_set.Add(terms[i]);
            }
            double kons_Value = FS.Nearest_Approx(terms_set);

            Result = new ARule(terms_set, order_of_terms, kons_Value);
            arules_database.Add(Result);
        }
Ejemplo n.º 3
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