Changeset 8969


Ignore:
Timestamp:
11/28/12 17:21:55 (10 years ago)
Author:
mkommend
Message:

#1917: Corrected event registration for problem changes in CrossValidation.

File:
1 edited

Legend:

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

    r8965 r8969  
    7373      RegisterEvents();
    7474      if (Algorithm != null) RegisterAlgorithmEvents();
    75       if (Problem != null) Problem.Reset += (o, e) => OnProblemChanged();
    7675    }
    7776
     
    121120          }
    122121          OnAlgorithmChanged();
    123           if (algorithm != null) OnProblemChanged();
    124122          Prepare();
    125123        }
     
    541539      algorithm.ProblemChanged += new EventHandler(Algorithm_ProblemChanged);
    542540      algorithm.ExecutionStateChanged += new EventHandler(Algorithm_ExecutionStateChanged);
     541      if (Problem != null) Problem.Reset += new EventHandler(Problem_Reset);
    543542    }
    544543    private void DeregisterAlgorithmEvents() {
    545544      algorithm.ProblemChanged -= new EventHandler(Algorithm_ProblemChanged);
    546545      algorithm.ExecutionStateChanged -= new EventHandler(Algorithm_ExecutionStateChanged);
     546      if (Problem != null) Problem.Reset -= new EventHandler(Problem_Reset);
    547547    }
    548548    private void Algorithm_ProblemChanged(object sender, EventArgs e) {
     
    551551        throw new ArgumentException("A cross validation algorithm can only contain DataAnalysisProblems.");
    552552      }
    553       algorithm.Problem.Reset += (x, y) => OnProblemChanged();
     553      if(problem!= null) problem.Reset -= new EventHandler(Problem_Reset);
     554      if (Problem != null) Problem.Reset += new EventHandler(Problem_Reset);
    554555      problem = (IDataAnalysisProblem)algorithm.Problem;
    555556      OnProblemChanged();
     
    559560      EventHandler handler = ProblemChanged;
    560561      if (handler != null) handler(this, EventArgs.Empty);
    561 
    562       SamplesStart.Value = 0;
     562      ConfigureProblem();
     563    }
     564
     565    private void Problem_Reset(object sender, EventArgs e) {
     566      ConfigureProblem();
     567    }
     568
     569    private void ConfigureProblem(){
     570    SamplesStart.Value = 0;
    563571      if (Problem != null) {
    564572        SamplesEnd.Value = Problem.ProblemData.Dataset.Rows;
Note: See TracChangeset for help on using the changeset viewer.