Changeset 8866
- Timestamp:
- 11/02/12 16:21:51 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/CrossoverPerformanceAnalyzer.cs
r8865 r8866 80 80 81 81 [Storable] 82 private ScatterPlotHelper plotHelper, childDiversityToWorseParentHelper, childDiversityToBetterParentHelper, parentDiversityHelper, parentQualityHelper;83 [Storable] 84 private DataTableHelper performanceHelper,successHelper, equalParentsHelper;82 private ScatterPlotHelper worseParentCrossoverPerformancePlot, betterParentCrossoverPerformancePlot, childDiversityToWorseParentHelper, childDiversityToBetterParentHelper, parentDiversityHelper, parentQualityHelper; 83 [Storable] 84 private DataTableHelper successHelper, equalParentsHelper; 85 85 [Storable] 86 86 private int cnt = 0; … … 91 91 [Storable] 92 92 private int equalParents = 0; 93 [Storable]94 private List<double> qualityPoints = new List<double>();95 93 96 94 [StorableConstructor] … … 102 100 lastGeneration = original.lastGeneration; 103 101 equalParents = original.equalParents; 104 qualityPoints = new List<double>(original.qualityPoints);105 plotHelper = (ScatterPlotHelper)original.plotHelper.Clone(cloner);102 worseParentCrossoverPerformancePlot = (ScatterPlotHelper)original.worseParentCrossoverPerformancePlot.Clone(cloner); 103 betterParentCrossoverPerformancePlot = (ScatterPlotHelper)original.betterParentCrossoverPerformancePlot.Clone(cloner); 106 104 childDiversityToWorseParentHelper = (ScatterPlotHelper)original.childDiversityToWorseParentHelper.Clone(cloner); 107 105 childDiversityToBetterParentHelper = (ScatterPlotHelper)original.childDiversityToBetterParentHelper.Clone(cloner); 108 106 parentDiversityHelper = (ScatterPlotHelper)original.parentDiversityHelper.Clone(cloner); 109 107 parentQualityHelper = (ScatterPlotHelper)original.parentQualityHelper.Clone(cloner); 110 performanceHelper = (DataTableHelper)original.performanceHelper.Clone(cloner);111 108 successHelper = (DataTableHelper)original.successHelper.Clone(cloner); 112 109 equalParentsHelper = (DataTableHelper)original.equalParentsHelper.Clone(cloner); … … 136 133 137 134 138 plotHelper = new ScatterPlotHelper(false, true); 135 worseParentCrossoverPerformancePlot = new ScatterPlotHelper(false, true); 136 betterParentCrossoverPerformancePlot = new ScatterPlotHelper(false, true); 139 137 childDiversityToWorseParentHelper = new ScatterPlotHelper(false, true); 140 138 childDiversityToBetterParentHelper = new ScatterPlotHelper(false, true); 141 139 parentDiversityHelper = new ScatterPlotHelper(false, true); 142 140 parentQualityHelper = new ScatterPlotHelper(false, true); 143 performanceHelper = new DataTableHelper();144 141 successHelper = new DataTableHelper(); 145 142 equalParentsHelper = new DataTableHelper(); … … 167 164 } 168 165 169 plotHelper.InitializePlot(Results, "Crossover Performance", "Solution Index", "Absolut Quality Difference"); 166 worseParentCrossoverPerformancePlot.InitializePlot(Results, "Crossover Performance compared to worse parent", "Solution Index", "Absolut Quality Difference"); 167 betterParentCrossoverPerformancePlot.InitializePlot(Results, "Crossover Performance compared to better parent", "Solution Index", "Absolut Quality Difference"); 170 168 childDiversityToWorseParentHelper.InitializePlot(Results, "Child Diversity to Worse Parent", "Solution Index", "Diversity"); 171 169 childDiversityToBetterParentHelper.InitializePlot(Results, "Child Diversity to Better Parent", "Solution Index", "Diversity"); 172 170 parentDiversityHelper.InitializePlot(Results, "Parent Diversity", "Solution Index", "Diversity"); 173 171 parentQualityHelper.InitializePlot(Results, "Parent Quality Difference", "Solution Index", "Absolut Quality Difference"); 174 performanceHelper.InitializeChart(Results, "Average Crossover Performance", new string[] { "Average Crossover Performance per Generation" });175 172 equalParentsHelper.InitializeChart(Results, "Number of equal parents", new string[] { "Absolut number of equal parents" }); 176 173 … … 186 183 Initialize(); 187 184 188 Point2D<double> qualityPoint, childDiversityToWorseParent, childDiversityToBetterParent, diversityPointParent, qualityPointParent;185 Point2D<double> worseQualityPoint, betterQualityPoint, childDiversityToWorseParent, childDiversityToBetterParent, diversityPointParent, qualityPointParent; 189 186 var parent1 = ParentsParameter.ActualValue.First(); 190 187 var parent2 = ParentsParameter.ActualValue.Last(); … … 200 197 qualityPointParent = new Point2D<double>(cnt, Math.Abs(qualityParent1 - qualityParent2)); 201 198 199 200 double worseQuality, betterQuality; 201 202 202 if (qualityParent1 > qualityParent2) { 203 203 if (MaximizationParameter.ActualValue.Value) { 204 204 childDiversityToWorseParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.Last())); 205 205 childDiversityToBetterParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.First())); 206 worseQuality = qualityParent2; 207 betterQuality = qualityParent1; 206 208 } else { 207 209 childDiversityToWorseParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.First())); 208 210 childDiversityToBetterParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.Last())); 211 worseQuality = qualityParent1; 212 betterQuality = qualityParent2; 209 213 } 210 214 } else { … … 212 216 childDiversityToWorseParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.First())); 213 217 childDiversityToBetterParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.Last())); 218 worseQuality = qualityParent1; 219 betterQuality = qualityParent2; 214 220 } else { 215 221 childDiversityToWorseParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.Last())); 216 222 childDiversityToBetterParent = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.First())); 217 } 218 } 219 220 double worseQuality = qualityParent1 > qualityParent2 ? qualityParent1 : qualityParent2; 221 qualityPoint = new Point2D<double>(cnt++, worseQuality - qualityChild); 222 qualityPoints.Add(qualityPoint.Y); 223 223 worseQuality = qualityParent2; 224 betterQuality = qualityParent1; 225 } 226 } 227 228 worseQualityPoint = new Point2D<double>(cnt, worseQuality - qualityChild); 229 betterQualityPoint = new Point2D<double>(cnt++, betterQuality - qualityChild); 230 231 if (GenerationsParameter.ActualValue.Value == lastGeneration) { 232 CountSuccess(qualityChild, qualityParent1, qualityParent2); 233 234 if (parentDiversity == 1.0) { 235 equalParents++; 236 } 237 } 238 239 if (GenerationsParameter.ActualValue.Value != 0) { 240 if (GenerationsParameter.ActualValue.Value > lastGeneration) { 241 equalParentsHelper.AddPoint(equalParents); 242 243 for (int i = 0; i < ComparisonFactorParameter.Value.Count; i++) { 244 successHelper.AddPoint(SuccessfullCrossoversRowName + ComparisonFactorParameter.Value.ElementAt(i).Value.ToString(), success[i]); 245 } 246 247 Reset(); 248 249 CountSuccess(qualityChild, qualityParent1, qualityParent2); 250 if (parentDiversity == 1.0) { 251 equalParents++; 252 } 253 } 254 255 betterParentCrossoverPerformancePlot.AddPoint(curGenStr, betterQualityPoint); 256 worseParentCrossoverPerformancePlot.AddPoint(curGenStr, worseQualityPoint); 257 childDiversityToWorseParentHelper.AddPoint(curGenStr, childDiversityToWorseParent); 258 childDiversityToBetterParentHelper.AddPoint(curGenStr, childDiversityToBetterParent); 259 parentDiversityHelper.AddPoint(curGenStr, diversityPointParent); 260 parentQualityHelper.AddPoint(curGenStr, qualityPointParent); 261 } 262 263 return base.Apply(); 264 } 265 266 private void CountSuccess(double qualityChild, double qualityParent1, double qualityParent2) { 224 267 //track successfull cx 225 268 var compFactsArray = ComparisonFactorParameter.Value.ToArray(); … … 229 272 } 230 273 } 231 232 if (parentDiversity == 1.0) {233 equalParents++;234 }235 236 if (GenerationsParameter.ActualValue.Value != 0) {237 if (GenerationsParameter.ActualValue.Value > lastGeneration) {238 double avg = qualityPoints.Average();239 240 performanceHelper.AddPoint(avg);241 equalParentsHelper.AddPoint(equalParents);242 243 for (int i = 0; i < compFactsArray.Length; i++) {244 successHelper.AddPoint(SuccessfullCrossoversRowName + compFactsArray[i].Value.ToString(), success[i]);245 }246 247 Reset();248 }249 250 plotHelper.AddPoint(curGenStr, qualityPoint);251 childDiversityToWorseParentHelper.AddPoint(curGenStr, childDiversityToWorseParent);252 childDiversityToBetterParentHelper.AddPoint(curGenStr, childDiversityToBetterParent);253 parentDiversityHelper.AddPoint(curGenStr, diversityPointParent);254 parentQualityHelper.AddPoint(curGenStr, qualityPointParent);255 }256 257 return base.Apply();258 274 } 259 275 … … 262 278 success = new int[ComparisonFactorParameter.Value.Count]; 263 279 lastGeneration = GenerationsParameter.ActualValue.Value; 264 qualityPoints.Clear();265 280 equalParents = 0; 266 281 }
Note: See TracChangeset
for help on using the changeset viewer.