Пример #1
0
 public SAFuzzySystem(SAFuzzySystem Source)
     : base(Source)
 {
     RulesDatabaseSet = new List <KnowlegeBaseSARules>();
     for (int i = 0; i < Source.RulesDatabaseSet.Count; i++)
     {
         RulesDatabaseSet.Add(new KnowlegeBaseSARules(Source.RulesDatabaseSet[i]));
     }
 }
Пример #2
0
        public static double NearestApprox(SAFuzzySystem Approximate, List <Term> termSet)
        {
            double min_diff       = double.PositiveInfinity;
            int    min_diff_index = 0;

            for (int c = 0; c < Approximate.LearnSamplesSet.CountSamples; c++)
            {
                double current_diff = 0;
                for (int i = 0; i < termSet.Count; i++)
                {
                    if (Approximate.AcceptedFeatures[termSet[i].NumVar] == false)
                    {
                        continue;
                    }

                    if (termSet[i] != null)
                    {
                        switch (termSet[i].TermFuncType)
                        {
                        case TypeTermFuncEnum.Треугольник:
                            current_diff +=
                                Math.Abs(Approximate.LearnSamplesSet.DataRows[c].InputAttributeValue[termSet[i].NumVar] -
                                         termSet[i].Parametrs[1]);
                            break;

                        case TypeTermFuncEnum.Гауссоида: current_diff +=
                            Math.Abs(Approximate.LearnSamplesSet.DataRows[c].InputAttributeValue[termSet[i].NumVar] -
                                     termSet[i].Parametrs[0]);
                            break;

                        case TypeTermFuncEnum.Парабола:
                            double argv = (termSet[i].Parametrs[0] + termSet[i].Parametrs[1]) / 2;
                            current_diff +=
                                Math.Abs(Approximate.LearnSamplesSet.DataRows[c].InputAttributeValue[termSet[i].NumVar] -
                                         argv);
                            break;

                        case TypeTermFuncEnum.Трапеция: double argvTR = (termSet[i].Parametrs[1] + termSet[i].Parametrs[2]) / 2;
                            current_diff +=
                                Math.Abs(Approximate.LearnSamplesSet.DataRows[c].InputAttributeValue[termSet[i].NumVar] -
                                         argvTR);
                            break;
                        }
                    }
                }
                if (current_diff < min_diff)
                {
                    min_diff       = current_diff;
                    min_diff_index = c;
                }
            }
            return(Approximate.LearnSamplesSet.DataRows[min_diff_index].DoubleOutput);
        }
Пример #3
0
        public void constuct__and_add_the_Rule(List <Term> terms, SAFuzzySystem FS)
        {
            SARule Result;

            int[] order_of_terms = new int[terms.Count()];
            for (int i = 0; i < terms.Count(); i++)
            {
                order_of_terms[i] = TermsSet.Count;
                TermsSet.Add(terms[i]);
            }
            double kons_Value = KNNConsequent.NearestApprox(FS, TermsSet);

            Result = new SARule(TermsSet, order_of_terms, kons_Value);
            RulesDatabase.Add(Result);
        }
Пример #4
0
 public static double NearestApprox(SAFuzzySystem Approximate, TermSetGlobal <Term> termSet)
 {
     return(NearestApprox(Approximate, termSet.ToList()));
 }
Пример #5
0
        public override FuzzySystem.SingletoneApproximate.SAFuzzySystem TuneUpFuzzySystem(FuzzySystem.SingletoneApproximate.SAFuzzySystem Approximate, ILearnAlgorithmConf conf)
        {
            result = Approximate;
            Init(conf);

            Ocean = new SingletonHybride(new SAFuzzySystem(result));


            List <Task> AlgTasks = new List <Task>();



            Parallel.For(0, Configs.Count, magic =>


            {
                Task CurrentTask = new Task(() => { Algorithms[magic].TuneUpFuzzySystem(Ocean, new SAFuzzySystem(result), Configs[magic]); });
                AlgTasks.Add(CurrentTask);

                AlgTasks[magic].Start();
            }
                         );
            Task.WaitAll(AlgTasks.ToArray());
            List <KnowlegeBaseSARules> ListSystems = Ocean.Get(1, FuzzySystem.FuzzyAbstract.Hybride.FuzzyHybrideBase.goodness.best, FuzzySystem.FuzzyAbstract.Hybride.FuzzyHybrideBase.islandStrategy.All);

            ListSystems.Add(result.RulesDatabaseSet[0]);

            result.RulesDatabaseSet[0] = ListSystems.SelectBest(result, 1)[0];
            result.RulesDatabaseSet[0].TermsSet.Trim();
            return(result);
        }