Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisSolution.cs @ 3408

Last change on this file since 3408 was 3408, checked in by gkronber, 14 years ago

Worked on views for DataAnalysis problems #938 (Data types and operators for regression problems)

File size: 3.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
28
29namespace HeuristicLab.Problems.DataAnalysis {
30  /// <summary>
31  /// Represents a solution for a data analysis problem which can be visualized in the GUI.
32  /// </summary>
33  [Item("DataAnalysisSolution", "Represents a solution for a data analysis problem which can be visualized in the GUI.")]
34  [StorableClass]
35  public sealed class DataAnalysisSolution : Item {
36    [Storable]
37    private IPredictor predictor;
38    public IPredictor Predictor {
39      get { return predictor; }
40      set {
41        if (predictor != value) {
42          predictor = value;
43          OnPredictorChanged();
44        }
45      }
46    }
47
48    [Storable]
49    private DataAnalysisProblemData problemData;
50    public DataAnalysisProblemData ProblemData {
51      get { return problemData; }
52      set {
53        if (problemData != value) {
54          if (problemData != null) DeregisterProblemDataEvents();
55          problemData = value;
56          if (problemData != null) RegisterProblemDataEvents();
57          OnProblemDataChanged();
58        }
59      }
60    }
61   
62    public DataAnalysisSolution() : base() { }
63    public DataAnalysisSolution(DataAnalysisProblemData problemData, IPredictor predictor)
64      : this() {
65      this.problemData = problemData;
66      this.predictor = predictor;
67      Initialize();
68    }
69    [StorableConstructor]
70    private DataAnalysisSolution(bool deserializing) : base(deserializing) { }
71
72    [StorableHook(HookType.AfterDeserialization)]
73    private void Initialize() {
74      if (problemData != null) RegisterProblemDataEvents();
75    }
76
77    public override IDeepCloneable Clone(Cloner cloner) {
78      DataAnalysisSolution clone = new DataAnalysisSolution();
79      cloner.RegisterClonedObject(this, clone);
80      clone.ReadOnlyView = ReadOnlyView;
81      clone.predictor = (IPredictor)cloner.Clone(predictor);
82      clone.problemData = problemData;
83      clone.Initialize();
84      return clone;
85    }
86
87    #region Events
88    public event EventHandler PredictorChanged;
89    private void OnPredictorChanged() {
90      var changed = PredictorChanged;
91      if (changed != null)
92        changed(this, EventArgs.Empty);
93    }
94    public event EventHandler ProblemDataChanged;
95    private void OnProblemDataChanged() {
96      var changed = ProblemDataChanged;
97      if (changed != null)
98        changed(this, EventArgs.Empty);
99    }
100
101    private void RegisterProblemDataEvents() {
102      ProblemData.DatasetChanged += new EventHandler(ProblemData_DataSetChanged);
103    }
104    private void DeregisterProblemDataEvents() {
105      ProblemData.DatasetChanged += new EventHandler(ProblemData_DataSetChanged);
106    }
107
108    private void ProblemData_DataSetChanged(object sender, EventArgs e) {
109      OnProblemDataChanged();
110    }
111    #endregion
112  }
113}
Note: See TracBrowser for help on using the repository browser.