Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4563 for branches


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

Adapted CrossValidation to use ISingleObjectiveDataAnalysisProblem (ticket #1199).

Location:
branches/HeuristicLab.Classification
Files:
4 edited

Legend:

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

    r4561 r4563  
    192192
    193193    private void workersNumericUpDown_Validated(object sender, EventArgs e) {
    194       if (foldsNumericUpDown.Text == string.Empty)
     194      if (workersNumericUpDown.Text == string.Empty)
    195195        workersNumericUpDown.Text = workersNumericUpDown.Value.ToString();
    196196    }
     
    261261        problemTypeSelectorDialog.Caption = "Select Problem";
    262262        problemTypeSelectorDialog.TypeSelector.Caption = "Available Problems";
    263         problemTypeSelectorDialog.TypeSelector.Configure(typeof(IDataAnalysisProblem), false, true);
     263        problemTypeSelectorDialog.TypeSelector.Configure(Content.ProblemType, false, true);
    264264      }
    265265      if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    266266        try {
    267           Content.Problem = (IDataAnalysisProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     267          Content.Problem = (ISingleObjectiveDataAnalysisProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    268268        }
    269269        catch (Exception ex) {
     
    282282          try {
    283283            if (error != null) throw error;
    284             IDataAnalysisProblem problem = content as IDataAnalysisProblem;
     284            ISingleObjectiveDataAnalysisProblem problem = content as ISingleObjectiveDataAnalysisProblem;
    285285            if (problem == null && (Content.Algorithm.ProblemType.IsAssignableFrom(content.GetType())))
    286286              Invoke(new Action(() =>
     
    339339    private void algorithmProblemTabPage_DragDrop(object sender, DragEventArgs e) {
    340340      if (e.Effect != DragDropEffects.None) {
    341         IDataAnalysisProblem problem = e.Data.GetData("Value") as IDataAnalysisProblem;
    342         if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) problem = (IDataAnalysisProblem)problem.Clone();
     341        ISingleObjectiveDataAnalysisProblem problem = e.Data.GetData("Value") as ISingleObjectiveDataAnalysisProblem;
     342        if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) problem = (ISingleObjectiveDataAnalysisProblem)problem.Clone();
    343343        Content.Problem = problem;
    344344      }
  • 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    }
  • branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3/ProblemBase/Problem.cs

    r4323 r4563  
    5151      Parameters.Add(new ValueParameter<T>(EvaluatorParameterName, "The operator used to evaluate a solution."));
    5252      Parameters.Add(new ValueParameter<U>(SolutionCreateParameterName, "The operator to create a solution."));
    53       RegisterParameterEventHandlers();
     53      RegisterEventHandlers();
    5454    }
    5555
    5656    [StorableHook(HookType.AfterDeserialization)]
    5757    private void AfterDeserialization() {
    58       RegisterParameterEventHandlers();
     58      RegisterEventHandlers();
    5959    }
    6060
     
    6262      Problem<T, U> clone = (Problem<T, U>)base.Clone(cloner);
    6363      clone.operators = new ItemCollection<IOperator>(operators.Select(x => (IOperator)cloner.Clone(x)));
    64       clone.RegisterParameterEventHandlers();
     64      clone.RegisterEventHandlers();
    6565      return clone;
    6666    }
    6767
    68     private void RegisterParameterEventHandlers() {
     68    private void RegisterEventHandlers() {
    6969      Operators.ItemsAdded += new CollectionItemsChangedEventHandler<IOperator>(Operators_Changed);
    7070      Operators.ItemsRemoved += new CollectionItemsChangedEventHandler<IOperator>(Operators_Changed);
     
    7777    #region properties
    7878    private ItemCollection<IOperator> operators;
    79     [Storable]
     79    [Storable(Name = "Operators")]
    8080    private IEnumerable<IOperator> StorableOperators {
    8181      get { return operators; }
  • branches/HeuristicLab.Classification/HeuristicLab.Problems.DataAnalysis.Classification/3.3/SingleObjectiveClassificationProblem.cs

    r4536 r4563  
    3030  [Item("Classification Problem", "Represents a classfication problem.")]
    3131  [StorableClass]
    32   public abstract class SingleObjectiveClassificationProblem<T, U> : SingleObjectiveProblem<T, U>, IDataAnalysisProblem
     32  public abstract class SingleObjectiveClassificationProblem<T, U> : SingleObjectiveProblem<T, U>, ISingleObjectiveDataAnalysisProblem
    3333    where T : class, ISingleObjectiveEvaluator
    3434    where U : class, ISolutionCreator {
Note: See TracChangeset for help on using the changeset viewer.