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
Location:
branches/PerformanceComparison
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Analysis.Views/3.3/IndexedDataTableView.cs

    r12771 r12808  
    128128      chart.ChartAreas[0].AxisY.Title = string.Empty;
    129129      chart.ChartAreas[0].AxisY2.Title = string.Empty;
     130      chart.ChartAreas[0].AxisX.IsLogarithmic = false;
     131      chart.ChartAreas[0].AxisX2.IsLogarithmic = false;
     132      chart.ChartAreas[0].AxisY.IsLogarithmic = false;
     133      chart.ChartAreas[0].AxisY2.IsLogarithmic = false;
    130134      chart.Series.Clear();
    131135      if (Content != null) {
     
    234238        area.AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
    235239      }
    236 
    237       area.AxisX.IsLogarithmic = Content.VisualProperties.XAxisLogScale;
    238       area.AxisX2.IsLogarithmic = Content.VisualProperties.SecondXAxisLogScale;
    239       area.AxisY.IsLogarithmic = Content.VisualProperties.YAxisLogScale;
    240       area.AxisY2.IsLogarithmic = Content.VisualProperties.SecondYAxisLogScale;
    241240    }
    242241
     
    247246        a.Maximum = double.NaN;
    248247      }
     248      // chart controls handle log scaling problems not in a graceful way
     249      if (chart.Series.Any(x => x.XAxisType == AxisType.Primary && (x.Points.Count == 0 || x.Points.Any(y => y.XValue <= 0))))
     250        area.AxisX.IsLogarithmic = false;
     251      else area.AxisX.IsLogarithmic = Content.VisualProperties.XAxisLogScale;
     252      if (chart.Series.Any(x => x.XAxisType == AxisType.Secondary && (x.Points.Count == 0 || x.Points.Any(y => y.XValue <= 0))))
     253        area.AxisX2.IsLogarithmic = false;
     254      else area.AxisX2.IsLogarithmic = Content.VisualProperties.SecondXAxisLogScale;
     255
     256      if (chart.Series.Any(x => x.YAxisType == AxisType.Primary && (x.Points.Count == 0 || x.Points.Any(y => y.YValues.Min() <= 0))))
     257        area.AxisY.IsLogarithmic = false;
     258      else area.AxisY.IsLogarithmic = Content.VisualProperties.YAxisLogScale;
     259      if (chart.Series.Any(x => x.YAxisType == AxisType.Secondary && (x.Points.Count == 0 || x.Points.Any(y => y.YValues.Min() <= 0))))
     260        area.AxisY2.IsLogarithmic = false;
     261      else area.AxisY2.IsLogarithmic = Content.VisualProperties.SecondYAxisLogScale;
     262
    249263      area.RecalculateAxesScale();
    250264      area.AxisX.IsMarginVisible = false;
  • branches/PerformanceComparison/HeuristicLab.Analysis/3.3/Optimizers/IRRestarter.cs

    r12804 r12808  
    3333
    3434namespace HeuristicLab.Analysis {
    35   public enum TerminationCriterium { OnlyByTime, OnlyByEvaluations, OnlyByTarget, ByTargetAndTime, ByTargetAndEvaluations, WhicheverHitsFirst, WhicheverHitsLast }
     35  public enum TerminationCriterium { OnlyByTime, OnlyByEvaluations, OnlyByTarget, ByTargetAndTime, ByTargetAndEvaluations, ByTimeAndEvaluations, WhicheverHitsFirst, WhicheverHitsLast }
    3636  /// <summary>
    3737  /// A run in which an algorithm is executed for a certain maximum time only.
     
    4343    private const string ExecutionTimeResultName = "Execution Time";
    4444    private const string BestQualityResultName = "BestQuality";
     45    private const string RandomRestartsResultName = "RandomRestarts";
    4546
    4647    public string Filename { get; set; }
     
    153154    }
    154155
    155     private int lastAlgorithmEvaluatedSolutions;
    156     private int lastAlgorithmEvaluatedMoves;
    157156    [Storable]
    158157    private double evaluations;
     
    239238        return timeHit && evalHit && targetHit
    240239          || timeHit && (TerminationCriterium == TerminationCriterium.OnlyByTime
     240                      || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst
    241241                      || TerminationCriterium == TerminationCriterium.ByTargetAndTime
    242                       || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst)
     242                      || TerminationCriterium == TerminationCriterium.ByTimeAndEvaluations)
    243243          || evalHit && (TerminationCriterium == TerminationCriterium.OnlyByEvaluations
     244                      || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst
    244245                      || TerminationCriterium == TerminationCriterium.ByTargetAndEvaluations
    245                       || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst)
     246                      || TerminationCriterium == TerminationCriterium.ByTimeAndEvaluations)
    246247          || targetHit && (TerminationCriterium == TerminationCriterium.OnlyByTarget
    247248                        || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst
     
    267268      bestSoFar = original.bestSoFar;
    268269      lastAlgorithmExecutionTime = original.lastAlgorithmExecutionTime;
    269       lastAlgorithmEvaluatedSolutions = original.lastAlgorithmEvaluatedSolutions;
    270       lastAlgorithmEvaluatedMoves = original.lastAlgorithmEvaluatedMoves;
    271270
    272271      perClockAnalyzer = cloner.Clone(original.perClockAnalyzer);
     
    294293      bestSoFar = double.NaN;
    295294      lastAlgorithmExecutionTime = TimeSpan.Zero;
    296       lastAlgorithmEvaluatedSolutions = 0;
    297       lastAlgorithmEvaluatedMoves = 0;
    298295
    299296      perClockAnalyzer = new QualityPerClockAnalyzer();
     
    316313      bestSoFar = double.NaN;
    317314      lastAlgorithmExecutionTime = TimeSpan.Zero;
    318       lastAlgorithmEvaluatedSolutions = 0;
    319       lastAlgorithmEvaluatedMoves = 0;
    320315
    321316      perClockAnalyzer = new QualityPerClockAnalyzer();
     
    337332      bestSoFar = double.NaN;
    338333      lastAlgorithmExecutionTime = TimeSpan.Zero;
    339       lastAlgorithmEvaluatedSolutions = 0;
    340       lastAlgorithmEvaluatedMoves = 0;
    341334
    342335      perClockAnalyzer = new QualityPerClockAnalyzer();
     
    366359      BestSoFar = double.NaN;
    367360      lastAlgorithmExecutionTime = TimeSpan.Zero;
    368       lastAlgorithmEvaluatedSolutions = 0;
    369       lastAlgorithmEvaluatedMoves = 0;
    370361
    371362      CurrentRun = null;
     
    399390        CurrentRun.Results.Add(perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName, new IntValue(0));
    400391        CurrentRun.Results.Add(BestQualityResultName, new DoubleValue(Maximization ? double.MinValue : double.MaxValue));
     392        CurrentRun.Results.Add(RandomRestartsResultName, new IntValue(0));
    401393      }
    402394      Algorithm.Start();
     
    492484      algorithm.ExceptionOccurred += Algorithm_ExceptionOccurred;
    493485      algorithm.ExecutionTimeChanged += Algorithm_ExecutionTimeChanged;
    494       algorithm.ExecutionStateChanged += Algorithm_ExecutionStateChanged;
    495486      algorithm.Paused += Algorithm_Paused;
    496487      algorithm.Prepared += Algorithm_Prepared;
    497       algorithm.Started += Algorithm_Started;
    498488      algorithm.Stopped += Algorithm_Stopped;
    499489      algorithm.ProblemChanged += Algorithm_ProblemChanged;
     
    503493      algorithm.ExceptionOccurred -= Algorithm_ExceptionOccurred;
    504494      algorithm.ExecutionTimeChanged -= Algorithm_ExecutionTimeChanged;
    505       algorithm.ExecutionStateChanged -= Algorithm_ExecutionStateChanged;
    506495      algorithm.Paused -= Algorithm_Paused;
    507496      algorithm.Prepared -= Algorithm_Prepared;
    508       algorithm.Started -= Algorithm_Started;
    509497      algorithm.Stopped -= Algorithm_Stopped;
    510498      algorithm.ProblemChanged -= Algorithm_ProblemChanged;
     
    514502    }
    515503    private void Algorithm_ExecutionTimeChanged(object sender, EventArgs e) {
    516       if (Algorithm.ExecutionState != ExecutionState.Started) return;
    517 
    518       if (ExecutionState == ExecutionState.Started)
    519         UpdateAlgorithmResults();
    520 
    521       if (IsFinished && ExecutionState != ExecutionState.Stopped) {
    522         Algorithm.Stop();
    523       }
    524       OnExecutionTimeChanged();
    525     }
    526 
    527     private void Algorithm_ExecutionStateChanged(object sender, EventArgs e) {
    528       //OnExecutionStateChanged();
     504      ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime;
     505      lastAlgorithmExecutionTime = Algorithm.ExecutionTime;
    529506    }
    530507    private void Algorithm_Paused(object sender, EventArgs e) {
    531       UpdateAlgorithmResults();
     508      ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime;
     509      lastAlgorithmExecutionTime = Algorithm.ExecutionTime;
    532510      OnPaused();
    533511    }
    534512    private void Algorithm_Prepared(object sender, EventArgs e) {
    535       lastAlgorithmEvaluatedSolutions = 0;
    536       lastAlgorithmEvaluatedMoves = 0;
    537513      lastAlgorithmExecutionTime = TimeSpan.Zero;
    538     }
    539     private void Algorithm_Started(object sender, EventArgs e) {
    540       //OnStarted();
    541514    }
    542515    private void Algorithm_Stopped(object sender, EventArgs e) {
    543516      var bestQuality = UpdateAlgorithmResults();
    544517
    545       var execTime = ((TimeSpanValue)currentRun.Results[ExecutionTimeResultName]).Value;
     518      var execTime = ((TimeSpanValue)CurrentRun.Results[ExecutionTimeResultName]).Value;
    546519      foreach (var result in Algorithm.Results) {
    547520        if (result.Name == perClockAnalyzer.QualityPerClockParameter.ResultName) {
    548           if (!currentRun.Results.ContainsKey(result.Name))
    549             currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     521          if (!CurrentRun.Results.ContainsKey(result.Name))
     522            CurrentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
    550523          else {
    551             var dt = (IndexedDataTable<double>)currentRun.Results[result.Name];
     524            var dt = (IndexedDataTable<double>)CurrentRun.Results[result.Name];
    552525            var best = dt.Rows.First().Values.Last().Item2;
    553526            var resultDt = (IndexedDataTable<double>)result.Value;
     
    560533          }
    561534        } else if (result.Name == perEvaluationsAnalyzer.QualityPerEvaluationsParameter.ResultName) {
    562           if (!currentRun.Results.ContainsKey(result.Name))
    563             currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     535          if (!CurrentRun.Results.ContainsKey(result.Name))
     536            CurrentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
    564537          else {
    565             var dt = (IndexedDataTable<double>)currentRun.Results[result.Name];
    566             var evalSols = ((IntValue)currentRun.Results[perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName]).Value;
    567             var evalMoves = ((IntValue)currentRun.Results[perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName]).Value;
     538            var dt = (IndexedDataTable<double>)CurrentRun.Results[result.Name];
     539            var evalSols = ((IntValue)CurrentRun.Results[perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName]).Value;
     540            var evalMoves = ((IntValue)CurrentRun.Results[perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName]).Value;
    568541            var best = dt.Rows.First().Values.Last().Item2;
    569542            var resultDt = (IndexedDataTable<double>)result.Value;
     
    576549          }
    577550        } else if (result.Name == perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName) {
    578           var evalSols = ((IntValue)currentRun.Results[perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName]);
    579           evalSols.Value += ((IntValue)result.Value).Value;
     551          var evalSols = ((IntValue)CurrentRun.Results[perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName]).Value;
     552          CurrentRun.Results[perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName] = new IntValue(evalSols + ((IntValue)result.Value).Value);
    580553        } else if (result.Name == perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName) {
    581           var evalMoves = ((IntValue)currentRun.Results[perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName]);
    582           evalMoves.Value += ((IntValue)result.Value).Value;
     554          var evalMoves = ((IntValue)CurrentRun.Results[perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName]).Value;
     555          CurrentRun.Results[perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName] = new IntValue(evalMoves + ((IntValue)result.Value).Value);
    583556        } else if (result.Name == perEvaluationsAnalyzer.BestQualityParameter.ActualName) {
    584           var best = ((DoubleValue)currentRun.Results[BestQualityResultName]).Value;
     557          var best = ((DoubleValue)CurrentRun.Results[BestQualityResultName]).Value;
    585558          if (Maximization && best < bestQuality || !Maximization && best > bestQuality)
    586             currentRun.Results[BestQualityResultName] = new DoubleValue(bestQuality);
     559            CurrentRun.Results[BestQualityResultName] = new DoubleValue(bestQuality);
    587560        } else if (result.Name.ToLower().EndsWith("solution") && BestSoFar == bestQuality) {
    588           if (currentRun.Results.ContainsKey(result.Name))
    589             currentRun.Results[result.Name] = (IItem)result.Value.Clone();
    590           else currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     561          if (CurrentRun.Results.ContainsKey(result.Name))
     562            CurrentRun.Results[result.Name] = (IItem)result.Value.Clone();
     563          else CurrentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
    591564        }
    592565      }
    593       currentRun.Results[ExecutionTimeResultName] = new TimeSpanValue(execTime + Algorithm.ExecutionTime);
     566      CurrentRun.Results[ExecutionTimeResultName] = new TimeSpanValue(execTime + Algorithm.ExecutionTime);
    594567
    595568      if (!forceStop && !IsFinished) {
     569        CurrentRun.Results[RandomRestartsResultName] = new IntValue(1 + ((IntValue)CurrentRun.Results[RandomRestartsResultName]).Value);
    596570        Algorithm.Prepare();
    597571        Algorithm.Start();
    598572      } else {
    599573        forceStop = false;
    600         Runs.Add(currentRun);
    601         currentRun = null;
     574        Runs.Add(CurrentRun);
    602575        Algorithm.Prepare(true);
    603576        ExecutionState = ExecutionState.Stopped;
     
    613586      if (Algorithm.Results.TryGetValue(perEvaluationsAnalyzer.EvaluatedSolutionsParameter.ActualName, out evaluationsResult)) {
    614587        var evals = ((IntValue)evaluationsResult.Value).Value;
    615         Evaluations += evals - lastAlgorithmEvaluatedSolutions;
    616         lastAlgorithmEvaluatedSolutions = evals;
     588        Evaluations += evals;
    617589      }
    618590      if (Algorithm.Results.TryGetValue(perEvaluationsAnalyzer.EvaluatedMovesParameter.ActualName, out evaluationsResult)) {
    619591        var evals = ((IntValue)evaluationsResult.Value).Value;
    620         Evaluations += moveCostPerSolution * (evals - lastAlgorithmEvaluatedMoves);
    621         lastAlgorithmEvaluatedMoves = evals;
     592        Evaluations += moveCostPerSolution * evals;
    622593      }
    623594      if (Algorithm.Results.TryGetValue(perEvaluationsAnalyzer.BestQualityParameter.ActualName, out evaluationsResult)) {
  • branches/PerformanceComparison/HeuristicLab.Analysis/3.3/QualityAnalysis/QualityPerClockAnalyzer.cs

    r12804 r12808  
    6565        Rows = { new IndexedDataRow<double>("First-hit Graph") { VisualProperties = {
    6666          ChartType = DataRowVisualProperties.DataRowChartType.StepLine,
    67           LineWidth = 3
     67          LineWidth = 2
    6868        } } }
    6969      };
  • branches/PerformanceComparison/HeuristicLab.Analysis/3.3/QualityAnalysis/QualityPerEvaluationsAnalyzer.cs

    r12804 r12808  
    7171        Rows = { new IndexedDataRow<double>("First-hit Graph") { VisualProperties = {
    7272          ChartType = DataRowVisualProperties.DataRowChartType.StepLine,
    73           LineWidth = 3
     73          LineWidth = 2
    7474        } } }
    7575      };
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.Designer.cs

    r12806 r12808  
    6060      this.budgetsTextBox = new System.Windows.Forms.TextBox();
    6161      this.fixedCostButton = new System.Windows.Forms.Button();
     62      this.allOrEachTargetCheckBox = new System.Windows.Forms.CheckBox();
    6263      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6364      this.SuspendLayout();
     
    139140      this.targetsTextBox.Location = new System.Drawing.Point(69, 57);
    140141      this.targetsTextBox.Name = "targetsTextBox";
    141       this.targetsTextBox.Size = new System.Drawing.Size(265, 20);
     142      this.targetsTextBox.Size = new System.Drawing.Size(209, 20);
    142143      this.targetsTextBox.TabIndex = 6;
    143144      this.toolTip.SetToolTip(this.targetsTextBox, "The order of the targets is important, first to-hit targets\r\nshould be given firs" +
     
    213214      this.fixedCostButton.Click += new System.EventHandler(this.fixedCostButton_Click);
    214215      //
     216      // allOrEachTargetCheckBox
     217      //
     218      this.allOrEachTargetCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     219      this.allOrEachTargetCheckBox.AutoSize = true;
     220      this.allOrEachTargetCheckBox.Location = new System.Drawing.Point(298, 59);
     221      this.allOrEachTargetCheckBox.Name = "allOrEachTargetCheckBox";
     222      this.allOrEachTargetCheckBox.Size = new System.Drawing.Size(36, 17);
     223      this.allOrEachTargetCheckBox.TabIndex = 8;
     224      this.allOrEachTargetCheckBox.Text = "all";
     225      this.allOrEachTargetCheckBox.UseVisualStyleBackColor = true;
     226      this.allOrEachTargetCheckBox.CheckedChanged += new System.EventHandler(this.allOrEachTargetCheckBox_CheckedChanged);
     227      //
    215228      // RunCollectionRLDView
    216229      //
    217230      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     231      this.Controls.Add(this.allOrEachTargetCheckBox);
    218232      this.Controls.Add(this.generateTargetsButton);
    219233      this.Controls.Add(this.fixedCostButton);
     
    254268    private System.Windows.Forms.TextBox budgetsTextBox;
    255269    private System.Windows.Forms.Label budgetsLabel;
     270    private System.Windows.Forms.CheckBox allOrEachTargetCheckBox;
    256271  }
    257272}
  • 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.