Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/11/16 14:32:35 (8 years ago)
Author:
abeham
Message:

#2431:

  • Fixed bug that occurs when runs of unequal length are aggregated over multiple problem instances
File:
1 edited

Legend:

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

    r13745 r14035  
    324324      var lineStyleCount = 0;
    325325
     326      var maxEfforts = new Dictionary<ProblemDescription, double>();
     327      foreach (var group in groupedRuns) {
     328        foreach (var problem in group.Value) {
     329          double eff;
     330          if (!maxEfforts.TryGetValue(problem.Key, out eff)) {
     331            eff = 0.0;
     332          }
     333          foreach (var run in problem.Value.Item2) {
     334            var maxEff = ((IndexedDataTable<double>)run.Results[table]).Rows.First().Values.Last().Item1;
     335            if (maxEff > eff) eff = maxEff;
     336          }
     337          maxEfforts[problem.Key] = eff;
     338        }
     339      }
     340      // if the group contains multiple different problems we want to use the minimal maximal observed effort
     341      // otherwise we run into situations where we don't have data for a certain problem instance anymore
     342      // this is a special case when aggregating over multiple problem instances
     343      var maxEffort = maxEfforts.Values.Min();
     344
    326345      foreach (var group in groupedRuns) {
    327346        // hits describes the number of target hits at a certain time for a certain group
     
    340359
    341360            if (eachOrAllTargetCheckBox.Checked) {
    342               CalculateHitsForEachTarget(hits, misses, resultsTable.Rows.First(), problem.Key, group.Key, problem.Value.Item1);
     361              CalculateHitsForEachTarget(hits, misses, resultsTable.Rows.First(), problem.Key, group.Key, problem.Value.Item1, maxEffort);
    343362              // achiving each target can be seen as a separate run for that target only
    344363              noRuns += targets.Length;
    345364            } else {
    346               var length = CalculateHitsForAllTargets(hits, misses, resultsTable.Rows.First(), problem.Key, group.Key, problem.Value.Item1);
     365              var length = CalculateHitsForAllTargets(hits, misses, resultsTable.Rows.First(), problem.Key, group.Key, problem.Value.Item1, maxEffort);
    347366              maxLength = Math.Max(length, maxLength);
    348367              noRuns++;
     
    403422                                            Dictionary<string, SortedList<double, int>> misses,
    404423                                            IndexedDataRow<double> row, ProblemDescription problem,
    405                                             string group, double bestTarget) {
     424                                            string group, double bestTarget, double maxEffort) {
    406425      foreach (var l in targets.Select(x => (problem.IsMaximization() ? (1 - x) : (1 + x)) * bestTarget)) {
    407426        var key = group + "-" + l;
     
    412431        var hit = false;
    413432        foreach (var v in row.Values) {
     433          if (v.Item1 > maxEffort) break;
    414434          if (problem.IsMaximization() && v.Item2 >= l || !problem.IsMaximization() && v.Item2 <= l) {
    415435            if (hits[key].ContainsKey(v.Item1))
     
    421441        }
    422442        if (!hit) {
    423           var max = row.Values.Last();
    424           if (misses[key].ContainsKey(max.Item1))
    425             misses[key][max.Item1]++;
    426           else misses[key][max.Item1] = 1;
     443          var max = Math.Min(row.Values.Last().Item1, maxEffort);
     444          if (misses[key].ContainsKey(max))
     445            misses[key][max]++;
     446          else misses[key][max] = 1;
    427447        }
    428448      }
     
    432452                                              Dictionary<string, SortedList<double, int>> misses,
    433453                                              IndexedDataRow<double> row, ProblemDescription problem,
    434                                               string group, double bestTarget) {
     454                                              string group, double bestTarget, double maxEffort) {
    435455      var values = row.Values;
    436456      if (!hits.ContainsKey(group)) {
     
    444464        var target = (problem.IsMaximization() ? (1 - targets[i]) : (1 + targets[i])) * bestTarget;
    445465        var current = values[j];
     466        if (current.Item1 > maxEffort) break;
    446467        if (problem.IsMaximization() && current.Item2 >= target
    447468          || !problem.IsMaximization() && current.Item2 <= target) {
     
    454475      }
    455476      if (j == values.Count) j--;
     477      var effort = Math.Min(values[j].Item1, maxEffort);
    456478      if (i < targets.Length) {
    457         if (misses[group].ContainsKey(values[j].Item1))
    458           misses[group][values[j].Item1] += targets.Length - i;
    459         else misses[group][values[j].Item1] = targets.Length - i;
    460       }
    461       return values[j].Item1;
     479        if (misses[group].ContainsKey(effort))
     480          misses[group][effort] += targets.Length - i;
     481        else misses[group][effort] = targets.Length - i;
     482      }
     483      return effort;
    462484    }
    463485
Note: See TracChangeset for help on using the changeset viewer.