Changeset 8867
- Timestamp:
- 11/04/12 23:11:01 (12 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/CrossoverPerformanceAnalyzer.cs
r8866 r8867 35 35 [Item("CrossoverPerformanceAnalyzer", "An operator that analyzes the performance of crossovers.")] 36 36 [StorableClass] 37 public class CrossoverPerformanceAnalyzer : InitializableOperator {37 public class CrossoverPerformanceAnalyzer : InitializableOperator, IStatefulItem { 38 38 private const string ResultsParameterName = "Results"; 39 39 private const string GenerationsParameterName = "Generations"; … … 226 226 } 227 227 228 worseQualityPoint = new Point2D<double>(cnt, worseQuality - qualityChild);229 betterQualityPoint = new Point2D<double>(cnt++, betterQuality - qualityChild);228 worseQualityPoint = new Point2D<double>(cnt, Math.Abs(worseQuality - qualityChild)); 229 betterQualityPoint = new Point2D<double>(cnt++, Math.Abs(betterQuality - qualityChild)); 230 230 231 231 if (GenerationsParameter.ActualValue.Value == lastGeneration) { … … 280 280 equalParents = 0; 281 281 } 282 283 public override void ClearState() { 284 betterParentCrossoverPerformancePlot.CleanUp(); 285 worseParentCrossoverPerformancePlot.CleanUp(); 286 childDiversityToWorseParentHelper.CleanUp(); 287 childDiversityToBetterParentHelper.CleanUp(); 288 parentDiversityHelper.CleanUp(); 289 parentQualityHelper.CleanUp(); 290 } 282 291 } 283 292 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/MutationPerformanceAnalyzer.cs
r8797 r8867 21 21 22 22 23 using System.Collections.Generic;24 23 using System.Linq; 25 24 using HeuristicLab.Common; … … 27 26 using HeuristicLab.Data; 28 27 using HeuristicLab.Encodings.PermutationEncoding; 29 using HeuristicLab.Operators;30 28 using HeuristicLab.Optimization; 31 29 using HeuristicLab.Parameters; … … 35 33 [Item("MutationPerformanceAnalyzer", "An operator that analyzes the performance of mutation.")] 36 34 [StorableClass] 37 public class MutationPerformanceAnalyzer : SingleSuccessorOperator, IAnalyzer{35 public class MutationPerformanceAnalyzer : InitializableOperator, IStatefulItem { 38 36 private const string ResultsParameterName = "Results"; 39 37 private const string GenerationsParameterName = "Generations"; 40 41 #region IAnalyzer Members42 public bool EnabledByDefault {43 get { return true; }44 }45 #endregion46 47 38 48 39 #region Parameter properties … … 82 73 private ScatterPlotHelper diversityPlotHelper, qualityPlotHelper; 83 74 [Storable] 84 private DataTableHelper avgDataTableHelper;85 [Storable]86 75 private int cnt = 0, lastGeneration = 0; 87 [Storable]88 private List<double> qualityPoints = new List<double>();89 76 90 77 [StorableConstructor] … … 94 81 diversityPlotHelper = (ScatterPlotHelper)original.diversityPlotHelper.Clone(cloner); 95 82 qualityPlotHelper = (ScatterPlotHelper)original.qualityPlotHelper.Clone(cloner); 96 avgDataTableHelper = (DataTableHelper)original.avgDataTableHelper.Clone(cloner);97 83 cnt = original.cnt; 98 84 lastGeneration = original.lastGeneration; 99 qualityPoints = new List<double>(original.qualityPoints);100 85 } 101 86 … … 122 107 diversityPlotHelper = new ScatterPlotHelper(false, true); 123 108 qualityPlotHelper = new ScatterPlotHelper(false, true); 124 avgDataTableHelper = new DataTableHelper();125 109 } 126 110 … … 129 113 } 130 114 131 public override IOperation Apply() { 132 Point2D<double> curPoint, divPoint; 133 115 protected override void InitializeAction() { 134 116 if (SimilarityCalculatorParameter.Value == null) { 135 117 SimilarityCalculatorParameter.Value = OperatorsParameter.ActualValue.OfType<ISingleObjectiveSolutionSimilarityCalculator>().FirstOrDefault(); 136 118 } 119 Reset(); 120 } 121 122 public override IOperation Apply() { 123 Initialize(); 124 Point2D<double> curPoint, divPoint; 137 125 138 126 var qualityCX = QualityAfterCrossoverParameter.ActualValue.Value; … … 144 132 qualityPlotHelper.InitializePlot(Results, "Mutation Quality", "Solution Index", "Absolut Quality Difference"); 145 133 diversityPlotHelper.InitializePlot(Results, "Mutation Diversity", "Solution Index", "Diversity"); 146 avgDataTableHelper.InitializeChart(Results, "Average Mutation Performance", new string[] { "Average Mutation Performance per Generation" });147 134 148 135 Scope permutationBeforeScope = new Scope(); … … 153 140 divPoint = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(permutationBeforeScope, permutationAfterScope)); 154 141 curPoint = new Point2D<double>(cnt++, qualityCX - qualityM); 155 qualityPoints.Add(curPoint.Y); 142 156 143 157 144 string curGenStr = GenerationsParameter.ActualValue.Value.ToString(); … … 162 149 if (GenerationsParameter.ActualValue.Value != 0) { 163 150 if (GenerationsParameter.ActualValue.Value > lastGeneration) { 164 double avg = qualityPoints.Average();165 avgDataTableHelper.AddPoint(avg);166 151 Reset(); 167 152 } 168 } else {169 Reset();170 153 } 171 154 } … … 177 160 cnt = 0; 178 161 lastGeneration = GenerationsParameter.ActualValue.Value; 179 qualityPoints.Clear(); 162 } 163 164 public override void ClearState() { 165 qualityPlotHelper.CleanUp(); 166 diversityPlotHelper.CleanUp(); 180 167 } 181 168 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ScatterPlotHelper.cs
r8797 r8867 133 133 Plot.VisualProperties.YAxisTitle = yAxisTitle; 134 134 } 135 136 public void CleanUp() { 137 if (!StoreHistory && CreateDataTable) { 138 resultsCol[chartName].Value = null; 139 resultsCol.Remove(chartName); 140 plot = null; 141 } 142 } 135 143 } 136 144 }
Note: See TracChangeset
for help on using the changeset viewer.