Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/15/11 19:33:28 (12 years ago)
Author:
abeham
Message:

#1465

  • removed AggregatedHistogramHistoryView
  • removed Histogram and HistogramHistory data structures
  • removed HistogramView and HistogramHistoryView, but left the HistogramControl
  • adapted the QualityDistributionAnalyzer to create a DataTable instead
  • added a StoreHistory parameter
  • adapted the temporary test project
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/histogram/HeuristicLab.Analysis/3.3/QualityAnalysis/QualityDistributionAnalyzer.cs

    r5994 r6013  
    3030
    3131namespace HeuristicLab.Analysis.QualityAnalysis {
    32   [Item("Quality Distribution Analyzer", "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.")]
    3333  [StorableClass]
    34   public class QualityDistributionAnalyzer : SingleSuccessorOperator, IAnalyzer {
     34  public class QualityDistributionAnalyzer : SingleSuccessorOperator, IAnalyzer, IIterationBasedOperator {
    3535
    3636    #region Parameter properties
     
    4141      get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; }
    4242    }
    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"]; }
    4554    }
    4655    #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    }
    4766
    4867    [StorableConstructor]
     
    5574      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
    5675      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;
    5885    }
    5986
     
    6390
    6491    public override IOperation Apply() {
    65       HistogramHistory qualityDistribution = null;
     92      DataTable qualityDistribution = null;
    6693      ResultCollection results = ResultsParameter.ActualValue;
    6794      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;
    7197      } 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));
    74102      }
    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      }
    76109      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));
    80112
     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      }
    81133      return base.Apply();
    82134    }
Note: See TracChangeset for help on using the changeset viewer.