Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/06/10 21:38:31 (14 years ago)
Author:
mkommend
Message:

Adapted CrossValidation to use ISingleObjectiveDataAnalysisProblem (ticket #1199).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Classification/HeuristicLab.Algorithms.DataAnalysis/3.3/CrossValidation.cs

    r4561 r4563  
    7373    public override IDeepCloneable Clone(Cloner cloner) {
    7474      CrossValidation clone = (CrossValidation)base.Clone(cloner);
    75       clone.DeregisterEvents();
     75      clone.DeregisterEvents(); //not necessary
    7676      clone.executionState = executionState;
    7777      clone.executionTime = executionTime;
     
    107107
    108108          if (algorithm != null) {
    109             algorithm.StoreAlgorithmInEachRun = StoreAlgorithmInEachRun;
     109            algorithm.StoreAlgorithmInEachRun = false;
    110110            RegisterAlgorithmEvents();
    111111            algorithm.Prepare(true);
     
    121121
    122122    [Storable]
    123     private IDataAnalysisProblem cachedProblem;
    124     public IDataAnalysisProblem Problem {
     123    private ISingleObjectiveDataAnalysisProblem problem;
     124    public ISingleObjectiveDataAnalysisProblem Problem {
    125125      get {
    126126        if (algorithm == null)
    127127          return null;
    128         return (IDataAnalysisProblem)algorithm.Problem;
     128        return (ISingleObjectiveDataAnalysisProblem)algorithm.Problem;
    129129      }
    130130      set {
     
    133133        if (algorithm == null) throw new ArgumentNullException("Could not set a problem before an algorithm was set.");
    134134        algorithm.Problem = value;
    135         cachedProblem = value;
     135        problem = value;
    136136      }
    137137    }
     
    142142        if (value != null && !ProblemType.IsInstanceOfType(value))
    143143          throw new ArgumentException("Only DataAnalysisProblems could be used for the cross validation.");
    144         Problem = (IDataAnalysisProblem)value;
     144        Problem = (ISingleObjectiveDataAnalysisProblem)value;
    145145      }
    146146    }
    147147    public Type ProblemType {
    148       get { return typeof(IDataAnalysisProblem); }
     148      get { return typeof(ISingleObjectiveDataAnalysisProblem); }
    149149    }
    150150
     
    245245
    246246    public void Prepare() {
    247       if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped))
     247      if (ExecutionState == ExecutionState.Started)
    248248        throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
    249249      clonedAlgorithms.Clear();
     
    442442    }
    443443    private void Algorithm_ProblemChanged(object sender, EventArgs e) {
    444       if (algorithm.Problem != null && !(algorithm.Problem is IDataAnalysisProblem)) {
    445         algorithm.Problem = cachedProblem;
     444      if (algorithm.Problem != null && !(algorithm.Problem is ISingleObjectiveDataAnalysisProblem)) {
     445        algorithm.Problem = problem;
    446446        throw new ArgumentException("A cross validation algorithm can only contain DataAnalysisProblems.");
    447447      }
    448       cachedProblem = (IDataAnalysisProblem)algorithm.Problem;
     448      problem = (ISingleObjectiveDataAnalysisProblem)algorithm.Problem;
    449449      OnProblemChanged();
    450450    }
Note: See TracChangeset for help on using the changeset viewer.