Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9525


Ignore:
Timestamp:
05/24/13 14:31:11 (10 years ago)
Author:
mkommend
Message:

#2052: Merged r9493, r9504, and r9517 into the stable branch.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.DataAnalysis

  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r9456 r9525  
    266266    }
    267267
    268     private bool startPending;
    269268    public void Start() {
    270269      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused))
    271270        throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState));
    272271
    273       if (Algorithm != null && !startPending) {
    274         startPending = true;
     272      if (Algorithm != null) {
    275273        //create cloned algorithms
    276274        if (clonedAlgorithms.Count == 0) {
     
    335333      if (!pausePending) {
    336334        pausePending = true;
    337         if (!startPending) PauseAllClonedAlgorithms();
     335        PauseAllClonedAlgorithms();
    338336      }
    339337    }
     
    352350      if (!stopPending) {
    353351        stopPending = true;
    354         if (!startPending) StopAllClonedAlgorithms();
     352        StopAllClonedAlgorithms();
    355353      }
    356354    }
     
    389387
    390388    private void AggregateResultValues(IDictionary<string, IItem> results) {
    391       Dictionary<string, List<double>> resultValues = new Dictionary<string, List<double>>();
    392389      IEnumerable<IRun> runs = clonedAlgorithms.Select(alg => alg.Runs.FirstOrDefault()).Where(run => run != null);
    393390      IEnumerable<KeyValuePair<string, IItem>> resultCollections = runs.Where(x => x != null).SelectMany(x => x.Results).ToList();
     
    552549      }
    553550      if (problem != null) problem.Reset -= new EventHandler(Problem_Reset);
    554       if (Problem != null) Problem.Reset += new EventHandler(Problem_Reset);
    555551      problem = (IDataAnalysisProblem)algorithm.Problem;
     552      if (problem != null) problem.Reset += new EventHandler(Problem_Reset);
    556553      OnProblemChanged();
    557554    }
     
    653650
    654651    private readonly object locker = new object();
     652    private readonly object resultLocker = new object();
    655653    private void ClonedAlgorithm_Started(object sender, EventArgs e) {
    656       lock (locker) {
    657         IAlgorithm algorithm = sender as IAlgorithm;
     654      IAlgorithm algorithm = sender as IAlgorithm;
     655      lock (resultLocker) {
    658656        if (algorithm != null && !results.ContainsKey(algorithm.Name))
    659657          results.Add(new Result(algorithm.Name, "Contains results for the specific fold.", algorithm.Results));
    660 
    661         if (startPending) {
    662           int startedAlgorithms = clonedAlgorithms.Count(alg => alg.ExecutionState == ExecutionState.Started);
    663           if (startedAlgorithms == NumberOfWorkers.Value ||
    664              clonedAlgorithms.All(alg => alg.ExecutionState != ExecutionState.Prepared))
    665             startPending = false;
    666 
    667           if (pausePending) PauseAllClonedAlgorithms();
    668           if (stopPending) StopAllClonedAlgorithms();
    669         }
    670658      }
    671659    }
     
    718706    public event EventHandler Started;
    719707    private void OnStarted() {
    720       startPending = false;
    721708      ExecutionState = ExecutionState.Started;
    722709      EventHandler handler = Started;
Note: See TracChangeset for help on using the changeset viewer.