Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/24/16 10:03:52 (8 years ago)
Author:
abeham
Message:

#2457: worked on performance modeling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Views/UnderstandingProblemInstanceView.cs

    r13757 r13787  
    2222using HeuristicLab.Common.Resources;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Core.Views;
    2524using HeuristicLab.Data;
    2625using HeuristicLab.MainForm;
     26using HeuristicLab.MainForm.WindowsForms;
    2727using HeuristicLab.OptimizationExpertSystem.Common;
    2828using System;
     
    3939  public sealed partial class UnderstandingProblemInstanceView : KnowledgeCenterViewBase {
    4040    private bool SuppressEvents { get; set; }
    41     private readonly CheckedItemListView<StringValue> characteristicsView;
     41    private readonly CheckedItemList<StringValue> characteristics;
    4242 
    4343    public UnderstandingProblemInstanceView() {
     
    4545      showCharacteristicsCheckBox.Text = string.Empty;
    4646      showCharacteristicsCheckBox.Image = VSImageLibrary.Properties;
    47       characteristicsView = new CheckedItemListView<StringValue>() {
    48         Dock = DockStyle.Fill
    49       };
    50       mapSplitContainer.Panel2.Controls.Add(characteristicsView);
     47      characteristics = new CheckedItemList<StringValue>();
     48      characteristics.CheckedItemsChanged += CharacteristicsOnCheckedItemsChanged;
     49      mapSplitContainer.Panel2.Controls.Add(new ViewHost() {
     50        Dock = DockStyle.Fill,
     51        Content = characteristics
     52      });
    5153    }
    5254
    5355    protected override void OnContentChanged() {
    5456      base.OnContentChanged();
     57      characteristics.Clear();
    5558      if (Content == null) {
    5659        problemInstancesView.Content = null;
    57         characteristicsView.Content = null;
    5860        instanceMapChart.Series["InstancesSeries"].Points.Clear();
    5961        instanceMapChart.Series["CurrentInstanceSeries"].Points.Clear();
    6062      } else {
    6163        problemInstancesView.Content = Content.ProblemInstances;
    62         characteristicsView.Content = Content.ProblemCharacteristics;
     64        UpdateCharacteristics();
    6365        UpdateProjectionComboBox();
    6466        UpdateSizeComboBox();
     
    6769    }
    6870
    69     #region Content Event Handlers
    70     protected override void OnProblemChanged() {
    71       base.OnProblemChanged();
    72       SetEnabledStateOfControls();
    73     }
    74 
    75     protected override void OnProblemInstancesChanged() {
    76       base.OnProblemInstancesChanged();
    77       if (Content.ProblemInstances.UpdateOfRunsInProgress) return;
    78       UpdateProjectionComboBox();
    79       UpdateSizeComboBox();
    80       UpdateColorComboBox();
    81       UpdateProjection();
    82     }
    83     #endregion
     71    protected override void SetEnabledStateOfControls() {
     72      base.SetEnabledStateOfControls();
     73    }
     74
     75    #region Update Controls
     76    private void UpdateCharacteristics() {
     77      var @checked = new HashSet<string>(characteristics.CheckedItems.Select(x => x.Value.Value));
     78      characteristics.Clear();
     79      foreach (var c in Content.ProblemInstances.ResultNames) {
     80        characteristics.Add(new StringValue(c), @checked.Contains(c));
     81      }
     82    }
    8483
    8584    private void UpdateProjectionComboBox() {
     
    126125      } finally { SuppressEvents = false; }
    127126    }
    128    
    129     private IEnumerable<string> GetProjections() {
    130       return Content.ProblemInstances
    131         .SelectMany(x => x.Results.Where(y => Regex.IsMatch(y.Key, "^Projection[.].*[.][XY]$")))
    132         .Select(x => Regex.Match(x.Key, "Projection[.](?<g>.*)[.][XY]").Groups["g"].Value)
    133         .Distinct();
    134     }
    135127
    136128    private void UpdateProjection() {
     
    153145        size, color, invPropCheckBox.Checked, fromZeroCheckBox.Checked);
    154146    }
     147    #endregion
     148
     149    #region Content Event Handlers
     150    protected override void OnProblemChanged() {
     151      base.OnProblemChanged();
     152      SetEnabledStateOfControls();
     153    }
     154
     155    protected override void OnProblemInstancesChanged() {
     156      base.OnProblemInstancesChanged();
     157      if (Content.ProblemInstances.UpdateOfRunsInProgress) return;
     158      try {
     159        SuppressEvents = true;
     160        UpdateCharacteristics();
     161      } finally { SuppressEvents = false; }
     162      UpdateProjectionComboBox();
     163      UpdateSizeComboBox();
     164      UpdateColorComboBox();
     165      UpdateProjection();
     166    }
     167    #endregion
     168
     169    #region Control Event Handlers
     170    private void ProjectionComboBoxOnSelectedIndexChanged(object sender, EventArgs e) {
     171      UpdateProjection();
     172    }
     173
     174    private void SizeComboBoxOnSelectedIndexChanged(object sender, EventArgs e) {
     175      UpdateProjection();
     176    }
     177
     178    private void colorComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     179      UpdateProjection();
     180    }
     181
     182    private void InvPropCheckBoxOnCheckedChanged(object sender, EventArgs e) {
     183      UpdateProjection();
     184    }
     185
     186    private void fromZeroCheckBox_CheckedChanged(object sender, EventArgs e) {
     187      UpdateProjection();
     188    }
     189
     190    private void showCharacteristicsCheckBox_CheckedChanged(object sender, EventArgs e) {
     191      mapSplitContainer.Panel2Collapsed = !showCharacteristicsCheckBox.Checked;
     192    }
     193    #endregion
     194
     195    #region Other Event Handlers
     196    private void CharacteristicsOnCheckedItemsChanged(object sender, EventArgs e) {
     197      if (SuppressEvents) return;
     198      if (characteristics.CheckedItems.Any())
     199        Content.UpdateInstanceProjection(characteristics.CheckedItems.Select(x => x.Value.Value).ToArray());
     200    }
     201    #endregion
     202
     203    #region Helper Classes and Methods
     204    private IEnumerable<string> GetProjections() {
     205      return Content.ProblemInstances.ResultNames
     206        .Where(x => Regex.IsMatch(x, "^Projection[.].*[.][XY]$"))
     207        .Select(x => Regex.Match(x, "Projection[.](?<g>.*)[.][XY]").Groups["g"].Value)
     208        .Distinct();
     209    }
    155210
    156211    private void DoProjectProblemInstances(Series instancesSeries, Series currentInstanceSeries, string projection, string size, string color, bool invProp, bool fromZero) {
     
    160215      double maxSize = 0, minSize = 0;
    161216      if (!string.IsNullOrEmpty(size)) {
    162         var sizes = Content.ProblemInstances.Where(x => x.Results.ContainsKey(size)).Select(x => x.Results[size]).OfType<Data.DoubleValue>().Where(x => !double.IsNaN(x.Value)).ToList();
     217        var sizes = Content.ProblemInstances.Where(x => x.Results.ContainsKey(size)).Select(x => x.Results[size]).OfType<DoubleValue>().Where(x => !double.IsNaN(x.Value)).ToList();
    163218        if (sizes.Count > 0) {
    164219          maxSize = sizes.Max(x => x.Value);
     
    177232        var yKey = "Projection." + projection + ".Y";
    178233        if (!run.Results.ContainsKey(xKey) || !run.Results.ContainsKey(yKey)
    179             || !(run.Results[xKey] is Data.DoubleValue) || !(run.Results[yKey] is Data.DoubleValue)) continue;
    180         var x = ((Data.DoubleValue)run.Results[xKey]).Value;
    181         var y = ((Data.DoubleValue)run.Results[yKey]).Value;
     234            || !(run.Results[xKey] is DoubleValue) || !(run.Results[yKey] is DoubleValue)) continue;
     235        var x = ((DoubleValue)run.Results[xKey]).Value;
     236        var y = ((DoubleValue)run.Results[yKey]).Value;
    182237        var dataPoint = new DataPoint(x, y) {
    183238          Label = run.Name,
     
    185240        IItem item;
    186241        if (maxSize > minSize && run.Results.TryGetValue(size, out item)) {
    187           var dItem = item as Data.DoubleValue;
     242          var dItem = item as DoubleValue;
    188243          if (dItem == null && item is IntValue) dItem = new DoubleValue(((IntValue)item).Value);
    189244          if (dItem != null) {
     
    216271      }
    217272    }
    218 
    219     #region Control Event Handlers
    220     private void ProjectionComboBoxOnSelectedIndexChanged(object sender, EventArgs e) {
    221       UpdateProjection();
    222     }
    223 
    224     private void SizeComboBoxOnSelectedIndexChanged(object sender, EventArgs e) {
    225       UpdateProjection();
    226     }
    227 
    228     private void colorComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    229       UpdateProjection();
    230     }
    231 
    232     private void InvPropCheckBoxOnCheckedChanged(object sender, EventArgs e) {
    233       UpdateProjection();
    234     }
    235 
    236     private void fromZeroCheckBox_CheckedChanged(object sender, EventArgs e) {
    237       UpdateProjection();
    238     }
    239 
    240     private void showCharacteristicsCheckBox_CheckedChanged(object sender, EventArgs e) {
    241       mapSplitContainer.Panel2Collapsed = !showCharacteristicsCheckBox.Checked;
    242     }
    243273    #endregion
    244274  }
Note: See TracChangeset for help on using the changeset viewer.