public override TSAFuzzySystem Generate(TSAFuzzySystem Approximate, IGeneratorConf config) { TSAFuzzySystem result = Approximate; if (result.RulesDatabaseSet.Count == 0) { AbstractNotSafeGenerator tempGen = new GeneratorRulesEveryoneWithEveryone(); result = tempGen.Generate(result, config); GC.Collect(); } count_shrink = ((TermShrinkAndRotateConf)config).TSARCShrinkVars; size_shrink = ((TermShrinkAndRotateConf)config).TSARCShrinkTerm; type_func = ((TermShrinkAndRotateConf)config).IEWEFuncType; count_slices = ((TermShrinkAndRotateConf)config).IEWECountSlice; List <int> Varians_of_run_system = new List <int>(); for (int i = 0; i < Approximate.CountFeatures; i++) { int count_terms_for_var = Approximate.RulesDatabaseSet[0].TermsSet.FindAll(x => x.NumVar == i).Count; if (i < count_shrink) { Varians_of_run_system.Add(count_terms_for_var - size_shrink); } else { Varians_of_run_system.Add(count_terms_for_var); } } Varians_of_run_system.Sort(); TypeTermFuncEnum type_of_term = Approximate.RulesDatabaseSet[0].TermsSet[0].TermFuncType; Generate_all_variant_in_pool(Varians_of_run_system); for (int i = 0; i < Pull_of_systems.Count; i++) { Approximate.RulesDatabaseSet.Clear(); GeneratorRulesEveryoneWithEveryone.InitRulesEveryoneWithEveryone(Approximate, type_of_term, Pull_of_systems[i].ToArray()); Systems_ready_to_test.Add(Approximate.RulesDatabaseSet[0]); errors_of_systems.Add(result.approxLearnSamples(result.RulesDatabaseSet[0])); } int best_index = errors_of_systems.IndexOf(errors_of_systems.Min()); result.RulesDatabaseSet.Clear(); result.RulesDatabaseSet.Add(Systems_ready_to_test[best_index]); Console.WriteLine(Pull_of_systems.Count()); GC.Collect(); // result.UnlaidProtectionFix(); result.RulesDatabaseSet[0].TermsSet.Trim(); return(result); }
public override TSAFuzzySystem Generate(TSAFuzzySystem Approximate, IGeneratorConf config) { start_add_rules = Approximate.RulesDatabaseSet.Count; TSAFuzzySystem result = Approximate; if (result.RulesDatabaseSet.Count == 0) { AbstractNotSafeGenerator tempGen = new GeneratorRulesEveryoneWithEveryone(); result = tempGen.Generate(result, config); GC.Collect(); } Request_count_rules = ((RullesShrinkConf)config).RSCCountRules; max_count_rules = ((RullesShrinkConf)config).RSCMaxRules; count_slices = ((RullesShrinkConf)config).IEWECountSlice; min_count_rules = ((RullesShrinkConf)config).RSCMinRules; type_term = ((RullesShrinkConf)config).IEWEFuncType; int count_of_swith_off = ((RullesShrinkConf)config).RSCMaxRules - Request_count_rules; List <byte> Varians_of_run_system = new List <byte>(); for (int i = 0; i < Approximate.RulesDatabaseSet[0].RulesDatabase.Count; i++) { Varians_of_run_system.Add(1); } for (int i = 0; i < count_of_swith_off; i++) { Varians_of_run_system[i] = 0; } Generate_all_variant_in_pool(Varians_of_run_system); for (int i = 0; i < Pull_of_systems.Count; i++) { KnowlegeBaseTSARules temp_rules = new KnowlegeBaseTSARules(result.RulesDatabaseSet[0], Pull_of_systems[i]); temp_rules.TrimTerms(); result.RulesDatabaseSet.Add(temp_rules); result.UnlaidProtectionFix(result.RulesDatabaseSet[start_add_rules + i]); errors_of_systems.Add(result.approxLearnSamples(result.RulesDatabaseSet [start_add_rules + i])); } int best_index = errors_of_systems.IndexOf(errors_of_systems.Min()); KnowlegeBaseTSARules best = result.RulesDatabaseSet[start_add_rules + best_index]; result.RulesDatabaseSet.Clear(); result.RulesDatabaseSet.Add(best); Console.WriteLine(Pull_of_systems.Count()); GC.Collect(); // result.UnlaidProtectionFix(); result.RulesDatabaseSet[0].TermsSet.Trim(); return(result); }