Changeset 13495
- Timestamp:
- 01/11/16 21:26:00 (9 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs
r13482 r13495 314 314 } 315 315 // update qualities for intermediate vertices 316 if (!TrimOlderGenerations) 317 EvaluateIntermediateChildren(); 316 EvaluateIntermediateChildren(); 318 317 319 318 // remove extra graph nodes (added by the instrumented operators in the case of offspring selection) -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisGeneticOperatorImprovementAnalyzer.cs
r12966 r13495 105 105 var vertices = population.Select(graph.GetByContent).ToList(); 106 106 DataTable table; 107 double aac = 0; // ratio of above average children produced108 double aacp = 0; // ratio of above average children from above average parents109 107 #region crossover improvement 110 108 if (!Results.ContainsKey("Crossover improvement")) { 111 109 table = new DataTable("Crossover improvement"); 112 110 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 }); 123 117 } else { 124 118 table = (DataTable)Results["Crossover improvement"].Value; … … 128 122 crossoverChildren.AddRange(vertices.Where(x => x.InDegree == 1).Select(v => v.Parents.First()).Where(p => p.Rank.IsAlmost(generation - 0.5))); // add intermediate children 129 123 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); 149 134 #endregion 150 135 … … 153 138 table = new DataTable("Mutation improvement"); 154 139 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 }); 162 146 } else { 163 147 table = (DataTable)Results["Mutation improvement"].Value; 164 148 } 165 149 166 aac = 0;167 aacp = 0;168 150 var mutationChildren = vertices.Where(x => x.InDegree == 1).ToList(); 169 151 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); 179 154 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 184 163 #endregion 185 164 return base.Apply(); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/Analyzers/SymbolicDataAnalysisFragmentLengthAnalyzer.cs
r12156 r13495 61 61 updateCounter.Value = 1; 62 62 63 if (PopulationGraph == null )63 if (PopulationGraph == null || Generation.Value == 0) 64 64 return base.Apply(); 65 65 66 var children = PopulationGraph.GetByRank(Generation.Value).Where(x => x.InDegree > 0).ToList(); 67 double avgFragmentLength = 0; 68 if (children.Any()) 69 avgFragmentLength = children.Select(x => (IFragment<ISymbolicExpressionTreeNode>)x.InArcs.Last().Data).Where(f => f != null).Average(x => x.Root.GetLength()); 66 // consider all fragments (including those of the intermediate crossover children) 67 double averageCrossoverFragmentLength = 0; 68 double averageMutationFragmentLength = 0; 69 int crossoverChildren = 0; 70 int mutationChildren = 0; 71 72 var vertices = PopulationGraph.Vertices.Where(x => x.Rank > Generation.Value - 1); 73 foreach (var v in vertices) { 74 if (!v.InArcs.Any() || v.InArcs.Last().Data == null) 75 continue; 76 var fragment = (IFragment<ISymbolicExpressionTreeNode>)v.InArcs.Last().Data; 77 if (v.InDegree == 2) { 78 averageCrossoverFragmentLength += fragment.Root.GetLength(); 79 crossoverChildren++; 80 } else { 81 averageMutationFragmentLength += fragment.Root.GetLength(); 82 mutationChildren++; 83 } 84 } 85 var averageFragmentLength = (averageCrossoverFragmentLength + averageMutationFragmentLength) / (crossoverChildren + mutationChildren); 86 averageCrossoverFragmentLength /= crossoverChildren; 87 averageMutationFragmentLength /= mutationChildren; 70 88 71 89 DataTable table; … … 73 91 table = new DataTable("Average fragment length"); 74 92 var row = new DataRow("Average fragment length") { VisualProperties = { StartIndexZero = true } }; 75 row.Values.Add(avgFragmentLength); 93 row.Values.Add(averageFragmentLength); 94 table.Rows.Add(row); 95 row = new DataRow("Average crossover fragment length") { VisualProperties = { StartIndexZero = true } }; 96 row.Values.Add(averageCrossoverFragmentLength); 97 table.Rows.Add(row); 98 row = new DataRow("Average mutation fragment length") { VisualProperties = { StartIndexZero = true } }; 99 row.Values.Add(averageMutationFragmentLength); 76 100 table.Rows.Add(row); 77 101 Results.Add(new Result("AverageFragmentLength", table)); 78 102 } else { 79 103 table = (DataTable)Results["AverageFragmentLength"].Value; 80 table.Rows["Average fragment length"].Values.Add(avgFragmentLength); 104 table.Rows["Average fragment length"].Values.Add(averageFragmentLength); 105 table.Rows["Average crossover fragment length"].Values.Add(averageCrossoverFragmentLength); 106 table.Rows["Average mutation fragment length"].Values.Add(averageMutationFragmentLength); 81 107 } 82 108 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.