1 | using System.Collections.Generic;
|
---|
2 | using System.Linq;
|
---|
3 | using System.Threading.Tasks;
|
---|
4 | using System.Windows.Forms;
|
---|
5 | using HeuristicLab.MainForm;
|
---|
6 | using HeuristicLab.MainForm.WindowsForms;
|
---|
7 | using HeuristicLab.Optimization;
|
---|
8 | using HeuristicLab.Problems.DataAnalysis.Views;
|
---|
9 |
|
---|
10 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
|
---|
11 | [Content(typeof(RunCollection), false)]
|
---|
12 | [View("RunCollection Partial Dependence Plots")]
|
---|
13 | public partial class RunCollectionPartialDependencePlotView : AsynchronousContentView {
|
---|
14 | public new RunCollection Content {
|
---|
15 | get => (RunCollection)base.Content;
|
---|
16 | set => base.Content = value;
|
---|
17 | }
|
---|
18 |
|
---|
19 | public RunCollectionPartialDependencePlotView() {
|
---|
20 | InitializeComponent();
|
---|
21 | }
|
---|
22 |
|
---|
23 | protected override async void OnContentChanged() {
|
---|
24 | base.OnContentChanged();
|
---|
25 | if (Content == null) {
|
---|
26 | tabControl.TabPages.Clear();
|
---|
27 | return;
|
---|
28 | }
|
---|
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();
|
---|
31 |
|
---|
32 | foreach (var resultName in solutionResultNames) {
|
---|
33 | var tabPage = new TabPage(resultName);
|
---|
34 | tabControl.TabPages.Add(tabPage);
|
---|
35 |
|
---|
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 | };
|
---|
48 |
|
---|
49 | tabPage.Controls.Add(plot);
|
---|
50 | for (int i = 1; i < solutions.Count; i++)
|
---|
51 | await plot.AddSolutionAsync(solutions[i]);
|
---|
52 | }
|
---|
53 | }
|
---|
54 | }
|
---|
55 | }
|
---|