Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/11/11 15:03:46 (13 years ago)
Author:
gkronber
Message:

Merged changes from trunk to data analysis exploration branch and added fractional distance metric evaluator. #1142

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.3/RunCollectionVariableImpactView.cs

    r5010 r5275  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
    2425using System.Windows.Forms;
    25 using alglib;
    2626using HeuristicLab.Common;
    2727using HeuristicLab.Data;
     
    2929using HeuristicLab.MainForm.WindowsForms;
    3030using HeuristicLab.Optimization;
    31 using System;
    3231
    3332namespace HeuristicLab.Problems.DataAnalysis.Views {
    3433  [Content(typeof(RunCollection), false)]
    3534  [View("RunCollection Variable Impact View")]
    36   public partial class RunCollectionVariableImpactView : AsynchronousContentView {
     35  public sealed partial class RunCollectionVariableImpactView : AsynchronousContentView {
    3736    private const string variableImpactResultName = "Integrated variable frequencies";
    3837    public RunCollectionVariableImpactView() {
     
    4544    }
    4645
     46    #region events
    4747    protected override void RegisterContentEvents() {
    4848      base.RegisterContentEvents();
    49       this.Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    50       this.Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    51       this.Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     49      Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
     50      Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
     51      Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
     52      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     53      RegisterRunEvents(Content);
    5254    }
    5355    protected override void DeregisterContentEvents() {
    5456      base.RegisterContentEvents();
    55       this.Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    56       this.Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    57       this.Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    58     }
     57      Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
     58      Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
     59      Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
     60      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     61      DeregisterRunEvents(Content);
     62    }
     63    private void RegisterRunEvents(IEnumerable<IRun> runs) {
     64      foreach (IRun run in runs)
     65        run.Changed += new EventHandler(Run_Changed);
     66    }
     67    private void DeregisterRunEvents(IEnumerable<IRun> runs) {
     68      foreach (IRun run in runs)
     69        run.Changed -= new EventHandler(Run_Changed);
     70    }
     71    private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
     72      RegisterRunEvents(e.Items);
     73      UpdateData();
     74    }
     75    private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
     76      DeregisterRunEvents(e.Items);
     77      UpdateData();
     78    }
     79    private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
     80      DeregisterRunEvents(e.OldItems);
     81      RegisterRunEvents(e.Items);
     82      UpdateData();
     83    }
     84    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     85      if (!Content.UpdateOfRunsInProgress) UpdateData();
     86    }
     87    private void Run_Changed(object sender, EventArgs e) {
     88      if (!Content.UpdateOfRunsInProgress) UpdateData();
     89    }
     90    #endregion
    5991
    6092    protected override void OnContentChanged() {
     
    6294      this.UpdateData();
    6395    }
    64     private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    65       this.UpdateData();
    66     }
    67     private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    68       this.UpdateData();
    69     }
    70     private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    71       this.UpdateData();
    72     }
    7396
    7497    private void UpdateData() {
     
    7699    }
    77100
    78     public DoubleMatrix CalculateVariableImpactMatrix() {
     101    private DoubleMatrix CalculateVariableImpactMatrix() {
    79102      DoubleMatrix matrix = null;
    80103      if (Content != null) {
    81         List<IRun> runsWithVariables = Content.Where(r => r.Results.ContainsKey(variableImpactResultName)).ToList();
     104        List<IRun> runsWithVariables = Content.Where(r => r.Visible && r.Results.ContainsKey(variableImpactResultName)).ToList();
    82105        IEnumerable<DoubleMatrix> allVariableImpacts = (from run in runsWithVariables
    83106                                                        select run.Results[variableImpactResultName]).Cast<DoubleMatrix>();
Note: See TracChangeset for help on using the changeset viewer.