Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/17/15 09:32:01 (9 years ago)
Author:
abeham
Message:

#2431:

  • Added label on last data point
  • Changed target in cost view to display as ratio to best-known or best found
File:
1 edited

Legend:

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

    r12864 r12865  
    526526      var lineStyleCount = 0;
    527527
     528      var maximization = IsMaximization();
     529      var targetsPerProblem = (from r in Content
     530                               let pd = new ProblemDescription(r).ToString()
     531                               let target = r.Parameters.ContainsKey("BestKnownQuality")
     532                                && r.Parameters["BestKnownQuality"] is DoubleValue
     533                                  ? ((DoubleValue)r.Parameters["BestKnownQuality"]).Value
     534                                  : ((IndexedDataTable<double>)r.Results[(string)dataTableComboBox.SelectedItem]).Rows.First().Values.Last().Item2
     535                               group target by pd into g
     536                               select new { Problem = g.Key, Target = maximization ? g.Max() : g.Min() })
     537                              .ToDictionary(x => x.Problem, x => x.Target);
     538
    528539      foreach (var group in groupedRuns) {
    529540        var hits = new Dictionary<string, SortedList<double, double>>();
     
    534545
    535546            if (eachOrAllBudgetsCheckBox.Checked) {
    536               CalculateHitsForEachBudget(hits, resultsTable.Rows.First(), group.Value.Count, group.Key, problem.Value.Item2.Count);
     547              CalculateHitsForEachBudget(hits, resultsTable.Rows.First(), maximization, group.Value.Count, group.Key, problem.Value.Item2.Count, targetsPerProblem[problem.Key]);
    537548            } else {
    538               CalculateHitsForAllBudgets(hits, resultsTable.Rows.First(), group.Value.Count, group.Key, problem.Value.Item2.Count);
     549              CalculateHitsForAllBudgets(hits, resultsTable.Rows.First(), maximization, group.Value.Count, group.Key, problem.Value.Item2.Count, targetsPerProblem[problem.Key]);
    539550            }
    540551          }
     
    563574      }
    564575
    565       byCostDataTable.VisualProperties.XAxisTitle = "Targets";
     576      byCostDataTable.VisualProperties.XAxisTitle = "Targets to Best-Known Ratio";
    566577      byCostDataTable.VisualProperties.XAxisLogScale = byCostDataTable.Rows.Count > 0 && budgetLogScalingCheckBox.Checked;
    567578    }
     
    588599    }
    589600
    590     private void CalculateHitsForEachBudget(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, int groupCount, string groupName, int problemCount) {
     601    private void CalculateHitsForEachBudget(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, bool maximization, int groupCount, string groupName, int problemCount, double bestTarget) {
    591602      foreach (var b in budgets) {
    592603        var key = groupName + "-" + b;
     
    597608            // the budget may be too low to achieve any target
    598609            if (prev == null && v.Item1 != b) break;
    599             var tgt = (prev == null || v.Item1 == b) ? v.Item2 : prev.Item2;
     610            var tgt = ((prev == null || v.Item1 == b) ? v.Item2 : prev.Item2);
     611            tgt = maximization ? bestTarget / tgt : tgt / bestTarget;
    600612            if (hits[key].ContainsKey(tgt))
    601613              hits[key][tgt] += 1.0 / (groupCount * problemCount);
     
    609621    }
    610622
    611     private void CalculateHitsForAllBudgets(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, int groupCount, string groupName, int problemCount) {
     623    private void CalculateHitsForAllBudgets(Dictionary<string, SortedList<double, double>> hits, IndexedDataRow<double> row, bool maximization, int groupCount, string groupName, int problemCount, double bestTarget) {
    612624      var values = row.Values;
    613625      if (!hits.ContainsKey(groupName)) hits.Add(groupName, new SortedList<double, double>());
     
    621633          if (prev != null || current.Item1 == budgets[i]) {
    622634            var tgt = (prev == null || current.Item1 == budgets[i]) ? current.Item2 : prev.Item2;
     635            tgt = maximization ? bestTarget / tgt : tgt / bestTarget;
    623636            if (!hits[groupName].ContainsKey(tgt)) hits[groupName][tgt] = 0;
    624637            hits[groupName][tgt] += 1.0 / (groupCount * problemCount * budgets.Length);
     
    631644      }
    632645      var lastTgt = values.Last().Item2;
     646      lastTgt = maximization ? bestTarget / lastTgt : lastTgt / bestTarget;
    633647      if (i < budgets.Length && !hits[groupName].ContainsKey(lastTgt)) hits[groupName][lastTgt] = 0;
    634648      while (i < budgets.Length) {
Note: See TracChangeset for help on using the changeset viewer.