Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/23/18 12:26:36 (6 years ago)
Author:
fholzing
Message:

#2871: Implemented review

Location:
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression
Files:
2 edited

Legend:

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

    r15752 r15998  
    1919 */
    2020#endregion
     21
     22using System;
    2123
    2224namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    8688      this.sortByComboBox.TabIndex = 5;
    8789      this.sortByComboBox.SelectedIndexChanged += new System.EventHandler(this.sortByComboBox_SelectedIndexChanged);
     90      this.sortByComboBox.DataSource = Enum.GetValues(typeof(SortingCriteria));
    8891      //
    8992      // factorVarReplComboBox
     
    159162      // variableImactsArrayView
    160163      //
    161       this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    162             | System.Windows.Forms.AnchorStyles.Left) 
     164      this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     165            | System.Windows.Forms.AnchorStyles.Left)
    163166            | System.Windows.Forms.AnchorStyles.Right)));
    164167      this.variableImactsArrayView.Caption = "StringConvertibleArray View";
  • trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs

    r15799 r15998  
    3939      VariableName
    4040    }
    41     private IProgress progress;
    42     private Dictionary<string, double> rawVariableImpacts = new Dictionary<string, double>();
     41    private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>();
    4342
    4443    public new IRegressionSolution Content {
     
    5352      InitializeComponent();
    5453
    55       //Little workaround. If you fill the ComboBox-Items in the other partial class, the UI-Designer will moan.
    56       this.sortByComboBox.Items.AddRange(Enum.GetValues(typeof(SortingCriteria)).Cast<object>().ToArray());
    57       this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue;
    58 
    5954      //Set the default values
    6055      this.dataPartitionComboBox.SelectedIndex = 0;
    6156      this.replacementComboBox.SelectedIndex = 0;
    6257      this.factorVarReplComboBox.SelectedIndex = 0;
     58      this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue;
    6359    }
    6460
     
    9389
    9490    private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) {
    95       if (!cancellationToken.IsCancellationRequested) {
    96         cancellationToken.Cancel();
    97       }
     91      cancellationToken.Cancel();
    9892    }
    9993
     
    110104      //Update the default ordering (asc,desc), but remove the eventHandler beforehand (otherwise the data would be ordered twice)
    111105      ascendingCheckBox.CheckedChanged -= ascendingCheckBox_CheckedChanged;
    112       switch ((SortingCriteria)sortByComboBox.SelectedItem) {
    113         case SortingCriteria.ImpactValue:
    114           ascendingCheckBox.Checked = false;
    115           break;
    116         case SortingCriteria.Occurrence:
    117           ascendingCheckBox.Checked = true;
    118           break;
    119         case SortingCriteria.VariableName:
    120           ascendingCheckBox.Checked = true;
    121           break;
    122         default:
    123           throw new NotImplementedException("Ordering for selected SortingCriteria not implemented");
    124       }
     106      ascendingCheckBox.Checked = (SortingCriteria)sortByComboBox.SelectedItem != SortingCriteria.ImpactValue;
    125107      ascendingCheckBox.CheckedChanged += ascendingCheckBox_CheckedChanged;
    126108
    127       UpdateDataOrdering();
     109      UpdateOrdering();
    128110    }
    129111
    130112    private void ascendingCheckBox_CheckedChanged(object sender, EventArgs e) {
    131       UpdateDataOrdering();
     113      UpdateOrdering();
    132114    }
    133115
    134116
    135117    private async void UpdateVariableImpact() {
     118      IProgress progress;
     119
    136120      //Check if the selection is valid
    137121      if (Content == null) { return; }
     
    166150
    167151        rawVariableImpacts.Clear();
    168         originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(v, impacts.First(vv => vv.Item1 == v).Item2));
    169         UpdateDataOrdering();
     152        originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(new Tuple<string, double>(v, impacts.First(vv => vv.Item1 == v).Item2)));
     153        UpdateOrdering();
    170154      } finally {
    171155        ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).RemoveOperationProgressFromView(this);
     
    177161    /// The default is "Descending" by "VariableImpact" (as in previous versions)
    178162    /// </summary>
    179     private void UpdateDataOrdering() {
     163    private void UpdateOrdering() {
    180164      //Check if valid sortingCriteria is selected and data exists
    181165      if (sortByComboBox.SelectedIndex == -1) { return; }
     
    186170      bool ascending = ascendingCheckBox.Checked;
    187171
    188       IEnumerable<KeyValuePair<string, double>> orderedEntries = null;
     172      IEnumerable<Tuple<string, double>> orderedEntries = null;
    189173
    190174      //Sort accordingly
    191175      switch (selectedItem) {
    192176        case SortingCriteria.ImpactValue:
    193           orderedEntries = rawVariableImpacts.OrderBy(v => v.Value);
     177          orderedEntries = rawVariableImpacts.OrderBy(v => v.Item2);
    194178          break;
    195179        case SortingCriteria.Occurrence:
     
    197181          break;
    198182        case SortingCriteria.VariableName:
    199           orderedEntries = rawVariableImpacts.OrderBy(v => v.Key, new NaturalStringComparer());
     183          orderedEntries = rawVariableImpacts.OrderBy(v => v.Item1, new NaturalStringComparer());
    200184          break;
    201185        default:
     
    206190
    207191      //Write the data back
    208       var impactArray = new DoubleArray(orderedEntries.Select(i => i.Value).ToArray()) {
    209         ElementNames = orderedEntries.Select(i => i.Key)
     192      var impactArray = new DoubleArray(orderedEntries.Select(i => i.Item2).ToArray()) {
     193        ElementNames = orderedEntries.Select(i => i.Item1)
    210194      };
    211195
Note: See TracChangeset for help on using the changeset viewer.