Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15673


Ignore:
Timestamp:
01/30/18 13:53:04 (7 years ago)
Author:
fholzing
Message:

#2871: Implemented review-issues

Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs

    r15665 r15673  
    1919 */
    2020#endregion
    21 using System;
    22 using System.Linq;
    2321
    2422namespace HeuristicLab.Problems.DataAnalysis.Views {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs

    r15665 r15673  
    3232  [Content(typeof(IRegressionSolution))]
    3333  public partial class RegressionSolutionVariableImpactsView : DataAnalysisSolutionEvaluationView {
     34    private enum SortingCriteria {
     35      ImpactValue,
     36      Occurrence,
     37      VariableName
     38    }
     39
    3440    private Dictionary<string, double> rawVariableImpacts = new Dictionary<string, double>();
    3541
     
    4652
    4753      //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;
    5056
    5157      this.dataPartitionComboBox.SelectedIndex = 0;
     
    96102      //Update the default ordering (asc,desc), but remove the eventHandler beforehand (otherwise the data would be ordered twice)
    97103      ascendingCheckBox.CheckedChanged -= ascendingCheckBox_CheckedChanged;
    98       switch ((RegressionSolutionVariableImpactsCalculator.SortingCriteria)sortByComboBox.SelectedItem) {
    99         case RegressionSolutionVariableImpactsCalculator.SortingCriteria.ImpactValue:
     104      switch ((SortingCriteria)sortByComboBox.SelectedItem) {
     105        case SortingCriteria.ImpactValue:
    100106          ascendingCheckBox.Checked = false;
    101107          break;
    102         case RegressionSolutionVariableImpactsCalculator.SortingCriteria.Occurrence:
     108        case SortingCriteria.Occurrence:
    103109          ascendingCheckBox.Checked = true;
    104110          break;
    105         case RegressionSolutionVariableImpactsCalculator.SortingCriteria.VariableName:
     111        case SortingCriteria.VariableName:
    106112          ascendingCheckBox.Checked = true;
    107113          break;
    108114        default:
    109           throw new Exception("Cannot interpret SortingCriteria");
     115          throw new NotImplementedException("Ordering for selected SortingCriteria not implemented");
    110116      }
    111117      ascendingCheckBox.CheckedChanged += ascendingCheckBox_CheckedChanged;
     
    121127    #region Helper Methods         
    122128    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
    126136      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;
    136140
    137141      Task.Factory.StartNew(() => {
     
    146150          rawVariableImpacts.Clear();
    147151          originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(v, impacts.First(vv => vv.Item1 == v).Item2));
     152          UpdateDataOrdering();
    148153        } finally {
    149154          mainForm.RemoveOperationProgressFromView(this);
    150           UpdateDataOrdering();
    151155        }
    152156      });
     
    159163    private void UpdateDataOrdering() {
    160164      //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; }
    162168
    163       var selectedItem = (RegressionSolutionVariableImpactsCalculator.SortingCriteria)sortByComboBox.SelectedItem;
     169      var selectedItem = (SortingCriteria)sortByComboBox.SelectedItem;
    164170      bool ascending = ascendingCheckBox.Checked;
    165171
     
    168174      //Sort accordingly
    169175      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);
    172178          break;
    173         case RegressionSolutionVariableImpactsCalculator.SortingCriteria.Occurrence:
    174           orderedEntries = ascending ? rawVariableImpacts : rawVariableImpacts.Reverse();
     179        case SortingCriteria.Occurrence:
     180          orderedEntries = rawVariableImpacts;
    175181          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());
    178184          break;
    179185        default:
    180           throw new Exception("Cannot interpret SortingCriteria");
     186          throw new NotImplementedException("Ordering for selected SortingCriteria not implemented");
    181187      }
     188
     189      if (!ascending) { orderedEntries = orderedEntries.Reverse(); }
    182190
    183191      //Write the data back
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolutionVariableImpactsCalculator.cs

    r15665 r15673  
    5252      All
    5353    }
    54     public enum SortingCriteria {
    55       ImpactValue,
    56       Occurrence,
    57       VariableName
    58     }
    59 
     54   
    6055    private const string ReplacementParameterName = "Replacement Method";
    6156    private const string DataPartitionParameterName = "DataPartition";
Note: See TracChangeset for help on using the changeset viewer.