Free cookie consent management tool by TermsFeed Policy Generator

Opened 7 years ago

Closed 7 years ago

#2823 closed defect (done)

Synchronous Experiment.Start call might return too early

Reported by: pfleck Owned by: pfleck
Priority: medium Milestone: HeuristicLab 3.3.15
Component: Optimization Version: 3.3.14
Keywords: Cc:

Description

Experiment.Start method might return prematurely if another Optimizer was started asynchronously.

Change History (9)

comment:1 Changed 7 years ago by pfleck

  • Status changed from new to accepted

comment:2 Changed 7 years ago by pfleck

r15327 Fixed potential early return of sync Start method.

Tested with the following Script:

using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;

using HeuristicLab.Core;
using HeuristicLab.Common;
using HeuristicLab.Collections;
using HeuristicLab.Data;
using HeuristicLab.Optimization;

public class MyScript : HeuristicLab.Scripting.CSharpScriptBase {
  public override void Main() {
    Experiment exp = vars.Experiment;
    var longOpt = exp.Optimizers.Find(o => o.Name == "10x Random Forest Regression (RF) {Number of trees=1000000}");
    
    Console.WriteLine("Preparing...");
    exp.Prepare();
        
    Task.Run(async () => {
      await Task.Delay(100);
      Console.WriteLine("start long Optimizer");
      longOpt.Start(); // sync or await async
      Console.WriteLine("long Optimizer finished");
    });
    
    Console.WriteLine("Starting...");
    exp.Start();
    
    Console.WriteLine("Finished.");
    
    foreach (var grp in exp.Optimizers.GroupBy(o => o.ExecutionState)) {
      Console.WriteLine(grp.Key);
      foreach (var opt in grp) {
        Console.WriteLine("   " + opt.Name);
      }
    }
  }
}

The Experiment contains some random forests (new RF -> Create experiments -> Number of Trees 25,50,1000000,100,100)

Before the change:

Preparing...
Starting...
start long Optimizer
Finished.
Stopped
   10x Random Forest Regression (RF) {Number of trees=25}
   10x Random Forest Regression (RF) {Number of trees=50}
   10x Random Forest Regression (RF) {Number of trees=100}
   10x Random Forest Regression (RF) {Number of trees=100}
Started
   10x Random Forest Regression (RF) {Number of trees=1000000}
long Optimizer finished

After the change:

Preparing...
Starting...
start long Optimizer
Finished.
Stopped
long Optimizer finished
   10x Random Forest Regression (RF) {Number of trees=25}
   10x Random Forest Regression (RF) {Number of trees=50}
   10x Random Forest Regression (RF) {Number of trees=1000000}
   10x Random Forest Regression (RF) {Number of trees=100}
   10x Random Forest Regression (RF) {Number of trees=100}

comment:3 Changed 7 years ago by pfleck

r15339 Moved wait-handle .Set to OnPaused/OnStopped.

Same test outputs as above.

comment:4 Changed 7 years ago by pfleck

  • Owner changed from pfleck to jkarder
  • Status changed from accepted to reviewing

comment:5 Changed 7 years ago by pfleck

  • Owner changed from jkarder to pfleck
  • Status changed from reviewing to assigned

comment:6 Changed 7 years ago by pfleck

  • Status changed from assigned to accepted

comment:7 Changed 7 years ago by pfleck

  • Owner changed from pfleck to jkarder
  • Status changed from accepted to reviewing

comment:8 Changed 7 years ago by jkarder

  • Owner changed from jkarder to pfleck
  • Status changed from reviewing to readytorelease

Looks good, thanks!

comment:9 Changed 7 years ago by pfleck

  • Resolution set to done
  • Status changed from readytorelease to closed

#2823 merged r15327, r15339 to stable

Note: See TracTickets for help on using tickets.