Ignore:
Timestamp:
01/11/16 21:26:00 (5 years ago)
Author:
bburlacu
Message:

#1772: Improve the average operator improvement and average fragment length analyzers. Update genealogy analyzer to always evaluate the intermediate children.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisGeneticOperatorImprovementAnalyzer.cs

    r12966 r13495  
    105105      var vertices = population.Select(graph.GetByContent).ToList();
    106106      DataTable table;
    107       double aac = 0; // ratio of above average children produced
    108       double aacp = 0; // ratio of above average children from above average parents
    109107      #region crossover improvement
    110108      if (!Results.ContainsKey("Crossover improvement")) {
    111109        table = new DataTable("Crossover improvement");
    112110        Results.Add(new Result("Crossover improvement", table));
    113         table.Rows.AddRange(new[]
    114           {
    115               new DataRow("Average crossover improvement (root parent)") { VisualProperties = { StartIndexZero = true } },
    116               new DataRow("Average crossover improvement (non-root parent)") { VisualProperties = { StartIndexZero = true } },
    117               new DataRow("Average child-parents quality difference") { VisualProperties = { StartIndexZero = true } },
    118               new DataRow("Best crossover improvement (root parent)") { VisualProperties = { StartIndexZero = true } },
    119               new DataRow("Best crossover improvement (non-root parent)") { VisualProperties = { StartIndexZero = true }},
    120               new DataRow("Above average children") { VisualProperties = { StartIndexZero = true }},
    121               new DataRow("Above average children from above average parents") { VisualProperties = { StartIndexZero = true } },
    122             });
     111        table.Rows.AddRange(new[] {
     112          new DataRow("Average crossover child quality") { VisualProperties = { StartIndexZero = true } },
     113          new DataRow("Average crossover parent quality") { VisualProperties = { StartIndexZero = true } },
     114          new DataRow("Best crossover child quality") { VisualProperties = { StartIndexZero = true } },
     115          new DataRow("Best crossover parent quality") { VisualProperties = { StartIndexZero = true } },
     116        });
    123117      } else {
    124118        table = (DataTable)Results["Crossover improvement"].Value;
     
    128122        crossoverChildren.AddRange(vertices.Where(x => x.InDegree == 1).Select(v => v.Parents.First()).Where(p => p.Rank.IsAlmost(generation - 0.5))); // add intermediate children
    129123
    130       foreach (var c in crossoverChildren) {
    131         if (c.Quality > averageQuality) {
    132           aac++;
    133           if (c.Parents.All(x => x.Quality > averageQuality))
    134             aacp++;
    135         }
    136       }
    137       var avgRootParentQualityImprovement = crossoverChildren.Average(x => x.Quality - x.Parents.First().Quality);
    138       var avgNonRootParentQualityImprovement = crossoverChildren.Average(x => x.Quality - x.Parents.Last().Quality);
    139       var avgChildParentQuality = crossoverChildren.Average(x => x.Quality - x.Parents.Average(p => p.Quality));
    140       var bestRootParentQualityImprovement = crossoverChildren.Max(x => x.Quality - x.Parents.First().Quality);
    141       var bestNonRootParentQualityImprovement = crossoverChildren.Max(x => x.Quality - x.Parents.Last().Quality);
    142       table.Rows["Average crossover improvement (root parent)"].Values.Add(avgRootParentQualityImprovement);
    143       table.Rows["Average crossover improvement (non-root parent)"].Values.Add(avgNonRootParentQualityImprovement);
    144       table.Rows["Best crossover improvement (root parent)"].Values.Add(bestRootParentQualityImprovement);
    145       table.Rows["Best crossover improvement (non-root parent)"].Values.Add(bestNonRootParentQualityImprovement);
    146       table.Rows["Average child-parents quality difference"].Values.Add(avgChildParentQuality);
    147       table.Rows["Above average children"].Values.Add(aac / populationSize);
    148       table.Rows["Above average children from above average parents"].Values.Add(aacp / populationSize);
     124      var avgCrossoverParentQuality = crossoverChildren.SelectMany(x => x.Parents).Average(x => x.Quality);
     125      var avgCrossoverChildQuality = crossoverChildren.Average(x => x.Quality);
     126
     127      var bestCrossoverChildQuality = crossoverChildren.OrderBy(x => x.Quality).Last().Quality;
     128      var bestCrossoverParentQuality = crossoverChildren.OrderBy(x => x.Quality).Last().Parents.First().Quality;
     129
     130      table.Rows["Average crossover child quality"].Values.Add(avgCrossoverChildQuality);
     131      table.Rows["Average crossover parent quality"].Values.Add(avgCrossoverParentQuality);
     132      table.Rows["Best crossover child quality"].Values.Add(bestCrossoverChildQuality);
     133      table.Rows["Best crossover parent quality"].Values.Add(bestCrossoverParentQuality);
    149134      #endregion
    150135
     
    153138        table = new DataTable("Mutation improvement");
    154139        Results.Add(new Result("Mutation improvement", table));
    155         table.Rows.AddRange(new[]
    156           {
    157               new DataRow("Average mutation improvement") { VisualProperties = { StartIndexZero = true } },
    158               new DataRow("Best mutation improvement") { VisualProperties = { StartIndexZero = true } },
    159               new DataRow("Above average children") { VisualProperties = { StartIndexZero = true } },
    160               new DataRow("Above average children from above average parents") { VisualProperties = { StartIndexZero = true } },
    161             });
     140        table.Rows.AddRange(new[] {
     141          new DataRow("Average mutation child quality") { VisualProperties = { StartIndexZero = true } },
     142          new DataRow("Average mutation parent quality") { VisualProperties = { StartIndexZero = true } },
     143          new DataRow("Best mutation child quality") { VisualProperties = { StartIndexZero = true } },
     144          new DataRow("Best mutation parent quality") { VisualProperties = { StartIndexZero = true } },
     145        });
    162146      } else {
    163147        table = (DataTable)Results["Mutation improvement"].Value;
    164148      }
    165149
    166       aac = 0;
    167       aacp = 0;
    168150      var mutationChildren = vertices.Where(x => x.InDegree == 1).ToList();
    169151
    170       foreach (var c in mutationChildren) {
    171         if (c.Quality > averageQuality) {
    172           aac++;
    173           if (c.Parents.All(x => x.Quality > averageQuality))
    174             aacp++;
    175         }
    176       }
    177       var avgMutationImprovement = mutationChildren.Average(x => x.Quality - x.Parents.First().Quality);
    178       var bestMutationImprovement = mutationChildren.Max(x => x.Quality - x.Parents.First().Quality);
     152      var avgMutationParentQuality = mutationChildren.SelectMany(x => x.Parents).Average(x => x.Quality);
     153      var avgMutationChildQuality = mutationChildren.Average(x => x.Quality);
    179154
    180       table.Rows["Average mutation improvement"].Values.Add(avgMutationImprovement);
    181       table.Rows["Best mutation improvement"].Values.Add(bestMutationImprovement);
    182       table.Rows["Above average children"].Values.Add(aac / populationSize);
    183       table.Rows["Above average children from above average parents"].Values.Add(aacp / populationSize);
     155      var bestMutationChildQuality = mutationChildren.OrderBy(x => x.Quality).Last().Quality;
     156      var bestMutationParentQuality = mutationChildren.OrderBy(x => x.Quality).Last().Parents.First().Quality;
     157
     158      table.Rows["Average mutation child quality"].Values.Add(avgMutationChildQuality);
     159      table.Rows["Average mutation parent quality"].Values.Add(avgMutationParentQuality);
     160      table.Rows["Best mutation child quality"].Values.Add(bestMutationChildQuality);
     161      table.Rows["Best mutation parent quality"].Values.Add(bestMutationParentQuality);
     162
    184163      #endregion
    185164      return base.Apply();
Note: See TracChangeset for help on using the changeset viewer.