Changeset 9363 for branches/OaaS/HeuristicLab.Analysis/3.3/AlleleFrequencyAnalysis/AlleleFrequencyAnalyzer.cs
- Timestamp:
- 04/16/13 13:13:41 (12 years ago)
- Location:
- branches/OaaS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Analysis
- Property svn:mergeinfo changed
-
branches/OaaS/HeuristicLab.Analysis/3.3/AlleleFrequencyAnalysis/AlleleFrequencyAnalyzer.cs
r7259 r9363 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 88 89 } 89 90 90 #region AlleleFrequencyIdEqualityComparer 91 #region Equality Comparers 92 private class AlleleIdEqualityComparer : IEqualityComparer<Allele> { 93 public bool Equals(Allele x, Allele y) { 94 return x.Id == y.Id; 95 } 96 public int GetHashCode(Allele obj) { 97 return obj.Id.GetHashCode(); 98 } 99 } 91 100 private class AlleleFrequencyIdEqualityComparer : IEqualityComparer<AlleleFrequency> { 92 101 public bool Equals(AlleleFrequency x, AlleleFrequency y) { … … 112 121 bool max = MaximizationParameter.ActualValue.Value; 113 122 ItemArray<T> solutions = SolutionParameter.ActualValue; 114 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;123 double[] qualities = QualityParameter.ActualValue.Select(x => x.Value).ToArray(); 115 124 T bestKnownSolution = BestKnownSolutionParameter.ActualValue; 116 125 bool storeHistory = StoreHistoryParameter.Value.Value; … … 120 129 if (!max) { 121 130 bestIndex = qualities 122 .Select((x, i ndex) => new { index, x.Value})131 .Select((x, i) => new { Index = i, Value = x }) 123 132 .OrderBy(x => x.Value) 124 .First(). index;133 .First().Index; 125 134 } else { 126 135 bestIndex = qualities 127 .Select((x, i ndex) => new { index, x.Value})136 .Select((x, i) => new { Index = i, Value = x }) 128 137 .OrderByDescending(x => x.Value) 129 .First(). index;138 .First().Index; 130 139 } 131 140 … … 142 151 x.Count() / ((double)solutions.Length), 143 152 x.Average(a => a.Allele.Impact), 144 x.Average(a => a.Quality .Value),153 x.Average(a => a.Quality), 145 154 bestKnownAlleles == null ? false : bestKnownAlleles.Any(a => a.Id == x.Key), 146 155 bestAlleles.Any(a => a.Id == x.Key))); … … 248 257 else 249 258 ((DoubleValue)results["Lost Alleles of Best Known Solution"].Value).Value = lostRelevantAllelesCount; 259 260 // calculate contained alleles of best known solution and relative quality 261 if (bestKnownAlleles != null) { 262 double qualityRange = Math.Abs(qualities.Max() - qualities.Min()); 263 var points = solutions.Select((s, index) => new Point2D<double>(CalculateAlleles(s).Intersect(bestKnownAlleles, new AlleleIdEqualityComparer()).Count(), 264 Math.Abs(qualities[index] - qualities[bestIndex]) / qualityRange)); 265 var avgContainedReleventAlleles = points.Select(x => x.X).Average(); 266 267 var plot = new ScatterPlot("Contained Alleles of Best Known Solution and Relative Solution Qualtiy", null); 268 plot.VisualProperties.XAxisTitle = "Contained Alleles of Best Known Solution"; 269 plot.VisualProperties.YAxisTitle = "Relative Solution Quality"; 270 plot.VisualProperties.XAxisMinimumAuto = false; 271 plot.VisualProperties.XAxisMinimumFixedValue = 0.0; 272 plot.VisualProperties.XAxisMaximumAuto = false; 273 plot.VisualProperties.XAxisMaximumFixedValue = bestKnownAlleles.Length; 274 plot.VisualProperties.YAxisMinimumAuto = false; 275 plot.VisualProperties.YAxisMinimumFixedValue = 0.0; 276 plot.VisualProperties.YAxisMaximumAuto = false; 277 plot.VisualProperties.YAxisMaximumFixedValue = 1.0; 278 var row = new ScatterPlotDataRow("Solutions of Current Generation", null, points); 279 row.VisualProperties.PointStyle = ScatterPlotDataRowVisualProperties.ScatterPlotDataRowPointStyle.Circle; 280 row.VisualProperties.PointSize = 5; 281 plot.Rows.Add(row); 282 283 if (!results.ContainsKey("Scatter Plot")) 284 results.Add(new Result("Scatter Plot", plot)); 285 else 286 results["Scatter Plot"].Value = plot; 287 if (storeHistory) { 288 if (!results.ContainsKey("Scatter Plot History")) { 289 results.Add(new Result("Scatter Plot History", new ScatterPlotHistory())); 290 } 291 ((ScatterPlotHistory)results["Scatter Plot History"].Value).Add(plot); 292 } 293 294 if (!allelesTable.Rows.ContainsKey("Average Contained Alleles of Best Known Solution")) { 295 allelesTable.Rows.Add(new DataRow("Average Contained Alleles of Best Known Solution", null)); 296 allelesTable.Rows["Average Contained Alleles of Best Known Solution"].VisualProperties.SecondYAxis = true; 297 allelesTable.Rows["Average Contained Alleles of Best Known Solution"].VisualProperties.StartIndexZero = true; 298 } 299 allelesTable.Rows["Average Contained Alleles of Best Known Solution"].Values.Add(avgContainedReleventAlleles); 300 301 if (!results.ContainsKey("Average Contained Alleles of Best Known Solution")) 302 results.Add(new Result("Average Contained Alleles of Best Known Solution", new DoubleValue(avgContainedReleventAlleles))); 303 else 304 ((DoubleValue)results["Average Contained Alleles of Best Known Solution"].Value).Value = avgContainedReleventAlleles; 305 } 250 306 } 251 307 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.