- Timestamp:
- 08/02/12 10:08:05 (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
r8337 r8382 29 29 using HeuristicLab.Operators; 30 30 using HeuristicLab.Optimization; 31 using HeuristicLab.Optimization.Operators; 31 32 using HeuristicLab.Parameters; 32 33 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 65 66 get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; } 66 67 } 68 public IValueParameter<SingleObjectiveSolutionSimilarityCalculator> SimilarityCalculatorParameter { 69 get { return (IValueParameter<SingleObjectiveSolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; } 70 } 67 71 #endregion 68 72 … … 73 77 #endregion 74 78 75 ScatterPlot plot ;76 DataRow dtRow ;79 ScatterPlot plot, childDiversityPlot, parentDiversityPlot; 80 DataRow dtRow, dtRowSuccess; 77 81 int cnt = 0; 82 int success = 0; 78 83 79 84 [StorableConstructor] … … 96 101 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The evaluated quality of the child solution.")); 97 102 QualityParameter.ActualName = "TSPTourLength"; 103 104 Parameters.Add(new ValueParameter<SingleObjectiveSolutionSimilarityCalculator>("SimilarityCalculator")); 98 105 } 99 106 … … 103 110 104 111 public override IOperation Apply() { 112 SimilarityCalculatorParameter.Value.QualityVariableName = "TSPTourLength"; 113 SimilarityCalculatorParameter.Value.SolutionVariableName = "TSPTour"; 114 115 Point2D<double> qualityPoint, diversityPointChild, diversityPointParent; 105 116 var qualityParent1 = ParentsQualityParameter.ActualValue.First().Value; 106 117 var qualityParent2 = ParentsQualityParameter.ActualValue.Last().Value; 107 Point2D<double> curPoint; 108 118 var child = ChildParameter.ActualValue; 119 var parent1 = ParentsParameter.ActualValue.First(); 120 var parent2 = ParentsParameter.ActualValue.Last(); 121 var parentDiversity = SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope.SubScopes.First(), ExecutionContext.Scope.SubScopes.Last()); 122 123 diversityPointParent = new Point2D<double>(cnt, parentDiversity); 109 124 double worseQuality = qualityParent1 > qualityParent2 ? qualityParent1 : qualityParent2; 110 curPoint = new Point2D<double>(cnt++, worseQuality - QualityParameter.ActualValue.Value); 125 if (qualityParent1 > qualityParent2) { 126 diversityPointChild = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.First())); 127 } else { 128 diversityPointChild = new Point2D<double>(cnt, SimilarityCalculatorParameter.Value.CalculateSolutionSimilarity(ExecutionContext.Scope, ExecutionContext.Scope.SubScopes.Last())); 129 } 130 131 qualityPoint = new Point2D<double>(cnt++, worseQuality - QualityParameter.ActualValue.Value); 132 if ((worseQuality - QualityParameter.ActualValue.Value) > 0) { 133 success++; 134 } 111 135 112 136 string curGenStr = GenerationsParameter.ActualValue.Value.ToString(); 113 ScatterPlotDataRow row;114 137 115 138 if (!Results.ContainsKey("Scatter Plot")) { 116 139 InitializePlot(); 140 InitializeChildDiversityPlot(); 141 InitializeParentDiversityPlot(); 142 117 143 Results.Add(new Result("Scatter Plot", plot)); 118 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())); 119 151 cnt = 0; 120 152 … … 123 155 dt.Rows.Add(dtRow); 124 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; 125 164 } 126 165 … … 129 168 double avg = plot.Rows[(GenerationsParameter.ActualValue.Value - 1).ToString()].Points.Average(x => x.Y); 130 169 dtRow.Values.Add(avg); 170 dtRowSuccess.Values.Add(success); 131 171 132 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); 133 175 InitializePlot(); 176 InitializeChildDiversityPlot(); 177 InitializeParentDiversityPlot(); 134 178 Results["Scatter Plot"].Value = plot; 179 Results["Child Diversity Scatter Plot"].Value = childDiversityPlot; 180 Results["Parent Diversity Scatter Plot"].Value = parentDiversityPlot; 135 181 cnt = 0; 182 success = 0; 136 183 } 137 184 138 185 var points = new List<Point2D<double>>(); 139 points.Add(curPoint); 186 points.Add(qualityPoint); 187 ScatterPlotDataRow row; 140 188 row = new ScatterPlotDataRow(curGenStr, null, points); 141 189 row.VisualProperties.PointStyle = ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Circle; 142 190 row.VisualProperties.PointSize = 5; 143 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); 144 206 } else { 145 plot.Rows[curGenStr].Points.Add(curPoint); 207 plot.Rows[curGenStr].Points.Add(qualityPoint); 208 childDiversityPlot.Rows[curGenStr].Points.Add(diversityPointChild); 209 parentDiversityPlot.Rows[curGenStr].Points.Add(diversityPointParent); 146 210 } 147 211 … … 154 218 plot.VisualProperties.YAxisTitle = "Absolut Quality Difference"; 155 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"; 229 } 156 230 } 157 231 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers-3.3.csproj
r8352 r8382 70 70 <Private>False</Private> 71 71 </Reference> 72 <Reference Include="HeuristicLab.Optimization.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 73 <Private>True</Private> 74 </Reference> 72 75 <Reference Include="HeuristicLab.Parameters-3.3"> 73 76 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath> -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/Plugin.cs.frame
r8336 r8382 32 32 [PluginDependency("HeuristicLab.Operators", "3.3")] 33 33 [PluginDependency("HeuristicLab.Optimization", "3.3")] 34 [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")] 34 35 [PluginDependency("HeuristicLab.Parameters", "3.3")] 35 36 [PluginDependency("HeuristicLab.Persistence", "3.3")]
Note: See TracChangeset
for help on using the changeset viewer.