Exemplo n.º 1
0
        public override int Run(string[] args)
        {
            Console.WriteLine("Start");
            fill_params(args);
            Console.WriteLine("Params get \nfile in {0} \n", file_in);

            Class_learn_set = BaseUFSLoader.LoadLearnFromUFS(file_in);
            Console.WriteLine("Tra load");

            Class_test_set = BaseUFSLoader.LoadTestFromUFS(file_in);
            Console.WriteLine("Tst load");
            conf = new PSOBacterySearchConf();
            conf.Init(Class_learn_set.CountVars);
            conf.loadParams(confParams);
            Console.WriteLine("Conf Filed");

            Class_Pittsburg = new PCFuzzySystem(Class_learn_set, Class_test_set);
            Class_Pittsburg = PCFSUFSLoader.loadUFS(Class_Pittsburg, file_in);

            Console.WriteLine("Classifier created");
            optimaze        = new Term_config_PSO_Bactery();
            Class_Pittsburg = optimaze.TuneUpFuzzySystem(Class_Pittsburg, conf);
            Console.WriteLine("Optimization complite");
            PCFSUFSWriter.saveToUFS(Class_Pittsburg, file_out);
            Console.WriteLine("Saved");
            return(1);
        }
Exemplo n.º 2
0
        protected KnowlegeBasePCRules[] loadDatabase()
        {
            KnowlegeBasePCRules temp = result.RulesDatabaseSet[0];

            if (!Directory.Exists(PathAlgDestiny))
            {
                Directory.CreateDirectory(PathAlgDestiny);
            }

            string[] files = Directory.GetFiles(PathAlgDestiny, "*.ufs", SearchOption.AllDirectories);
            KnowlegeBasePCRules[] tempResult = new KnowlegeBasePCRules[files.Count()];

            for (int i = 0; i < files.Count(); i++)
            {
                result        = PCFSUFSLoader.loadUFS(result, files[i]);
                tempResult[i] = result.RulesDatabaseSet[0];
                File.Delete(files[i]);
            }

            result.RulesDatabaseSet[0] = temp;

            return(tempResult);
        }
Exemplo n.º 3
0
      protected KnowlegeBasePCRules[] loadDatabase()
      {
          KnowlegeBasePCRules temp = result.RulesDatabaseSet[0];
          string PathAlg           = (new FileInfo(Application.ExecutablePath)).DirectoryName + "\\FS\\fromBactery\\";

          if (!Directory.Exists(PathAlg))
          {
              Directory.CreateDirectory(PathAlg);
          }

          string[] files = Directory.GetFiles(PathAlg, "*.ufs", SearchOption.AllDirectories);
          KnowlegeBasePCRules[] tempResult = new KnowlegeBasePCRules[files.Count()];

          for (int i = 0; i < files.Count(); i++)
          {
              result        = PCFSUFSLoader.loadUFS(result, files[i]);
              tempResult[i] = result.RulesDatabaseSet[0];
              File.Delete(files[i]);
          }

          result.RulesDatabaseSet[0] = temp;

          return(tempResult);
      }
Exemplo n.º 4
0
        public void Calc()
        {
            DateTime   start__full_time = DateTime.Now;
            List <int> gen_index        = prepare_generate_to_Calc();
            List <int> leant_index      = prepare_learn_to_Calc();

            make_Log(Log_line.Start, TimerValue: start__full_time);
            int currentstep = 0;
            int all_step    = (Rules_generator.Count() + Learn_algorithms.Count() * Repeat_into) * Repeat_renew_global;

            currentstep = Make_inform_back_process(currentstep, all_step);

            //   Parallel.For(0, Repeat_renew_global, i =>
            for (int i = 0; i < Repeat_renew_global; i++)
            {
                Classifier = new PCFuzzySystem(Classifier_learn_set, Classifier_test_set);
                DateTime start__curle_time = DateTime.Now;
                #region Генерация аппроксиматора

                make_Log(Log_line.StartGenerate, TimerValue: start__curle_time);
                if (Rules_generator.Count() == 0 && (is_UFS))
                {
                    Classifier = PCFSUFSLoader.loadUFS(Classifier as PCFuzzySystem, UFS_file_name);
                }
                for (int ad = 0; ad < Rules_generator.Count(); ad++)
                {
                    make_Log(Log_line.PreGenerate_log, name_Alg: Rules_generator[ad].ToString());

                    Classifier =
                        Rules_generator[ad].Generate(Classifier, Rules_generator_conf[gen_index[ad]]);

                    currentstep = Make_inform_back_process(currentstep, all_step);

                    make_Log(Log_line.PostGenerate_log, Classifier as PCFuzzySystem, name_Alg: Rules_generator[ad].ToString(true));
                    if (is_autosave)
                    {
                        save_FS(Classifier as PCFuzzySystem, Name_alg: Rules_generator[ad].ToString());
                    }
                    GC.Collect();
                }

                #endregion

                make_Log(Log_line.StartOptimaze, Classifier as PCFuzzySystem);

                for (int j = 0; j < Repeat_into; j++)
                {
                    #region Оптимизация аппроксиматора
                    for (int l = 0; l < Learn_algorithms.Count(); l++)
                    {
                        make_Log(Log_line.PreOptimaze_log, name_Alg: Learn_algorithms[l].ToString());
                        Classifier =
                            Learn_algorithms[l].TuneUpFuzzySystem(Classifier, Learn_algorithm_conf[leant_index[l]]);

                        currentstep = Make_inform_back_process(currentstep, all_step);

                        make_Log(Log_line.PostOptimaze_log, FS: Classifier as PCFuzzySystem, name_Alg: Learn_algorithms[l].ToString(true));

                        if (is_autosave)
                        {
                            save_FS(Classifier as PCFuzzySystem, Learn_algorithms[l].ToString());
                        }
                        GC.Collect();
                    }
                    #endregion
                }
                make_Log(Log_line.EndCircle, TimerSpan: (DateTime.Now - start__curle_time));

                GC.Collect();
            }
            //  );
            make_Log(Log_line.End, TimerSpan: DateTime.Now - start__full_time);
        }
Exemplo n.º 5
0
 private void loadPCFSFromUFS()
 {
     FuzzySystem = PCFSUFSLoader.loadUFS(FuzzySystem as PCFuzzySystem, UFS_file_name);
 }