Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/28/12 12:19:01 (12 years ago)
Author:
mkommend
Message:

#1917: Added missing event registration in AfterDeserialization of CrossValidation and clean up code if a problem changes in the crossvalidation. Additionally, I removed explicit calls to OnReset in the Load methods of IDataAnalysisProblems the reset event is automatically fired when the problem data is changed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/CrossValidation.cs

    r8962 r8965  
    7373      RegisterEvents();
    7474      if (Algorithm != null) RegisterAlgorithmEvents();
     75      if (Problem != null) Problem.Reset += (o, e) => OnProblemChanged();
    7576    }
    7677
     
    521522    private void RegisterEvents() {
    522523      Folds.ValueChanged += new EventHandler(Folds_ValueChanged);
    523       SamplesStart.ValueChanged += new EventHandler(SamplesStart_ValueChanged);
    524       SamplesEnd.ValueChanged += new EventHandler(SamplesEnd_ValueChanged);
    525524      RegisterClonedAlgorithmsEvents();
    526525    }
     
    530529    }
    531530
    532     private bool samplesChanged = false;
    533     private void SamplesStart_ValueChanged(object sender, EventArgs e) {
    534       samplesChanged = true;
    535       if (Problem != null) Problem.ProblemData.TrainingPartition.Start = SamplesStart.Value;
    536       samplesChanged = false;
    537     }
    538     private void SamplesEnd_ValueChanged(object sender, EventArgs e) {
    539       samplesChanged = true;
    540       if (Problem != null) Problem.ProblemData.TrainingPartition.End = SamplesEnd.Value;
    541       samplesChanged = false;
    542     }
    543531
    544532    #region template algorithms events
     
    571559      EventHandler handler = ProblemChanged;
    572560      if (handler != null) handler(this, EventArgs.Empty);
    573       if (samplesChanged) return;
    574561
    575562      SamplesStart.Value = 0;
     
    593580      } else
    594581        SamplesEnd.Value = 0;
    595 
    596       SamplesStart_ValueChanged(this, EventArgs.Empty);
    597       SamplesEnd_ValueChanged(this, EventArgs.Empty);
    598582    }
    599583
     
    689673      lock (locker) {
    690674        if (!stopPending && ExecutionState == ExecutionState.Started) {
    691           IAlgorithm preparedAlgorithm = clonedAlgorithms.Where(alg => alg.ExecutionState == ExecutionState.Prepared ||
    692                                                                        alg.ExecutionState == ExecutionState.Paused).FirstOrDefault();
     675          IAlgorithm preparedAlgorithm = clonedAlgorithms.FirstOrDefault(alg => alg.ExecutionState == ExecutionState.Prepared ||
     676                                                                                alg.ExecutionState == ExecutionState.Paused);
    693677          if (preparedAlgorithm != null) preparedAlgorithm.Start();
    694678        }
Note: See TracChangeset for help on using the changeset viewer.