Changeset 8738


Ignore:
Timestamp:
10/04/12 15:42:21 (8 years ago)
Author:
mkommend
Message:

#1673: Added new property AlgorithmName to the RunCollection and synced the property with the name of the surrounding IOptimizer. The AlgorithmName is used by the RunCollectionViews as prefix for its caption if it was set.

Location:
trunk/sources
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r8528 r8738  
    4444
    4545      executionState = ExecutionState.Stopped;
    46       runs = new RunCollection();
     46      runs = new RunCollection { AlgorithmName = name };
    4747      runsCounter = 0;
    4848
     
    246246    #endregion
    247247
     248    protected override void OnNameChanged() {
     249      base.OnNameChanged();
     250      Runs.AlgorithmName = Name;
     251    }
     252
    248253    public void Prepare() {
    249254      if (ExecutionState == ExecutionState.Started)
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs

    r7469 r8738  
    7575      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    7676      Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
     77      Content.AlgorithmNameChanged += new EventHandler(Content_AlgorithmNameChanged);
    7778      RegisterRunEvents(Content);
    7879    }
     
    8586      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    8687      Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
     88      Content.AlgorithmNameChanged -= new EventHandler(Content_AlgorithmNameChanged);
    8789      DeregisterRunEvents(Content);
    8890    }
     
    139141      }
    140142    }
     143
     144    private void Content_AlgorithmNameChanged(object sender, EventArgs e) {
     145      if (InvokeRequired)
     146        Invoke(new EventHandler(Content_AlgorithmNameChanged), sender, e);
     147      else UpdateCaption();
     148    }
    141149    #endregion
    142150
     
    147155      UpdateComboBoxes();
    148156      UpdateDataPoints();
     157      UpdateCaption();
     158    }
     159
     160    private void UpdateCaption() {
     161      Caption = Content != null ? Content.AlgorithmName + "Box Plots" : ViewAttribute.GetViewName(GetType());
    149162    }
    150163
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r7469 r8738  
    9393      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    9494      Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
     95      Content.AlgorithmNameChanged += new EventHandler(Content_AlgorithmNameChanged);
    9596      RegisterRunEvents(Content);
    9697    }
     
    103104      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    104105      Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
     106      Content.AlgorithmNameChanged -= new EventHandler(Content_AlgorithmNameChanged);
    105107      DeregisterRunEvents(Content);
    106108    }
     
    163165      UpdateComboBoxes();
    164166      UpdateDataPoints();
     167      UpdateCaption();
    165168    }
    166169    private void Content_ColumnNamesChanged(object sender, EventArgs e) {
     
    169172      else
    170173        UpdateComboBoxes();
     174    }
     175
     176    private void UpdateCaption() {
     177      Caption = Content != null ? Content.AlgorithmName + "Bubble Chart" : ViewAttribute.GetViewName(GetType());
    171178    }
    172179
     
    215222        if (!suppressUpdates) UpdateDataPoints();
    216223      }
     224    }
     225
     226    private void Content_AlgorithmNameChanged(object sender, EventArgs e) {
     227      if (InvokeRequired)
     228        Invoke(new EventHandler(Content_AlgorithmNameChanged), sender, e);
     229      else UpdateCaption();
    217230    }
    218231
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionDataTableView.cs

    r8108 r8738  
    6363      Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    6464      Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
     65      Content.AlgorithmNameChanged += new EventHandler(Content_AlgorithmNameChanged);
    6566    }
    6667    protected override void DeregisterContentEvents() {
     
    6970      Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    7071      Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
     72      Content.AlgorithmNameChanged -= new EventHandler(Content_AlgorithmNameChanged);
    7173      base.DeregisterContentEvents();
    7274    }
     
    9395      RemoveRuns(e.OldItems);
    9496      AddRuns(e.Items);
     97    }
     98    private void Content_AlgorithmNameChanged(object sender, EventArgs e) {
     99      if (InvokeRequired)
     100        Invoke(new EventHandler(Content_AlgorithmNameChanged), sender, e);
     101      else UpdateCaption();
    95102    }
    96103    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     
    123130      runMapping.Clear();
    124131
     132      UpdateCaption();
    125133      if (Content != null) {
    126134        UpdateDataTableComboBox();
     
    195203    }
    196204
     205    private void UpdateCaption() {
     206      Caption = Content != null ? Content.AlgorithmName + "Data Table" : ViewAttribute.GetViewName(GetType());
     207    }
     208
    197209    private void UpdateDataRowComboBox() {
    198210      dataRowComboBox.Items.Clear();
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTabularView.cs

    r8139 r8738  
    5555        UpdateRowAttributes();
    5656      }
     57      UpdateCaption();
    5758    }
    5859
     
    6465      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    6566      Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
     67      Content.AlgorithmNameChanged += new EventHandler(Content_AlgorithmNameChanged);
    6668      RegisterRunEvents(Content);
    6769    }
     
    7678      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    7779      Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
     80      Content.AlgorithmNameChanged -= new EventHandler(Content_AlgorithmNameChanged);
    7881      DeregisterRunEvents(Content);
    7982    }
     
    9194    private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    9295      RegisterRunEvents(e.Items);
     96    }
     97    private void Content_AlgorithmNameChanged(object sender, EventArgs e) {
     98      if (InvokeRequired)
     99        Invoke(new EventHandler(Content_AlgorithmNameChanged), sender, e);
     100      else UpdateCaption();
    93101    }
    94102    private void run_Changed(object sender, EventArgs e) {
     
    101109    }
    102110    #endregion
     111
     112    private void UpdateCaption() {
     113      Caption = Content != null ? Content.AlgorithmName + "Tabular View" : ViewAttribute.GetViewName(GetType());
     114    }
    103115
    104116    protected override void UpdateColumnHeaders() {
  • trunk/sources/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs

    r8212 r8738  
    134134      storeAlgorithmInEachRun = false;
    135135      runsCounter = 0;
    136       Runs = new RunCollection();
     136      Runs = new RunCollection { AlgorithmName = Name };
    137137    }
    138138    protected Algorithm(string name)
     
    142142      storeAlgorithmInEachRun = false;
    143143      runsCounter = 0;
    144       Runs = new RunCollection();
     144      Runs = new RunCollection { AlgorithmName = Name };
    145145    }
    146146    protected Algorithm(string name, ParameterCollection parameters)
     
    150150      storeAlgorithmInEachRun = false;
    151151      runsCounter = 0;
    152       Runs = new RunCollection();
     152      Runs = new RunCollection { AlgorithmName = Name };
    153153    }
    154154    protected Algorithm(string name, string description)
     
    158158      storeAlgorithmInEachRun = false;
    159159      runsCounter = 0;
    160       Runs = new RunCollection();
     160      Runs = new RunCollection { AlgorithmName = Name };
    161161    }
    162162    protected Algorithm(string name, string description, ParameterCollection parameters)
     
    166166      storeAlgorithmInEachRun = false;
    167167      runsCounter = 0;
    168       Runs = new RunCollection();
     168      Runs = new RunCollection { AlgorithmName = Name };
    169169    }
    170170    [StorableConstructor]
     
    250250
    251251    #region Events
     252    protected override void OnNameChanged() {
     253      base.OnNameChanged();
     254      Runs.AlgorithmName = Name;
     255    }
     256
    252257    public event EventHandler ExecutionStateChanged;
    253258    protected virtual void OnExecutionStateChanged() {
  • trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs

    r8668 r8738  
    175175      repetitions = 10;
    176176      repetitionsCounter = 0;
    177       Runs = new RunCollection();
     177      Runs = new RunCollection { AlgorithmName = Name };
    178178    }
    179179    public BatchRun(string name)
     
    185185      repetitions = 10;
    186186      repetitionsCounter = 0;
    187       Runs = new RunCollection();
     187      Runs = new RunCollection { AlgorithmName = Name };
    188188    }
    189189    public BatchRun(string name, string description)
     
    194194      repetitions = 10;
    195195      repetitionsCounter = 0;
    196       Runs = new RunCollection();
     196      Runs = new RunCollection { AlgorithmName = Name };
    197197    }
    198198    [StorableConstructor]
     
    278278
    279279    #region Events
     280    protected override void OnNameChanged() {
     281      base.OnNameChanged();
     282      runs.AlgorithmName = Name;
     283    }
     284
    280285    public event EventHandler ExecutionStateChanged;
    281286    private void OnExecutionStateChanged() {
  • trunk/sources/HeuristicLab.Optimization/3.3/Experiment.cs

    r8194 r8738  
    117117      executionTime = TimeSpan.Zero;
    118118      optimizers = new OptimizerList();
    119       Runs = new RunCollection();
     119      Runs = new RunCollection { AlgorithmName = Name };
    120120      Initialize();
    121121    }
     
    126126      executionTime = TimeSpan.Zero;
    127127      optimizers = new OptimizerList();
    128       Runs = new RunCollection();
     128      Runs = new RunCollection { AlgorithmName = Name };
    129129      Initialize();
    130130    }
     
    134134      executionTime = TimeSpan.Zero;
    135135      optimizers = new OptimizerList();
    136       Runs = new RunCollection();
     136      Runs = new RunCollection { AlgorithmName = Name };
    137137      Initialize();
    138138    }
     
    180180      foreach (IOptimizer optimizer in Optimizers.Where(x => x.ExecutionState != ExecutionState.Started)) {
    181181        // a race-condition may occur when the optimizer has changed the state by itself in the meantime
    182         try { optimizer.Prepare(clearRuns); } catch (InvalidOperationException) { }
     182        try { optimizer.Prepare(clearRuns); }
     183        catch (InvalidOperationException) { }
    183184      }
    184185    }
     
    193194      if (optimizer != null) {
    194195        // a race-condition may occur when the optimizer has changed the state by itself in the meantime
    195         try { optimizer.Start(); } catch (InvalidOperationException) { }
     196        try { optimizer.Start(); }
     197        catch (InvalidOperationException) { }
    196198      }
    197199    }
     
    205207      foreach (IOptimizer optimizer in Optimizers.Where(x => x.ExecutionState == ExecutionState.Started)) {
    206208        // a race-condition may occur when the optimizer has changed the state by itself in the meantime
    207         try { optimizer.Pause(); } catch (InvalidOperationException) { }
     209        try { optimizer.Pause(); }
     210        catch (InvalidOperationException) { }
    208211      }
    209212    }
     
    218221        foreach (var optimizer in Optimizers.Where(x => (x.ExecutionState == ExecutionState.Started) || (x.ExecutionState == ExecutionState.Paused))) {
    219222          // a race-condition may occur when the optimizer has changed the state by itself in the meantime
    220           try { optimizer.Stop(); } catch (InvalidOperationException) { }
     223          try { optimizer.Stop(); }
     224          catch (InvalidOperationException) { }
    221225        }
    222226      } else {
     
    226230
    227231    #region Events
     232    protected override void OnNameChanged() {
     233      base.OnNameChanged();
     234      Runs.AlgorithmName = Name;
     235    }
     236
    228237    public event EventHandler ExecutionStateChanged;
    229238    private void OnExecutionStateChanged() {
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs

    r7798 r8738  
    4444      : base(original, cloner) {
    4545      updateOfRunsInProgress = false;
     46      algorithmName = original.algorithmName;
     47
    4648      resultNames = new List<string>(original.resultNames);
    4749      parameterNames = new List<string>(original.parameterNames);
     
    104106    }
    105107
     108    private string algorithmName = string.Empty;
     109    [Storable]
     110    public string AlgorithmName {
     111      get { return algorithmName; }
     112      set {
     113        if (value != algorithmName && !string.IsNullOrEmpty(value)) {
     114          algorithmName = value;
     115          OnAlgorithmNameChanged();
     116        }
     117      }
     118    }
     119
    106120    [StorableHook(HookType.AfterDeserialization)]
    107121    private void AfterDeserialization() {
     
    120134    protected virtual void OnUpdateOfRunsInProgressChanged() {
    121135      var handler = UpdateOfRunsInProgressChanged;
     136      if (handler != null) handler(this, EventArgs.Empty);
     137    }
     138
     139    public event EventHandler AlgorithmNameChanged;
     140    protected virtual void OnAlgorithmNameChanged() {
     141      var handler = AlgorithmNameChanged;
    122142      if (handler != null) handler(this, EventArgs.Empty);
    123143    }
Note: See TracChangeset for help on using the changeset viewer.