- Timestamp:
- 03/12/13 21:52:28 (12 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.cs
r8587 r9315 181 181 activeView.CaptionChanged += new EventHandler(activeView_CaptionChanged); 182 182 activeView.LockedChanged += new EventHandler(activeView_LockedChanged); 183 activeView.Changed += new EventHandler(activeView_Changed); 183 184 } 184 185 private void DeregisterActiveViewEvents() { 185 186 activeView.CaptionChanged -= new EventHandler(activeView_CaptionChanged); 186 187 activeView.LockedChanged -= new EventHandler(activeView_LockedChanged); 188 activeView.Changed -= new EventHandler(activeView_Changed); 187 189 } 188 190 private void activeView_CaptionChanged(object sender, EventArgs e) { … … 192 194 Locked = activeView.Locked; 193 195 configurationLabel.Enabled = !activeView.Locked; 196 } 197 private void activeView_Changed(object sender, EventArgs e) { 198 OnChanged(); 194 199 } 195 200 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs
r9312 r9315 556 556 } 557 557 } 558 558 559 this.chart.ChartAreas[0].CursorX.SelectionStart = this.chart.ChartAreas[0].CursorX.SelectionEnd; 559 560 this.chart.ChartAreas[0].CursorY.SelectionStart = this.chart.ChartAreas[0].CursorY.SelectionEnd; 561 this.OnChanged(); 560 562 } 561 563 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/MenuItems/CreateEnsembleMenuItem.cs
r7738 r9315 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.MainForm; 28 using HeuristicLab.MainForm.WindowsForms; 28 29 using HeuristicLab.Optimization; 30 using HeuristicLab.Optimization.Views; 29 31 using HeuristicLab.Optimizer; 30 32 … … 49 51 protected override void OnActiveViewChanged(object sender, EventArgs e) { 50 52 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 51 if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IOptimizer) && !activeView.Locked) {52 var optimizer = activeView.Content as IOptimizer;53 ToolStripItem.Enabled = GetDataAnalysisResults(optimizer).Any();54 } else {55 ToolStripItem.Enabled = false;56 }53 ToolStripItem.Enabled = GetDataAnalysisResults(activeView).Any(); 54 } 55 protected override void OnViewChanged(object sender, EventArgs e) { 56 base.OnViewChanged(sender, e); 57 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 58 ToolStripItem.Enabled = GetDataAnalysisResults(activeView).Any(); 57 59 } 58 60 59 61 public override void Execute() { 60 62 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 61 if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IOptimizer) && !activeView.Locked) { 62 var optimizer = activeView.Content as IOptimizer; 63 var solutionGroups = from pair in GetDataAnalysisResults(optimizer) 64 group pair.Value by pair.Key into g 65 select g; 66 foreach (var group in solutionGroups) { 67 // check if all solutions in the group are either only regression or only classification solutions 68 if (group.All(s => s is IRegressionSolution)) { 69 // show all regression ensembles 70 // clone problemdata (N.B. this assumes all solutions are based on the same problem data!) 71 var problemData = (RegressionProblemData)group 72 .OfType<IRegressionSolution>() 73 .First() 74 .ProblemData.Clone(); 75 var ensemble = new RegressionEnsembleSolution(problemData); 76 ensemble.Name = group.Key + " ensemble"; 77 var nestedSolutions = group.OfType<RegressionEnsembleSolution>().SelectMany(e => e.RegressionSolutions); 78 var solutions = group.Where(s => !(s is RegressionEnsembleSolution)).OfType<IRegressionSolution>(); 79 ensemble.AddRegressionSolutions(nestedSolutions.Concat(solutions)); 80 MainFormManager.MainForm.ShowContent(ensemble); 81 } else if (group.All(s => s is IClassificationSolution)) { 82 // show all classification ensembles 83 var problemData = (ClassificationProblemData)group 84 .OfType<IClassificationSolution>() 85 .First() 86 .ProblemData.Clone(); 87 var ensemble = new ClassificationEnsembleSolution(Enumerable.Empty<IClassificationModel>(), problemData); 88 ensemble.Name = group.Key + " ensemble"; 89 var nestedSolutions = group.OfType<ClassificationEnsembleSolution>().SelectMany(e => e.ClassificationSolutions); 90 var solutions = group.Where(s => !(s is ClassificationEnsembleSolution)).OfType<IClassificationSolution>(); 91 ensemble.AddClassificationSolutions(nestedSolutions.Concat(solutions)); 92 MainFormManager.MainForm.ShowContent(ensemble); 93 } 63 var solutionGroups = from pair in GetDataAnalysisResults(activeView) 64 group pair.Value by pair.Key into g 65 select g; 66 foreach (var group in solutionGroups) { 67 // check if all solutions in the group are either only regression or only classification solutions 68 if (group.All(s => s is IRegressionSolution)) { 69 // show all regression ensembles 70 // clone problemdata (N.B. this assumes all solutions are based on the same problem data!) 71 var problemData = (RegressionProblemData)group 72 .OfType<IRegressionSolution>() 73 .First() 74 .ProblemData.Clone(); 75 var ensemble = new RegressionEnsembleSolution(problemData); 76 ensemble.Name = group.Key + " ensemble"; 77 var nestedSolutions = group.OfType<RegressionEnsembleSolution>().SelectMany(e => e.RegressionSolutions); 78 var solutions = group.Where(s => !(s is RegressionEnsembleSolution)).OfType<IRegressionSolution>(); 79 ensemble.AddRegressionSolutions(nestedSolutions.Concat(solutions)); 80 MainFormManager.MainForm.ShowContent(ensemble); 81 } else if (group.All(s => s is IClassificationSolution)) { 82 // show all classification ensembles 83 var problemData = (ClassificationProblemData)group 84 .OfType<IClassificationSolution>() 85 .First() 86 .ProblemData.Clone(); 87 var ensemble = new ClassificationEnsembleSolution(Enumerable.Empty<IClassificationModel>(), problemData); 88 ensemble.Name = group.Key + " ensemble"; 89 var nestedSolutions = group.OfType<ClassificationEnsembleSolution>().SelectMany(e => e.ClassificationSolutions); 90 var solutions = group.Where(s => !(s is ClassificationEnsembleSolution)).OfType<IClassificationSolution>(); 91 ensemble.AddClassificationSolutions(nestedSolutions.Concat(solutions)); 92 MainFormManager.MainForm.ShowContent(ensemble); 94 93 } 95 94 } 96 95 } 97 96 98 private IEnumerable<KeyValuePair<string, IItem>> GetDataAnalysisResults(IOptimizer optimizer) { 99 var allResults = from r in optimizer.Runs 97 private IEnumerable<KeyValuePair<string, IItem>> GetDataAnalysisResults(IContentView view) { 98 var empty = Enumerable.Empty<KeyValuePair<string, IItem>>(); 99 if (view == null) return empty; 100 if (view.Content == null) return empty; 101 if (view.Locked) return empty; 102 103 var optimizer = view.Content as IOptimizer; 104 if (optimizer != null) return GetDataAnalysisResults(optimizer.Runs); 105 106 RunCollectionBubbleChartView bubbleChart; 107 var viewHost = view as ViewHost; 108 if (viewHost != null) 109 bubbleChart = viewHost.ActiveView as RunCollectionBubbleChartView; 110 else bubbleChart = view as RunCollectionBubbleChartView; 111 if (bubbleChart != null && bubbleChart.SelectedRuns.Any()) return GetDataAnalysisResults(bubbleChart.SelectedRuns); 112 113 return empty; 114 } 115 116 private IEnumerable<KeyValuePair<string, IItem>> GetDataAnalysisResults(IEnumerable<IRun> runs) { 117 var allResults = from r in runs 100 118 select r.Results; 101 119 return from r in allResults
Note: See TracChangeset
for help on using the changeset viewer.