Changeset 6013 for branches/histogram/HeuristicLab.Analysis
- Timestamp:
- 04/15/11 19:33:28 (14 years ago)
- Location:
- branches/histogram/HeuristicLab.Analysis/3.3
- Files:
-
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/histogram/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj
r5994 r6013 118 118 <Compile Include="AlleleFrequencyAnalysis\AlleleFrequencyCollectionHistory.cs" /> 119 119 <Compile Include="BestScopeSolutionAnalyzer.cs" /> 120 <Compile Include="DataVisualization\HistogramHistory.cs" />121 120 <Compile Include="DataVisualization\DataRow.cs" /> 122 121 <Compile Include="DataVisualization\DataRowVisualProperties.cs" /> … … 127 126 <Compile Include="DataVisualization\HeatMap.cs" /> 128 127 <Compile Include="DataVisualization\HeatMapHistory.cs" /> 129 <Compile Include="DataVisualization\Histogram.cs" />130 128 <Compile Include="MultidimensionalScaling\MultidimensionalScaling.cs" /> 131 129 <Compile Include="MultiObjective\RankBasedParetoFrontAnalyzer.cs" /> -
branches/histogram/HeuristicLab.Analysis/3.3/QualityAnalysis/QualityDistributionAnalyzer.cs
r5994 r6013 30 30 31 31 namespace HeuristicLab.Analysis.QualityAnalysis { 32 [Item("Quality DistributionAnalyzer", "Analyzes the distribution of the quality values in that it adds a Histogram of them into the result collection.")]32 [Item("QualityDistributionAnalyzer", "Analyzes the distribution of the quality values in that it adds a Histogram of them into the result collection.")] 33 33 [StorableClass] 34 public class QualityDistributionAnalyzer : SingleSuccessorOperator, IAnalyzer {34 public class QualityDistributionAnalyzer : SingleSuccessorOperator, IAnalyzer, IIterationBasedOperator { 35 35 36 36 #region Parameter properties … … 41 41 get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; } 42 42 } 43 public IValueParameter<StringValue> HistogramNameParameter { 44 get { return (IValueParameter<StringValue>)Parameters["HistogramName"]; } 43 private ValueParameter<StringValue> HistogramNameParameter { 44 get { return (ValueParameter<StringValue>)Parameters["HistogramName"]; } 45 } 46 private ValueParameter<BoolValue> StoreHistoryParameter { 47 get { return (ValueParameter<BoolValue>)Parameters["StoreHistory"]; } 48 } 49 public ILookupParameter<IntValue> IterationsParameter { 50 get { return (ILookupParameter<IntValue>)Parameters["Iterations"]; } 51 } 52 public IValueLookupParameter<IntValue> MaximumIterationsParameter { 53 get { return (IValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; } 45 54 } 46 55 #endregion 56 57 public string HistogramName { 58 get { return HistogramNameParameter.Value.Value; } 59 set { HistogramNameParameter.Value.Value = value; } 60 } 61 62 public bool StoreHistory { 63 get { return StoreHistoryParameter.Value.Value; } 64 set { StoreHistoryParameter.Value.Value = value; } 65 } 47 66 48 67 [StorableConstructor] … … 55 74 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution.")); 56 75 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection where the analysis values should be stored.")); 57 Parameters.Add(new ValueParameter<StringValue>("HistogramName", "The name of the histogram that gets injected in to the results collection.", new StringValue("QualityDistribution"))); 76 Parameters.Add(new FixedValueParameter<StringValue>("HistogramName", "The name of the histogram that gets injected in to the results collection.", new StringValue("Quality Distribution"))); 77 Parameters.Add(new FixedValueParameter<BoolValue>("StoreHistory", "True if the history should be stored in addition to the current distribution", new BoolValue(false))); 78 Parameters.Add(new LookupParameter<IntValue>("Iterations", "Optional: A value indicating the current iteration.")); 79 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "Unused", new IntValue(-1))); 80 81 QualityParameter.Hidden = true; 82 ResultsParameter.Hidden = true; 83 IterationsParameter.Hidden = true; 84 MaximumIterationsParameter.Hidden = true; 58 85 } 59 86 … … 63 90 64 91 public override IOperation Apply() { 65 HistogramHistoryqualityDistribution = null;92 DataTable qualityDistribution = null; 66 93 ResultCollection results = ResultsParameter.ActualValue; 67 94 string description = "Shows the quality distributions in the current population."; 68 string resultName = HistogramNameParameter.Value.Value; 69 if (results.ContainsKey(resultName)) { 70 qualityDistribution = results[resultName].Value as HistogramHistory; 95 if (results.ContainsKey(HistogramName)) { 96 qualityDistribution = results[HistogramName].Value as DataTable; 71 97 } else { 72 qualityDistribution = new HistogramHistory(); 73 results.Add(new Result(resultName, description, qualityDistribution)); 98 qualityDistribution = new DataTable("Population Quality Distribution", description); 99 qualityDistribution.VisualProperties.XAxisTitle = IterationsParameter.ActualName; 100 qualityDistribution.VisualProperties.YAxisTitle = QualityParameter.ActualName; 101 results.Add(new Result(HistogramName, description, qualityDistribution)); 74 102 } 75 Histogram histogram = new Histogram("History " + qualityDistribution.Count, description); 103 DataRow row; 104 if (!qualityDistribution.Rows.TryGetValue("QualityDistribution", out row)) { 105 row = new DataRow("QualityDistribution"); 106 row.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 107 qualityDistribution.Rows.Add(row); 108 } 76 109 var qualities = QualityParameter.ActualValue; 77 histogram.Values.Clear(); 78 histogram.Values.AddRange(qualities.Select(x => x.Value)); 79 qualityDistribution.Add(histogram); 110 row.Values.Clear(); 111 row.Values.AddRange(qualities.Select(x => x.Value)); 80 112 113 if (StoreHistory) { 114 string historyResultName = HistogramName + " History"; 115 DataTableHistory qdHistory = null; 116 if (results.ContainsKey(historyResultName)) { 117 qdHistory = results[historyResultName].Value as DataTableHistory; 118 } else { 119 qdHistory = new DataTableHistory(); 120 results.Add(new Result(historyResultName, qdHistory)); 121 } 122 DataTable table = (DataTable)qualityDistribution.Clone(); 123 IntValue iteration = IterationsParameter.ActualValue; 124 if (iteration != null) { 125 string iterationName = IterationsParameter.ActualName; 126 if (iterationName.EndsWith("s")) iterationName = iterationName.Remove(iterationName.Length - 1); 127 string appendix = " at " + iterationName + " " + iteration.Value.ToString(); 128 table.Name += appendix; 129 table.Rows["QualityDistribution"].Name += appendix; 130 } 131 qdHistory.Add(table); 132 } 81 133 return base.Apply(); 82 134 }
Note: See TracChangeset
for help on using the changeset viewer.