Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/28/15 14:41:03 (9 years ago)
Author:
abeham
Message:

#2431:

  • added ability to plot curves for multiple targets at once
  • fixed bug in IndexedDataTableView regarding log-scaling
  • added result that counts restarts
  • fixed bugs in IRRestarter
  • Set LineWidth = 2 in analyzers for chart
  • fixed bugs in RLD view
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs

    r12806 r12808  
    2727using HeuristicLab.Analysis;
    2828using HeuristicLab.Collections;
    29 using HeuristicLab.Common;
    3029using HeuristicLab.Core.Views;
    3130using HeuristicLab.Data;
     
    5554      InitializeComponent();
    5655      combinedDataTable = new IndexedDataTable<double>("Combined DataTable", "A data table containing the ECDF of each of a number of groups.") {
    57         VisualProperties = { YAxisTitle = "Proportion of reached targets" }
     56        VisualProperties = {
     57          YAxisTitle = "Proportion of reached targets",
     58          YAxisMinimumFixedValue = 0, YAxisMinimumAuto = false,
     59          YAxisMaximumFixedValue = 1, YAxisMaximumAuto = false
     60        }
    5861      };
    5962      viewHost.Content = combinedDataTable;
     
    179182        if (string.IsNullOrEmpty(table)) return;
    180183        if (levels == null) {
    181           var worst = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item2)).First();
    182           var best = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item2)).Last();
     184          var worstMin = Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.First().Item2).Min();
     185          var worstMax = Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.First().Item2).Max();
     186          var bestMin = Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Last().Item2).Min();
     187          var bestMax = Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Last().Item2).Max();
     188          double worst, best;
     189          if (Math.Abs(bestMax - worstMin) > Math.Abs(bestMin - worstMax)) {
     190            worst = worstMin;
     191            best = bestMax;
     192          } else {
     193            worst = worstMax;
     194            best = bestMin;
     195          }
    183196          levels = Enumerable.Range(0, 11).Select(x => worst + (x / 10.0) * (best - worst)).ToArray();
    184197          suppressTargetsEvents = true;
     
    196209        var xAxisTitles = new HashSet<string>();
    197210        foreach (var group in groupedRuns) {
    198           var hits = new SortedList<double, int>();
     211          var hits = new Dictionary<string, SortedList<double, double>>();
    199212          foreach (var run in group.Item2) {
     213            if (!run.Results.ContainsKey(table)) continue;
    200214            var resultsTable = (IndexedDataTable<double>)run.Results[table];
    201215            xAxisTitles.Add(resultsTable.VisualProperties.XAxisTitle);
    202216            var values = resultsTable.Rows.First().Values;
    203217            var maximization = values.First().Item2 < values.Last().Item2;
    204             var i = 0;
    205             var j = 0;
    206             var current = values[j];
    207             var prev = Tuple.Create(-1.0, double.NaN);
    208             while (i < levels.Length) {
    209               if ((double.IsNaN(prev.Item2) || prev.Item2 != current.Item2)
    210                   && (maximization && current.Item2 >= levels[i]
    211                   || !maximization && current.Item2 <= levels[i])) {
    212                 if (hits.ContainsKey(current.Item1))
    213                   hits[current.Item1]++;
    214                 else hits[current.Item1] = 1;
    215                 i++;
    216               } else {
    217                 j++;
    218                 if (j >= values.Count) break;
    219                 prev = current;
    220                 current = values[j];
     218            if (allOrEachTargetCheckBox.Checked) {
     219              // each
     220              foreach (double l in levels) {
     221                var key = "-" + l.ToString();
     222                if (!hits.ContainsKey(key)) hits.Add(key, new SortedList<double, double>());
     223                foreach (var v in values) {
     224                  if (maximization && v.Item2 >= l || !maximization && v.Item2 <= l) {
     225                    if (hits[key].ContainsKey(v.Item1))
     226                      hits[key][v.Item1] += 1.0 / group.Item2.Count;
     227                    else hits[key][v.Item1] = 1.0 / group.Item2.Count;
     228                    break;
     229                  }
     230                }
     231              }
     232            } else {
     233              if (!hits.ContainsKey("all")) hits.Add("all", new SortedList<double, double>());
     234              // all
     235              var i = 0;
     236              var j = 0;
     237              var current = values[j];
     238              var prev = Tuple.Create(-1.0, double.NaN);
     239              while (i < levels.Length) {
     240                if ((double.IsNaN(prev.Item2) || prev.Item2 != current.Item2)
     241                    && (maximization && current.Item2 >= levels[i]
     242                        || !maximization && current.Item2 <= levels[i])) {
     243                  if (hits["all"].ContainsKey(current.Item1))
     244                    hits["all"][current.Item1] += 1.0 / (group.Item2.Count * levels.Length);
     245                  else hits["all"][current.Item1] = 1.0 / (group.Item2.Count * levels.Length);
     246                  i++;
     247                } else {
     248                  j++;
     249                  if (j >= values.Count) break;
     250                  prev = current;
     251                  current = values[j];
     252                }
    221253              }
    222254            }
    223255          }
    224           var row = new IndexedDataRow<double>(group.Item1) { VisualProperties = { ChartType = DataRowVisualProperties.DataRowChartType.StepLine } };
    225           var total = 0.0;
    226           foreach (var h in hits) {
    227             total += h.Value;
    228             row.Values.Add(Tuple.Create(h.Key, total / (group.Item2.Count * levels.Length)));
    229           }
    230           combinedDataTable.Rows.Add(row);
     256          foreach (var list in hits) {
     257            var row = new IndexedDataRow<double>(group.Item1 + (list.Key != "all" ? list.Key : string.Empty)) {
     258              VisualProperties = {
     259                ChartType = DataRowVisualProperties.DataRowChartType.StepLine,
     260                LineWidth = 2
     261              }
     262            };
     263            var total = 0.0;
     264            foreach (var h in list.Value) {
     265              total += h.Value;
     266              row.Values.Add(Tuple.Create(h.Key, total));
     267            }
     268            combinedDataTable.Rows.Add(row);
     269          }
    231270        }
    232271        combinedDataTable.VisualProperties.XAxisTitle = string.Join(" / ", xAxisTitles);
    233         combinedDataTable.VisualProperties.XAxisLogScale = logScalingCheckBox.Checked;
     272        combinedDataTable.VisualProperties.XAxisLogScale = combinedDataTable.Rows.Count > 0 && logScalingCheckBox.Checked;
    234273      } finally { ResumeRepaint(true); }
    235274    }
     
    317356      } else if (Content.Count > 0 && dataTableComboBox.SelectedIndex >= 0) {
    318357        var table = (string)dataTableComboBox.SelectedItem;
    319         var worst = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item2)).First();
    320         var best = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item2)).Last();
     358        var worst = Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item2)).First();
     359        var best = Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item2)).Last();
    321360        max = (decimal)Math.Max(best, worst);
    322361        min = (decimal)Math.Min(best, worst);
     
    332371            levels = maximization ? dialog.Values.Select(x => (double)x).ToArray()
    333372                                  : dialog.Values.Reverse().Select(x => (double)x).ToArray();
     373            suppressTargetsEvents = true;
     374            targetsTextBox.Text = string.Join(" ; ", levels);
     375            suppressTargetsEvents = false;
     376
    334377            UpdateRuns();
    335378            SetEnabledStateOfControls();
     
    342385      var table = (string)dataTableComboBox.SelectedItem;
    343386      foreach (var run in Content) {
     387        if (!run.Results.ContainsKey(table)) continue;
    344388        var resultsTable = (IndexedDataTable<double>)run.Results[table];
    345389        var values = resultsTable.Rows.First().Values;
     
    384428
    385429      foreach (var run in Content) {
     430        if (!run.Results.ContainsKey(table)) continue;
    386431        var resultsTable = (IndexedDataTable<double>)run.Results[table];
    387432        var values = resultsTable.Rows.First().Values;
     
    403448      }
    404449    }
     450
     451    private void allOrEachTargetCheckBox_CheckedChanged(object sender, EventArgs e) {
     452      var each = allOrEachTargetCheckBox.Checked;
     453      allOrEachTargetCheckBox.Text = each ? "each" : "all";
     454      UpdateRuns();
     455    }
    405456  }
    406457}
Note: See TracChangeset for help on using the changeset viewer.