Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/24/22 21:45:48 (2 years ago)
Author:
gkronber
Message:

#3134: bugfixes and improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RunCollectionPartialDependencePlotView.cs

    r18052 r18208  
    11using System.Collections.Generic;
    22using System.Linq;
     3using System.Threading.Tasks;
    34using System.Windows.Forms;
    45using HeuristicLab.MainForm;
     
    2021    }
    2122
    22     private static async void AddSolution(RegressionSolutionPartialDependencePlotView plot, IEnumerable<IRegressionSolution> solutions) {
    23       foreach(var sol in solutions) {
    24         await plot.AddSolution(sol);
     23    protected override async void OnContentChanged() {
     24      base.OnContentChanged();
     25      if (Content == null) {
     26        tabControl.TabPages.Clear();
     27        return;
    2528      }
    26     }
     29      // distinct names of results of types IRegressionSolution
     30      var solutionResultNames = Content.SelectMany(run => run.Results.Where(kvp => kvp.Value is IRegressionSolution).Select(kvp => kvp.Key)).Distinct().ToArray();
    2731
    28     protected override void OnContentChanged() {
    29       base.OnContentChanged();
     32      foreach (var resultName in solutionResultNames) {
     33        var tabPage = new TabPage(resultName);
     34        tabControl.TabPages.Add(tabPage);
    3035
    31       if (Content == null) return;
     36        var solutions = new List<IRegressionSolution>();
     37        foreach (var run in Content) {
     38          // in experiments we may mix algorithms and therefore have different solution names in different runs
     39          // we only combine solutions with the same name
     40          if (run.Results.TryGetValue(resultName, out var sol) && sol is IRegressionSolution) {
     41            solutions.Add((IRegressionSolution)sol);
     42          }
     43        }
     44        var plot = new RegressionSolutionPartialDependencePlotView {
     45          Content = solutions[0],
     46          Dock = DockStyle.Fill
     47        };
    3248
    33       var solutions = Content.Select(run => (IRegressionSolution)run.Results["Best training solution"]).ToList();
    34       var plot = new RegressionSolutionPartialDependencePlotView {
    35         Content = solutions[0],
    36         Dock = DockStyle.Fill
    37       };
    38 
    39       mainPanel.Controls.Add(plot);
    40       AddSolution(plot, solutions);
     49        tabPage.Controls.Add(plot);
     50        for (int i = 1; i < solutions.Count; i++)
     51          await plot.AddSolutionAsync(solutions[i]);
     52      }
    4153    }
    4254  }
Note: See TracChangeset for help on using the changeset viewer.