Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/18/15 12:42:13 (9 years ago)
Author:
abeham
Message:

#2457:

  • fixed bugs in iterated sampling view
  • worked on download runs from okb feature
File:
1 edited

Legend:

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

    r13475 r13485  
    2626using System.Linq;
    2727using System.Windows.Forms.DataVisualization.Charting;
    28 using HeuristicLab.MainForm.WindowsForms;
    29 using HeuristicLab.MainForm;
    3028using HeuristicLab.Analysis;
    3129using HeuristicLab.Common;
    3230using HeuristicLab.Data;
     31using HeuristicLab.MainForm;
     32using HeuristicLab.MainForm.WindowsForms;
    3333
    3434namespace HeuristicLab.Optimization.Views.RunCollectionViews {
     
    268268      bestProbability = 1.0;
    269269      var bestProbabilityEffort = 0.0;
     270      var succ = 0;
    270271      foreach (var d in data) {
    271272        if (double.IsNaN(d.Item2)) continue;
    272         double succ = 0.0, unsucc = 0.0;
    273         foreach (var e in data) {
    274           if (e.Item1 <= d.Item1 && HasAchievedTarget(maximization, e, target)) succ++;
    275           else if (e.Item1 >= d.Item1) unsucc++;
    276         }
     273        if (HasAchievedTarget(maximization, d, target)) succ++;
    277274        // probability of having no successful run with effort d.Item1
    278         var prob = (1.0 - succ / (succ + unsucc));
     275        var prob = (1.0 - succ / (double)data.Count);
    279276        // normalizing probability to effort 1 (assuming exponential convergence)
    280277        prob = Math.Pow(prob, 1.0 / d.Item1);
     
    293290    private void UpdateGraph(double cutoff, double bestProbability, double target, bool maximization) {
    294291      var table = (string)dataTableComboBox.SelectedItem;
    295       var result = ExpectedRuntimeHelper.CalculateErt(GetRunsFiltered().ToList(), table, target, maximization);
    296       var lambda = 1.0 / result.ExpectedRuntime;
    297292      var runs = GetRunsFiltered().Select(x => (IndexedDataTable<double>)x.Results[table]).ToList();
    298293      var evaluations = runs.SelectMany(x => x.Rows.First().Values.Select(y => y.Item1)).Distinct().OrderBy(x => x).ToList();
     
    332327      }
    333328
    334       var minimum = hits.First(x => x.Value > 0).Key;
    335 
    336329      enhancedChart.SuspendRepaint();
    337330
     
    346339      var series2 = enhancedChart.Series["rldApproximationSeries"];
    347340      series2.Points.Clear();
    348       foreach (var e in Enumerable.Range(0, (int)Math.Ceiling(evaluations.Max()))) {
    349         series2.Points.AddXY(e, Math.Max(0, 1.0 - Math.Exp(-lambda * (e - minimum))));
     341      var evalMax = evaluations.Max();
     342      var steps = evalMax / 100.0;
     343
     344      var result = ExpectedRuntimeHelper.CalculateErt(GetRunsFiltered().ToList(), table, target, maximization);
     345      var lambda = 1.0 / result.ExpectedRuntime;
     346      foreach (var e in Enumerable.Range(0, 100)) {
     347        var x = e * steps;
     348        series2.Points.AddXY(x, Math.Max(0, 1.0 - Math.Exp(-lambda * x)));
    350349      }
    351350      var series3 = enhancedChart.Series["optimalSeries"];
    352351      series3.Points.Clear();
    353       lambda = -Math.Log(bestProbability);
    354       foreach (var e in Enumerable.Range(0, (int)Math.Ceiling(evaluations.Max())))
    355         series3.Points.AddXY(e, Math.Max(0, 1.0 - Math.Exp(-lambda * (e - minimum))));
     352      if (bestProbability <= 0) bestProbability = 1 - lambda;
     353      foreach (var e in Enumerable.Range(0, 100)) {
     354        var x = e * steps;
     355        series3.Points.AddXY(x, Math.Max(0, 1.0 - Math.Pow(bestProbability, x)));
     356      }
    356357
    357358      enhancedChart.Annotations.Clear();
     
    359360        var annotation = new VerticalLineAnnotation();
    360361        annotation.AnchorDataPoint = series.Points[cutOffIdx];
    361         annotation.Height = -20;
     362        annotation.Height = series.Points[cutOffIdx].YValues[0] > enhancedChart.ChartAreas[series.ChartArea].AxisY.Maximum / 2.0 ? 10 : -10;
    362363        annotation.LineWidth = 2;
    363364        annotation.StartCap = LineAnchorCapStyle.Arrow;
Note: See TracChangeset for help on using the changeset viewer.