Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15674


Ignore:
Timestamp:
01/30/18 14:00:03 (7 years ago)
Author:
fholzing
Message:

#2884:Implemented additional review points (see #2871)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionVariableImpactsView.cs

    r15667 r15674  
    3232  [Content(typeof(IClassificationSolution))]
    3333  public partial class ClassificationSolutionVariableImpactsView : 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(ClassificationSolutionVariableImpactsCalculator.SortingCriteria)).Cast<object>().ToArray());
    49       this.sortByComboBox.SelectedItem = ClassificationSolutionVariableImpactsCalculator.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 ((ClassificationSolutionVariableImpactsCalculator.SortingCriteria)sortByComboBox.SelectedItem) {
    99         case ClassificationSolutionVariableImpactsCalculator.SortingCriteria.ImpactValue:
     104      switch ((SortingCriteria)sortByComboBox.SelectedItem) {
     105        case SortingCriteria.ImpactValue:
    100106          ascendingCheckBox.Checked = false;
    101107          break;
    102         case ClassificationSolutionVariableImpactsCalculator.SortingCriteria.Occurrence:
     108        case SortingCriteria.Occurrence:
    103109          ascendingCheckBox.Checked = true;
    104110          break;
    105         case ClassificationSolutionVariableImpactsCalculator.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          (ClassificationSolutionVariableImpactsCalculator.ReplacementMethodEnum)
    130            replacementComboBox.Items[replacementComboBox.SelectedIndex];
    131       var factorReplMethod =
    132         (ClassificationSolutionVariableImpactsCalculator.FactorReplacementMethodEnum)
    133           factorVarReplComboBox.Items[factorVarReplComboBox.SelectedIndex];
    134       var dataPartition =
    135         (ClassificationSolutionVariableImpactsCalculator.DataPartitionEnum)dataPartitionComboBox.SelectedItem;
     137      var replMethod = (ClassificationSolutionVariableImpactsCalculator.ReplacementMethodEnum)replacementComboBox.Items[replacementComboBox.SelectedIndex];
     138      var factorReplMethod = (ClassificationSolutionVariableImpactsCalculator.FactorReplacementMethodEnum)factorVarReplComboBox.Items[factorVarReplComboBox.SelectedIndex];
     139      var dataPartition = (ClassificationSolutionVariableImpactsCalculator.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 = (ClassificationSolutionVariableImpactsCalculator.SortingCriteria)sortByComboBox.SelectedItem;
     169      var selectedItem = (SortingCriteria)sortByComboBox.SelectedItem;
    164170      bool ascending = ascendingCheckBox.Checked;
    165171
     
    168174      //Sort accordingly
    169175      switch (selectedItem) {
    170         case ClassificationSolutionVariableImpactsCalculator.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 ClassificationSolutionVariableImpactsCalculator.SortingCriteria.Occurrence:
    174           orderedEntries = ascending ? rawVariableImpacts : rawVariableImpacts.Reverse();
     179        case SortingCriteria.Occurrence:
     180          orderedEntries = rawVariableImpacts;
    175181          break;
    176         case ClassificationSolutionVariableImpactsCalculator.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/Classification/ClassificationSolutionVariableImpactsCalculator.cs

    r15667 r15674  
    5151      Test,
    5252      All
    53     }
    54 
    55     public enum SortingCriteria {
    56       ImpactValue,
    57       Occurrence,
    58       VariableName
    5953    }
    6054
Note: See TracChangeset for help on using the changeset viewer.