Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/23/13 13:31:29 (12 years ago)
Author:
sforsten
Message:

#1980:

  • several small bug fixes
  • added windowing technique ILAS to GAssist
  • GAssist and XCS work now with real-valued features
  • severely improved the performance of XCS
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/LearningClassifierSystems/HeuristicLab.Optimization.Operators.LCS/3.3/Selection/NichingTournamentSelector.cs

    r9352 r9392  
    8888
    8989      int parentsPerChild = ParentsPerChildParameter.ActualValue.Value;
    90       var possibleNiches = GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches().ToList();
    91       var selectPerNiche = new Dictionary<IGAssistNiche, int>(possibleNiches.First().Comparer);
     90      var nicheComparer = GAssistNichesProblemDataParameter.ActualValue.GetPossibleNiches().First().Comparer;
     91      var selectPerNiche = new Dictionary<IGAssistNiche, int>(nicheComparer);
     92      var nicheScope = new Dictionary<IGAssistNiche, List<int>>(nicheComparer);
    9293
    93       var nicheScope = new Dictionary<IGAssistNiche, List<int>>(possibleNiches.First().Comparer);
    94       foreach (var niche in possibleNiches) {
    95         nicheScope.Add(niche, new List<int>());
    96         selectPerNiche.Add(niche, count / possibleNiches.Count);
     94      for (int i = 0; i < individuals.Count; i++) {
     95        if (!nicheScope.ContainsKey(individuals[i].Niche)) {
     96          nicheScope.Add(individuals[i].Niche, new List<int>());
     97        }
     98        nicheScope[individuals[i].Niche].Add(i);
    9799      }
    98100
    99       for (int i = 0; i < individuals.Count; i++) {
    100         nicheScope[individuals[i].Niche].Add(i);
     101      var possibleNiches = nicheScope.Keys.ToList();
     102      foreach (var niche in possibleNiches) {
     103        selectPerNiche.Add(niche, count / possibleNiches.Count);
    101104      }
    102105
     
    144147    }
    145148
    146     private IGAssistNiche GetNiche(IRandom random, Dictionary<IGAssistNiche, int> nicheScope, List<IGAssistNiche> possibleNiches) {
    147       int sum = nicheScope.Values.Sum();
     149    private IGAssistNiche GetNiche(IRandom random, Dictionary<IGAssistNiche, int> selectPerNiche, List<IGAssistNiche> possibleNiches) {
     150      int sum = selectPerNiche.Values.Sum();
    148151      if (sum <= 0) { return possibleNiches[random.Next(possibleNiches.Count)]; }
    149152      int pos = random.Next(sum);
    150153      int total = 0;
    151       IGAssistNiche niche = nicheScope.Keys.First();
    152       foreach (var item in nicheScope) {
     154      IGAssistNiche niche = selectPerNiche.Keys.First();
     155      foreach (var item in selectPerNiche) {
    153156        total += item.Value;
    154157        niche = item.Key;
Note: See TracChangeset for help on using the changeset viewer.