Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/04/12 15:42:21 (12 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/HeuristicLab.Optimization/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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.