Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/28/11 02:08:34 (13 years ago)
Author:
swagner
Message:

Modified ExecutionState handling in Experiment (#1714)

File:
1 edited

Legend:

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

    r7238 r7241  
    175175
    176176      if (clearRuns) runs.Clear();
     177
     178      experimentStarted = false;
     179      experimentStopped = false;
    177180      foreach (IOptimizer optimizer in Optimizers.Where(x => x.ExecutionState != ExecutionState.Started))
    178181        if (clearRuns || optimizer.ExecutionState != ExecutionState.Prepared)
     
    206209      experimentStarted = false;
    207210      experimentStopped = true;
    208       foreach (IOptimizer optimizer in Optimizers.Where(x => (x.ExecutionState == ExecutionState.Started) || (x.ExecutionState == ExecutionState.Paused)))
    209         optimizer.Stop();
     211      if (Optimizers.Any(x => (x.ExecutionState == ExecutionState.Started) || (x.ExecutionState == ExecutionState.Paused))) {
     212        foreach (IOptimizer optimizer in Optimizers.Where(x => (x.ExecutionState == ExecutionState.Started) || (x.ExecutionState == ExecutionState.Paused)))
     213          optimizer.Stop();
     214      } else {
     215        OnStopped();
     216      }
    210217    }
    211218
     
    326333    }
    327334    private void optimizer_Paused(object sender, EventArgs e) {
    328       if (Optimizers.All(x => x.ExecutionState != ExecutionState.Started))
    329         OnPaused();
     335      if (Optimizers.All(x => x.ExecutionState != ExecutionState.Started)) OnPaused();
    330336    }
    331337    private void optimizer_Prepared(object sender, EventArgs e) {
    332       if (ExecutionState == ExecutionState.Stopped)
    333         OnPrepared();
     338      if (Optimizers.All(x => x.ExecutionState == ExecutionState.Prepared)) OnPrepared();
     339      else if (Optimizers.All(x => x.ExecutionState != ExecutionState.Started)) OnPaused();
    334340    }
    335341    private void optimizer_Started(object sender, EventArgs e) {
    336       if (ExecutionState != ExecutionState.Started)
    337         OnStarted();
     342      if (ExecutionState != ExecutionState.Started) OnStarted();
    338343    }
    339344    private void optimizer_Stopped(object sender, EventArgs e) {
    340       if (!experimentStarted && Optimizers.Any(o => o.ExecutionState == ExecutionState.Prepared) && Optimizers.All(o => o.ExecutionState != ExecutionState.Started && o.ExecutionState != ExecutionState.Paused)) OnPrepared();
    341       else if (Optimizers.All(o => o.ExecutionState == ExecutionState.Stopped)) OnStopped();
    342       else if (Optimizers.Any(o => o.ExecutionState == ExecutionState.Paused) && Optimizers.All(o => o.ExecutionState != ExecutionState.Started)) OnPaused();
    343       else if (experimentStarted && !experimentStopped && Optimizers.Any(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused))) {
    344         Optimizers.First(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused)).Start();
     345      if (experimentStopped) {
     346        if (Optimizers.All(x => (x.ExecutionState == ExecutionState.Stopped) || (x.ExecutionState == ExecutionState.Prepared))) OnStopped();
     347      } else {
     348        if (experimentStarted && Optimizers.Any(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused))) {
     349          Optimizers.First(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused)).Start();
     350        } else if (Optimizers.All(x => x.ExecutionState == ExecutionState.Stopped)) OnStopped();
     351        else if (Optimizers.Any(x => (x.ExecutionState == ExecutionState.Prepared) || (x.ExecutionState == ExecutionState.Paused)) && Optimizers.All(o => o.ExecutionState != ExecutionState.Started)) OnPaused();
    345352      }
    346353    }
Note: See TracChangeset for help on using the changeset viewer.