Changeset 13663 for branches/PerformanceComparison/HeuristicLab.Analysis
- Timestamp:
- 03/07/16 21:29:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Analysis/3.3/QualityAnalysis/QualityDistributionAnalyzer.cs
r12012 r13663 20 20 #endregion 21 21 22 using System.Linq;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 28 27 using HeuristicLab.Parameters; 29 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using System.Collections.Generic; 30 using System.Linq; 30 31 31 32 namespace HeuristicLab.Analysis.QualityAnalysis { … … 33 34 [StorableClass] 34 35 public class QualityDistributionAnalyzer : SingleSuccessorOperator, IAnalyzer, IIterationBasedOperator, ISingleObjectiveOperator { 36 private const string TableDescription = "Shows the quality distributions in the current population."; 35 37 36 38 #region Parameter properties … … 93 95 } 94 96 97 public static DataTable PrepareTable(string qualityName = "Quality") { 98 var result = new DataTable("Population Quality Distribution", TableDescription); 99 result.VisualProperties.XAxisTitle = qualityName; 100 result.VisualProperties.YAxisTitle = "Frequency"; 101 102 var row = new DataRow("QualityDistribution"); 103 row.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 104 result.Rows.Add(row); 105 106 return result; 107 } 108 109 public static void UpdateTable(DataTable table, IEnumerable<double> qualities) { 110 var row = table.Rows["QualityDistribution"]; 111 row.Values.Replace(qualities); 112 } 113 95 114 public override IOperation Apply() { 96 115 DataTable qualityDistribution = null; 97 ResultCollection results = ResultsParameter.ActualValue; 98 string description = "Shows the quality distributions in the current population."; 116 var results = ResultsParameter.ActualValue; 99 117 if (results.ContainsKey(HistogramName)) { 100 qualityDistribution = results[HistogramName].Value as DataTable;118 qualityDistribution = (DataTable)results[HistogramName].Value; 101 119 } else { 102 qualityDistribution = new DataTable("Population Quality Distribution", description); 103 qualityDistribution.VisualProperties.XAxisTitle = QualityParameter.ActualName; 104 qualityDistribution.VisualProperties.YAxisTitle = "Frequency"; 105 results.Add(new Result(HistogramName, description, qualityDistribution)); 120 qualityDistribution = PrepareTable(QualityParameter.ActualName); 121 results.Add(new Result(HistogramName, TableDescription, qualityDistribution)); 106 122 } 107 DataRow row; 108 if (!qualityDistribution.Rows.TryGetValue("QualityDistribution", out row)) { 109 row = new DataRow("QualityDistribution"); 110 row.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 111 qualityDistribution.Rows.Add(row); 112 } 113 var qualities = QualityParameter.ActualValue; 114 row.Values.Replace(qualities.Select(x => x.Value)); 123 124 UpdateTable(qualityDistribution, QualityParameter.ActualValue.Select(x => x.Value)); 115 125 116 126 if (StoreHistory) { 117 stringhistoryResultName = HistogramName + " History";127 var historyResultName = HistogramName + " History"; 118 128 DataTableHistory qdHistory = null; 119 129 if (results.ContainsKey(historyResultName)) { 120 qdHistory = results[historyResultName].Value as DataTableHistory;130 qdHistory = (DataTableHistory)results[historyResultName].Value; 121 131 } else { 122 132 qdHistory = new DataTableHistory(); 123 133 results.Add(new Result(historyResultName, qdHistory)); 124 134 } 125 DataTabletable = (DataTable)qualityDistribution.Clone();126 IntValueiteration = IterationsParameter.ActualValue;135 var table = (DataTable)qualityDistribution.Clone(); 136 var iteration = IterationsParameter.ActualValue; 127 137 if (iteration != null) { 128 stringiterationName = IterationsParameter.ActualName;138 var iterationName = IterationsParameter.ActualName; 129 139 if (iterationName.EndsWith("s")) iterationName = iterationName.Remove(iterationName.Length - 1); 130 stringappendix = " at " + iterationName + " " + iteration.Value.ToString();140 var appendix = " at " + iterationName + " " + iteration.Value.ToString(); 131 141 table.Name += appendix; 132 142 table.Rows["QualityDistribution"].VisualProperties.DisplayName += appendix;
Note: See TracChangeset
for help on using the changeset viewer.