- Timestamp:
- 01/30/18 13:53:04 (7 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs
r15665 r15673 19 19 */ 20 20 #endregion 21 using System;22 using System.Linq;23 21 24 22 namespace HeuristicLab.Problems.DataAnalysis.Views { -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r15665 r15673 32 32 [Content(typeof(IRegressionSolution))] 33 33 public partial class RegressionSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView { 34 private enum SortingCriteria { 35 ImpactValue, 36 Occurrence, 37 VariableName 38 } 39 34 40 private Dictionary<string, double> rawVariableImpacts = new Dictionary<string, double>(); 35 41 … … 46 52 47 53 //Little workaround. If you fill the ComboBox-Items in the other partial class, the UI-Designer will moan. 48 this.sortByComboBox.Items.AddRange(Enum.GetValues(typeof( RegressionSolutionVariableImpactsCalculator.SortingCriteria)).Cast<object>().ToArray());49 this.sortByComboBox.SelectedItem = RegressionSolutionVariableImpactsCalculator.SortingCriteria.ImpactValue;54 this.sortByComboBox.Items.AddRange(Enum.GetValues(typeof(SortingCriteria)).Cast<object>().ToArray()); 55 this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue; 50 56 51 57 this.dataPartitionComboBox.SelectedIndex = 0; … … 96 102 //Update the default ordering (asc,desc), but remove the eventHandler beforehand (otherwise the data would be ordered twice) 97 103 ascendingCheckBox.CheckedChanged -= ascendingCheckBox_CheckedChanged; 98 switch (( RegressionSolutionVariableImpactsCalculator.SortingCriteria)sortByComboBox.SelectedItem) {99 case RegressionSolutionVariableImpactsCalculator.SortingCriteria.ImpactValue:104 switch ((SortingCriteria)sortByComboBox.SelectedItem) { 105 case SortingCriteria.ImpactValue: 100 106 ascendingCheckBox.Checked = false; 101 107 break; 102 case RegressionSolutionVariableImpactsCalculator.SortingCriteria.Occurrence:108 case SortingCriteria.Occurrence: 103 109 ascendingCheckBox.Checked = true; 104 110 break; 105 case RegressionSolutionVariableImpactsCalculator.SortingCriteria.VariableName:111 case SortingCriteria.VariableName: 106 112 ascendingCheckBox.Checked = true; 107 113 break; 108 114 default: 109 throw new Exception("Cannot interpret SortingCriteria");115 throw new NotImplementedException("Ordering for selected SortingCriteria not implemented"); 110 116 } 111 117 ascendingCheckBox.CheckedChanged += ascendingCheckBox_CheckedChanged; … … 121 127 #region Helper Methods 122 128 private void UpdateVariableImpacts() { 123 if (Content == null || replacementComboBox.SelectedIndex < 0 124 || factorVarReplComboBox.SelectedIndex < 0 125 || dataPartitionComboBox.SelectedIndex < 0) return; 129 if (Content == null) { return; } 130 if (replacementComboBox.SelectedIndex < 0) { return; } 131 if (dataPartitionComboBox.SelectedIndex < 0) { return; } 132 if (factorVarReplComboBox.SelectedIndex < 0) { return; } 133 134 variableImactsArrayView.Caption = Content.Name + " Variable Impacts"; 135 126 136 var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm; 127 variableImactsArrayView.Caption = Content.Name + " Variable Impacts"; 128 var replMethod = 129 (RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum) 130 replacementComboBox.Items[replacementComboBox.SelectedIndex]; 131 var factorReplMethod = 132 (RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum) 133 factorVarReplComboBox.Items[factorVarReplComboBox.SelectedIndex]; 134 var dataPartition = 135 (RegressionSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem; 137 var replMethod = (RegressionSolutionVariableImpactsCalculator.ReplacementMethodEnum)replacementComboBox.Items[replacementComboBox.SelectedIndex]; 138 var factorReplMethod = (RegressionSolutionVariableImpactsCalculator.FactorReplacementMethodEnum)factorVarReplComboBox.Items[factorVarReplComboBox.SelectedIndex]; 139 var dataPartition = (RegressionSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem; 136 140 137 141 Task.Factory.StartNew(() => { … … 146 150 rawVariableImpacts.Clear(); 147 151 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(v, impacts.First(vv => vv.Item1 == v).Item2)); 152 UpdateDataOrdering(); 148 153 } finally { 149 154 mainForm.RemoveOperationProgressFromView(this); 150 UpdateDataOrdering();151 155 } 152 156 }); … … 159 163 private void UpdateDataOrdering() { 160 164 //Check if valid sortingCriteria is selected and data exists 161 if (sortByComboBox.SelectedIndex == -1 || rawVariableImpacts == null || !rawVariableImpacts.Any()) { return; } 165 if (sortByComboBox.SelectedIndex == -1) { return; } 166 if (rawVariableImpacts == null) { return; } 167 if (!rawVariableImpacts.Any()) { return; } 162 168 163 var selectedItem = ( RegressionSolutionVariableImpactsCalculator.SortingCriteria)sortByComboBox.SelectedItem;169 var selectedItem = (SortingCriteria)sortByComboBox.SelectedItem; 164 170 bool ascending = ascendingCheckBox.Checked; 165 171 … … 168 174 //Sort accordingly 169 175 switch (selectedItem) { 170 case RegressionSolutionVariableImpactsCalculator.SortingCriteria.ImpactValue:171 orderedEntries = ascending ? rawVariableImpacts.OrderBy(v => v.Value) : rawVariableImpacts.OrderByDescending(v => v.Value);176 case SortingCriteria.ImpactValue: 177 orderedEntries = rawVariableImpacts.OrderBy(v => v.Value); 172 178 break; 173 case RegressionSolutionVariableImpactsCalculator.SortingCriteria.Occurrence:174 orderedEntries = ascending ? rawVariableImpacts : rawVariableImpacts.Reverse();179 case SortingCriteria.Occurrence: 180 orderedEntries = rawVariableImpacts; 175 181 break; 176 case RegressionSolutionVariableImpactsCalculator.SortingCriteria.VariableName:177 orderedEntries = ascending ? rawVariableImpacts.OrderBy(v => v.Key, new NaturalStringComparer()) : rawVariableImpacts.OrderByDescending(v => v.Key, new NaturalStringComparer());182 case SortingCriteria.VariableName: 183 orderedEntries = rawVariableImpacts.OrderBy(v => v.Key, new NaturalStringComparer()); 178 184 break; 179 185 default: 180 throw new Exception("Cannot interpret SortingCriteria");186 throw new NotImplementedException("Ordering for selected SortingCriteria not implemented"); 181 187 } 188 189 if (!ascending) { orderedEntries = orderedEntries.Reverse(); } 182 190 183 191 //Write the data back -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs
r15665 r15673 52 52 All 53 53 } 54 public enum SortingCriteria { 55 ImpactValue, 56 Occurrence, 57 VariableName 58 } 59 54 60 55 private const string ReplacementParameterName = "Replacement Method"; 61 56 private const string DataPartitionParameterName = "DataPartition";
Note: See TracChangeset
for help on using the changeset viewer.