Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8668 for trunk/sources


Ignore:
Timestamp:
09/18/12 12:56:25 (12 years ago)
Author:
mkommend
Message:

#1043: Implemented display of calculated repetitions of a batchrun in the experiment tree view by adapting the text of the batchrun node to "Batchrun-Name x/y".

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentTreeView.cs

    r7275 r8668  
    110110      } else if (batchRun != null) {
    111111        batchRun.OptimizerChanged += new EventHandler(batchRun_OptimizerChanged);
     112        batchRun.RepetetionsCounterChanged += new EventHandler(batchRun_RepetitionsCounterChanged);
     113        batchRun.RepetitionsChanged += new EventHandler(batchRun_RepetitionsChanged);
    112114      } else if (experiment != null) {
    113115        experiment.Optimizers.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsAdded);
     
    132134      } else if (batchRun != null) {
    133135        batchRun.OptimizerChanged -= new EventHandler(batchRun_OptimizerChanged);
     136        batchRun.RepetetionsCounterChanged -= new EventHandler(batchRun_RepetitionsCounterChanged);
     137        batchRun.RepetitionsChanged += new EventHandler(batchRun_RepetitionsChanged);
    134138      } else if (experiment != null) {
    135139        experiment.Optimizers.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IOptimizer>>(Optimizers_ItemsAdded);
     
    225229    }
    226230
     231    private void batchRun_RepetitionsCounterChanged(object sender, EventArgs e) {
     232      namedItem_ToStringChanged(sender, e);
     233    }
     234    private void batchRun_RepetitionsChanged(object sender, EventArgs e) {
     235      namedItem_ToStringChanged(sender, e);
     236    }
     237
    227238    private void Optimizers_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IOptimizer>> e) {
    228239      if (InvokeRequired) {
     
    362373      }
    363374      var namedItem = (INamedItem)sender;
    364       foreach (TreeNode node in treeNodeTagMapping[namedItem])
     375      foreach (TreeNode node in treeNodeTagMapping[namedItem]) {
    365376        node.Text = namedItem.ToString();
     377        var batchRun = namedItem as BatchRun;
     378        if (batchRun != null)
     379          node.Text += string.Format(" {0}/{1}", batchRun.RepetitionsCounter, batchRun.Repetitions);
     380      }
    366381    }
    367382
     
    811826          node.Nodes.Add(childNode);
    812827      }
     828      var batchRun = optimizer as BatchRun;
     829      if (batchRun != null) {
     830        node.Text += string.Format(" {0}/{1}", batchRun.RepetitionsCounter, batchRun.Repetitions);
     831      }
    813832
    814833      List<TreeNode> nodes;
  • trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs

    r8194 r8668  
    130130    [Storable]
    131131    private int repetitionsCounter;
     132    public int RepetitionsCounter {
     133      get { return repetitionsCounter; }
     134      private set {
     135        if (value != repetitionsCounter) {
     136          repetitionsCounter = value;
     137          OnRepetitionsCounterChanged();
     138        }
     139      }
     140    }
    132141
    133142    [Storable]
     
    224233      if (Optimizer != null) {
    225234        ExecutionTime = TimeSpan.Zero;
    226         repetitionsCounter = 0;
     235        RepetitionsCounter = 0;
    227236        if (clearRuns) runs.Clear();
    228237        batchRunAction = BatchRunAction.Prepare;
    229238        // a race-condition may occur when the optimizer has changed the state by itself in the meantime
    230         try { Optimizer.Prepare(clearRuns); } catch (InvalidOperationException) { }
     239        try { Optimizer.Prepare(clearRuns); }
     240        catch (InvalidOperationException) { }
    231241      } else {
    232242        ExecutionState = ExecutionState.Stopped;
     
    240250      if (Optimizer.ExecutionState == ExecutionState.Stopped) Optimizer.Prepare();
    241251      // a race-condition may occur when the optimizer has changed the state by itself in the meantime
    242       try { Optimizer.Start(); } catch (InvalidOperationException) { }
     252      try { Optimizer.Start(); }
     253      catch (InvalidOperationException) { }
    243254    }
    244255    public void Pause() {
     
    249260      if (Optimizer.ExecutionState != ExecutionState.Started) return;
    250261      // a race-condition may occur when the optimizer has changed the state by itself in the meantime
    251       try { Optimizer.Pause(); } catch (InvalidOperationException) { }
     262      try { Optimizer.Pause(); }
     263      catch (InvalidOperationException) { }
    252264    }
    253265    public void Stop() {
     
    261273      }
    262274      // a race-condition may occur when the optimizer has changed the state by itself in the meantime
    263       try { Optimizer.Stop(); } catch (InvalidOperationException) { }
     275      try { Optimizer.Stop(); }
     276      catch (InvalidOperationException) { }
    264277    }
    265278
     
    283296    private void OnRepetitionsChanged() {
    284297      EventHandler handler = RepetitionsChanged;
     298      if (handler != null) handler(this, EventArgs.Empty);
     299    }
     300    public event EventHandler RepetetionsCounterChanged;
     301    private void OnRepetitionsCounterChanged() {
     302      EventHandler handler = RepetetionsCounterChanged;
    285303      if (handler != null) handler(this, EventArgs.Empty);
    286304    }
     
    356374        ExecutionTime = TimeSpan.Zero;
    357375        runsExecutionTime = TimeSpan.Zero;
    358         repetitionsCounter = 0;
     376        RepetitionsCounter = 0;
    359377        OnPrepared();
    360378      }
     
    365383    }
    366384    private void Optimizer_Stopped(object sender, EventArgs e) {
    367       repetitionsCounter++;
     385      RepetitionsCounter++;
    368386      ExecutionTime += runsExecutionTime;
    369387      runsExecutionTime = TimeSpan.Zero;
Note: See TracChangeset for help on using the changeset viewer.