Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5419


Ignore:
Timestamp:
02/04/11 01:29:43 (14 years ago)
Author:
mkommend
Message:

#1402 - Implemented IOptmizer.NestedOptimizers and adapted optimizer views to stop their content only if no way to display the content is available.

Location:
trunk/sources
Files:
9 edited

Legend:

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

    r4569 r5419  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Windows.Forms;
    2425using HeuristicLab.Common;
     
    102103    }
    103104
     105    protected override void OnClosed(FormClosedEventArgs e) {
     106      if ((Content != null) && (Content.ExecutionState == ExecutionState.Started)) {
     107        //The content must be stopped if no other view showing the content is available
     108        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();
     113      }
     114      base.OnClosed(e);
     115    }
     116
    104117    protected override void SetEnabledStateOfControls() {
    105118      if (InvokeRequired) Invoke((Action)SetEnabledStateOfControls);
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.3/CrossValidation.cs

    r5287 r5419  
    165165    }
    166166
     167    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      }
     178    }
     179
    167180    [Storable]
    168181    private ResultCollection results;
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs

    r5237 r5419  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using System.Windows.Forms;
    2526using HeuristicLab.Common;
     
    133134
    134135    protected override void OnClosed(FormClosedEventArgs e) {
    135       if ((Content != null) && (Content.ExecutionState == ExecutionState.Started)) Content.Stop();
     136      if ((Content != null) && (Content.ExecutionState == ExecutionState.Started)) {
     137        //The content must be stopped if no other view showing the content is available
     138        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();
     143      }
    136144      base.OnClosed(e);
    137145    }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs

    r5300 r5419  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Windows.Forms;
    2425using HeuristicLab.Common;
     
    109110
    110111    protected override void OnClosed(FormClosedEventArgs e) {
    111       if ((Content != null) && (Content.ExecutionState == ExecutionState.Started)) Content.Stop();
     112      if ((Content != null) && (Content.ExecutionState == ExecutionState.Started)) {
     113        //The content must be stopped if no other view showing the content is available
     114        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();
     119      }
    112120      base.OnClosed(e);
    113121    }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.cs

    r4540 r5419  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Windows.Forms;
    2425using HeuristicLab.Common;
     
    9192
    9293    protected override void OnClosed(FormClosedEventArgs e) {
    93       if ((Content != null) && (Content.ExecutionState == ExecutionState.Started)) Content.Stop();
     94      if ((Content != null) && (Content.ExecutionState == ExecutionState.Started)) {
     95        //The content must be stopped if no other view showing the content is available
     96        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();
     101      }
    94102      base.OnClosed(e);
    95103    }
  • trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs

    r5287 r5419  
    2323using System.Collections.Generic;
    2424using System.Drawing;
     25using System.Linq;
    2526using HeuristicLab.Collections;
    2627using HeuristicLab.Common;
     
    120121    }
    121122
     123    public virtual IEnumerable<IOptimizer> NestedOptimizers {
     124      get { return Enumerable.Empty<IOptimizer>(); }
     125    }
     126
    122127    protected Algorithm()
    123128      : base() {
  • trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs

    r5409 r5419  
    137137    }
    138138
     139    public IEnumerable<IOptimizer> NestedOptimizers {
     140      get {
     141        if (Optimizer == null) yield break;
     142
     143        yield return Optimizer;
     144        foreach (IOptimizer opt in Optimizer.NestedOptimizers)
     145          yield return opt;
     146      }
     147    }
     148
    139149    private bool stopPending;
    140150
  • trunk/sources/HeuristicLab.Optimization/3.3/Experiment.cs

    r5300 r5419  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
    2425using System.Linq;
     
    9192    }
    9293
     94    public IEnumerable<IOptimizer> NestedOptimizers {
     95      get {
     96        if (Optimizers == null) yield break;
     97
     98        foreach (IOptimizer opt in Optimizers) {
     99          yield return opt;
     100          foreach (IOptimizer nestedOpt in opt.NestedOptimizers)
     101            yield return nestedOpt;
     102        }
     103      }
     104    }
     105
    93106    private bool stopPending;
    94107
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IOptimizer.cs

    r4068 r5419  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HeuristicLab.Core;
    2324
     
    3031
    3132    void Prepare(bool clearRuns);
     33
     34    IEnumerable<IOptimizer> NestedOptimizers { get; }
    3235  }
    3336}
Note: See TracChangeset for help on using the changeset viewer.