Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5420


Ignore:
Timestamp:
02/04/11 02:16:08 (14 years ago)
Author:
mkommend
Message:

#1402 - Refactored OnClosed method of IOptimizer views.

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.3/CrossValidationView.cs

    r5419 r5420  
    107107        //The content must be stopped if no other view showing the content is available
    108108        var optimizers = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v != this).Select(v => v.Content).OfType<IOptimizer>();
    109         //add nested optimizers
    110         optimizers = optimizers.SelectMany(opt => opt.NestedOptimizers).Union(optimizers);
    111 
    112         if (!optimizers.Contains(Content)) Content.Stop();
     109        if (!optimizers.Contains(Content)) {
     110          var nestedOptimizers = optimizers.SelectMany(opt => opt.NestedOptimizers);
     111          if (!nestedOptimizers.Contains(Content)) Content.Stop();
     112        }
    113113      }
    114114      base.OnClosed(e);
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.3/CrossValidation.cs

    r5419 r5420  
    4848      algorithm = null;
    4949      clonedAlgorithms = new ItemCollection<IAlgorithm>();
    50       readOnlyClonedAlgorithms = null;
    5150      results = new ResultCollection();
    5251
     
    157156    [Storable]
    158157    private ItemCollection<IAlgorithm> clonedAlgorithms;
    159     private ReadOnlyItemCollection<IAlgorithm> readOnlyClonedAlgorithms;
    160     public IItemCollection<IAlgorithm> ClonedAlgorithms {
    161       get {
    162         if (readOnlyClonedAlgorithms == null) readOnlyClonedAlgorithms = clonedAlgorithms.AsReadOnly();
    163         return readOnlyClonedAlgorithms;
    164       }
    165     }
    166158
    167159    public IEnumerable<IOptimizer> NestedOptimizers {
    168       get {
    169         if (Algorithm != null) yield return Algorithm;
    170         if (clonedAlgorithms != null) {
    171           foreach (IAlgorithm alg in ClonedAlgorithms) {
    172             yield return alg;
    173             foreach (IOptimizer nested in alg.NestedOptimizers)
    174               yield return nested;
    175           }
    176         }
    177       }
     160      get { return Enumerable.Empty<IOptimizer>(); }
    178161    }
    179162
     
    316299    }
    317300    private void PauseAllClonedAlgorithms() {
    318       foreach (IAlgorithm clonedAlgorithm in ClonedAlgorithms) {
     301      foreach (IAlgorithm clonedAlgorithm in clonedAlgorithms) {
    319302        if (clonedAlgorithm.ExecutionState == ExecutionState.Started)
    320303          clonedAlgorithm.Pause();
     
    333316    }
    334317    private void StopAllClonedAlgorithms() {
    335       foreach (IAlgorithm clonedAlgorithm in ClonedAlgorithms) {
     318      foreach (IAlgorithm clonedAlgorithm in clonedAlgorithms) {
    336319        if (clonedAlgorithm.ExecutionState == ExecutionState.Started ||
    337320            clonedAlgorithm.ExecutionState == ExecutionState.Paused)
     
    360343    public void CollectResultValues(IDictionary<string, IItem> results) {
    361344      Dictionary<string, List<double>> resultValues = new Dictionary<string, List<double>>();
    362       IEnumerable<IRun> runs = ClonedAlgorithms.Select(alg => alg.Runs.FirstOrDefault()).Where(run => run != null);
     345      IEnumerable<IRun> runs = clonedAlgorithms.Select(alg => alg.Runs.FirstOrDefault()).Where(run => run != null);
    363346      IEnumerable<KeyValuePair<string, IItem>> resultCollections = runs.Where(x => x != null).SelectMany(x => x.Results).ToList();
    364347
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs

    r5419 r5420  
    137137        //The content must be stopped if no other view showing the content is available
    138138        var optimizers = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v != this).Select(v => v.Content).OfType<IOptimizer>();
    139         //add nested optimizers
    140         optimizers = optimizers.SelectMany(opt => opt.NestedOptimizers).Union(optimizers);
    141 
    142         if (!optimizers.Contains(Content)) Content.Stop();
     139        if (!optimizers.Contains(Content)) {
     140          var nestedOptimizers = optimizers.SelectMany(opt => opt.NestedOptimizers);
     141          if (!nestedOptimizers.Contains(Content)) Content.Stop();
     142        }
    143143      }
    144144      base.OnClosed(e);
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs

    r5419 r5420  
    113113        //The content must be stopped if no other view showing the content is available
    114114        var optimizers = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v != this).Select(v => v.Content).OfType<IOptimizer>();
    115         //add nested optimizers
    116         optimizers = optimizers.SelectMany(opt => opt.NestedOptimizers).Union(optimizers);
    117 
    118         if (!optimizers.Contains(Content)) Content.Stop();
     115        if (!optimizers.Contains(Content)) {
     116          var nestedOptimizers = optimizers.SelectMany(opt => opt.NestedOptimizers);
     117          if (!nestedOptimizers.Contains(Content)) Content.Stop();
     118        }
    119119      }
    120120      base.OnClosed(e);
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.cs

    r5419 r5420  
    9595        //The content must be stopped if no other view showing the content is available
    9696        var optimizers = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v != this).Select(v => v.Content).OfType<IOptimizer>();
    97         //add nested optimizers
    98         optimizers = optimizers.SelectMany(opt => opt.NestedOptimizers).Union(optimizers);
    99 
    100         if (!optimizers.Contains(Content)) Content.Stop();
     97        if (!optimizers.Contains(Content)) {
     98          var nestedOptimizers = optimizers.SelectMany(opt => opt.NestedOptimizers);
     99          if (!nestedOptimizers.Contains(Content)) Content.Stop();
     100        }
    101101      }
    102102      base.OnClosed(e);
Note: See TracChangeset for help on using the changeset viewer.