Changeset 8499 for branches/HeuristicLab.Analysis.AlgorithmBehavior
- Timestamp:
- 08/18/12 09:45:42 (12 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/CrossoverPerformanceAnalyzer.cs
r8382 r8499 32 32 using HeuristicLab.Parameters; 33 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 34 using HeuristicLab.Problems.TravelingSalesman; 34 35 35 36 namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers { … … 77 78 #endregion 78 79 79 ScatterPlot plot, childDiversityPlot, parentDiversityPlot;80 Data Row dtRow, dtRowSuccess;80 ScatterPlotHelper plotHelper, childDiversityHelper, parentDiversityHelper; 81 DataTableHelper performanceHelper, successHelper, equalParentsHelper; 81 82 int cnt = 0; 82 83 int success = 0; 84 int lastGeneration = 0; 85 int equalParents = 0; 86 List<double> qualityPoints = new List<double>(); 83 87 84 88 [StorableConstructor] … … 103 107 104 108 Parameters.Add(new ValueParameter<SingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator")); 109 110 plotHelper = new ScatterPlotHelper(); 111 childDiversityHelper = new ScatterPlotHelper(); 112 parentDiversityHelper = new ScatterPlotHelper(); 113 performanceHelper = new DataTableHelper(); 114 successHelper = new DataTableHelper(); 115 equalParentsHelper = new DataTableHelper(); 105 116 } 106 117 … … 113 124 SimilarityCalculatorParameter.Value.SolutionVariableName = "TSPTour"; 114 125 126 plotHelper.InitializePlot(Results, "Crossover Performance", "Solution Index", "Absolut Quality Difference"); 127 childDiversityHelper.InitializePlot(Results, "Child Diversity", "Solution Index", "Diversity"); 128 parentDiversityHelper.InitializePlot(Results, "Parent Diversity", "Solution Index", "Diversity"); 129 130 performanceHelper.InitializeChart(Results, "Average Crossover Performance", "Average Crossover Performance per Generation"); 131 successHelper.InitializeChart(Results, "Successfull Crossovers", "Successfull Crossovers per Generation"); 132 equalParentsHelper.InitializeChart(Results, "Number of equal parents", "Absolut number of equal parents"); 133 115 134 Point2D<double> qualityPoint, diversityPointChild, diversityPointParent; 116 135 var qualityParent1 = ParentsQualityParameter.ActualValue.First().Value; … … 120 139 var parent2 = ParentsParameter.ActualValue.Last(); 121 140 var parentDiversity = SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope.SubScopes.First(), ExecutionContext.Scope.SubScopes.Last()); 141 string curGenStr = GenerationsParameter.ActualValue.Value.ToString(); 142 122 143 123 144 diversityPointParent = new Point2D<double>(cnt, parentDiversity); … … 133 154 success++; 134 155 } 156 qualityPoints.Add(qualityPoint.Y); 135 157 136 string curGenStr = GenerationsParameter.ActualValue.Value.ToString(); 137 138 if (!Results.ContainsKey("Scatter Plot")) { 139 InitializePlot(); 140 InitializeChildDiversityPlot(); 141 InitializeParentDiversityPlot(); 142 143 Results.Add(new Result("Scatter Plot", plot)); 144 Results.Add(new Result("Scatter Plot History", new ScatterPlotHistory())); 145 146 Results.Add(new Result("Child Diversity Scatter Plot", childDiversityPlot)); 147 Results.Add(new Result("Child Diversity Scatter Plot History", new ScatterPlotHistory())); 148 149 Results.Add(new Result("Parent Diversity Scatter Plot", parentDiversityPlot)); 150 Results.Add(new Result("Parent Diversity Scatter Plot History", new ScatterPlotHistory())); 151 cnt = 0; 152 153 DataTable dt = new DataTable("Average Crossover Performance"); 154 dtRow = new DataRow("Average Crossover Performance per Generation"); 155 dt.Rows.Add(dtRow); 156 Results.Add(new Result("Average Crossover Performance", dt)); 157 158 DataTable dtSuccess = new DataTable("Successfull Crossovers"); 159 dtRowSuccess = new DataRow("Successfull Crossovers per Generation"); 160 dtSuccess.Rows.Add(dtRowSuccess); 161 Results.Add(new Result("Successfull Crossovers", dtSuccess)); 162 163 success = 0; 158 if (TSPSimilarityCalculator.CalculateSimilarity(parent1, parent2) == 1.0) { 159 equalParents++; 164 160 } 165 161 166 if (!plot.Rows.ContainsKey(curGenStr)) { 167 if (GenerationsParameter.ActualValue.Value != 0) { 168 double avg = plot.Rows[(GenerationsParameter.ActualValue.Value - 1).ToString()].Points.Average(x => x.Y); 169 dtRow.Values.Add(avg); 170 dtRowSuccess.Values.Add(success); 162 if (GenerationsParameter.ActualValue.Value != 0) { 163 if (GenerationsParameter.ActualValue.Value > lastGeneration) { 164 double avg = qualityPoints.Average(); 171 165 172 ((ScatterPlotHistory)Results["Scatter Plot History"].Value).Add(plot); 173 ((ScatterPlotHistory)Results["Child Diversity Scatter Plot History"].Value).Add(childDiversityPlot); 174 ((ScatterPlotHistory)Results["Parent Diversity Scatter Plot History"].Value).Add(parentDiversityPlot); 175 InitializePlot(); 176 InitializeChildDiversityPlot(); 177 InitializeParentDiversityPlot(); 178 Results["Scatter Plot"].Value = plot; 179 Results["Child Diversity Scatter Plot"].Value = childDiversityPlot; 180 Results["Parent Diversity Scatter Plot"].Value = parentDiversityPlot; 181 cnt = 0; 182 success = 0; 166 performanceHelper.AddPoint(avg); 167 successHelper.AddPoint(success); 168 equalParentsHelper.AddPoint(equalParents); 169 170 Reset(); 183 171 } 184 172 185 var points = new List<Point2D<double>>(); 186 points.Add(qualityPoint); 187 ScatterPlotDataRow row; 188 row = new ScatterPlotDataRow(curGenStr, null, points); 189 row.VisualProperties.PointStyle = ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Circle; 190 row.VisualProperties.PointSize = 5; 191 plot.Rows.Add(row); 192 193 points = new List<Point2D<double>>(); 194 points.Add(diversityPointChild); 195 row = new ScatterPlotDataRow(curGenStr, null, points); 196 row.VisualProperties.PointStyle = ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Circle; 197 row.VisualProperties.PointSize = 5; 198 childDiversityPlot.Rows.Add(row); 199 200 points = new List<Point2D<double>>(); 201 points.Add(diversityPointParent); 202 row = new ScatterPlotDataRow(curGenStr, null, points); 203 row.VisualProperties.PointStyle = ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Circle; 204 row.VisualProperties.PointSize = 5; 205 parentDiversityPlot.Rows.Add(row); 173 plotHelper.AddPoint(curGenStr, qualityPoint); 174 childDiversityHelper.AddPoint(curGenStr, diversityPointChild); 175 parentDiversityHelper.AddPoint(curGenStr, diversityPointParent); 206 176 } else { 207 plot.Rows[curGenStr].Points.Add(qualityPoint); 208 childDiversityPlot.Rows[curGenStr].Points.Add(diversityPointChild); 209 parentDiversityPlot.Rows[curGenStr].Points.Add(diversityPointParent); 177 Reset(); 210 178 } 211 179 … … 213 181 } 214 182 215 private void InitializePlot() { 216 plot = new ScatterPlot("Crossover Performance", null); 217 plot.VisualProperties.XAxisTitle = "Solution Index"; 218 plot.VisualProperties.YAxisTitle = "Absolut Quality Difference"; 219 } 220 private void InitializeChildDiversityPlot() { 221 childDiversityPlot = new ScatterPlot("Child Diversity", null); 222 childDiversityPlot.VisualProperties.XAxisTitle = "Solution Index"; 223 childDiversityPlot.VisualProperties.YAxisTitle = "Diversity"; 224 } 225 private void InitializeParentDiversityPlot() { 226 parentDiversityPlot = new ScatterPlot("Parent Diversity", null); 227 parentDiversityPlot.VisualProperties.XAxisTitle = "Solution Index"; 228 parentDiversityPlot.VisualProperties.YAxisTitle = "Diversity"; 183 private void Reset() { 184 cnt = 0; 185 success = 0; 186 lastGeneration = GenerationsParameter.ActualValue.Value; 187 qualityPoints.Clear(); 188 equalParents = 0; 229 189 } 230 190 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/MutationPerformanceAnalyzer.cs
r8498 r8499 134 134 double avg = qualityPoints.Average(); 135 135 avgDataTableHelper.AddPoint(avg); 136 cnt = 0; 137 lastGeneration = GenerationsParameter.ActualValue.Value; 138 qualityPoints.Clear(); 136 Reset(); 139 137 } 138 } else { 139 Reset(); 140 140 } 141 141 142 142 return base.Apply(); 143 143 } 144 145 private void Reset() { 146 cnt = 0; 147 lastGeneration = GenerationsParameter.ActualValue.Value; 148 qualityPoints.Clear(); 149 } 144 150 } 145 151 }
Note: See TracChangeset
for help on using the changeset viewer.