Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis Refactoring/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblem.cs @ 5678

Last change on this file since 5678 was 5625, checked in by mkommend, 13 years ago

#1418: Reorganized branch and removed CreateAble-Attribute from outdated classes.

File size: 5.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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 System.Collections.Generic;
24using System.Drawing;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Optimization;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30
31namespace HeuristicLab.Problems.DataAnalysis {
32  [Item("Data Analysis Problem", "Represents a data analysis problem.")]
33  [StorableClass]
34  public class DataAnalysisProblem : ParameterizedNamedItem, IDataAnalysisProblem, IStorableContent {
35    private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData";
36
37    public string Filename { get; set; }
38
39    public override Image ItemImage {
40      get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
41    }
42
43    #region Parameter Properties
44    public ValueParameter<DataAnalysisProblemData> DataAnalysisProblemDataParameter {
45      get { return (ValueParameter<DataAnalysisProblemData>)Parameters[DataAnalysisProblemDataParameterName]; }
46    }
47    #endregion
48    #region properties
49    public DataAnalysisProblemData DataAnalysisProblemData {
50      get { return DataAnalysisProblemDataParameter.Value; }
51    }
52    #endregion
53
54    [StorableConstructor]
55    protected DataAnalysisProblem(bool deserializing) : base(deserializing) { }
56    protected DataAnalysisProblem(DataAnalysisProblem original, Cloner cloner)
57      : base(original, cloner) {
58      RegisterParameterEvents();
59      RegisterParameterValueEvents();
60    }
61
62    public DataAnalysisProblem()
63      : base() {
64      Parameters.Add(new ValueParameter<DataAnalysisProblemData>(DataAnalysisProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem.", new DataAnalysisProblemData()));
65      RegisterParameterEvents();
66      RegisterParameterValueEvents();
67    }
68
69    [StorableHook(HookType.AfterDeserialization)]
70    private void AfterDeserialization() {
71      RegisterParameterEvents();
72      RegisterParameterValueEvents();
73    }
74
75    #region events
76    protected virtual void OnDataAnalysisProblemChanged(EventArgs e) {
77      RaiseReset(e);
78    }
79
80    private void RegisterParameterEvents() {
81      DataAnalysisProblemDataParameter.ValueChanged += new EventHandler(DataAnalysisProblemDataParameter_ValueChanged);
82    }
83
84    private void RegisterParameterValueEvents() {
85      DataAnalysisProblemData.ProblemDataChanged += new EventHandler(DataAnalysisProblemData_ProblemDataChanged);
86    }
87
88    private void DataAnalysisProblemDataParameter_ValueChanged(object sender, EventArgs e) {
89      OnDataAnalysisProblemChanged(e);
90    }
91
92    private void DataAnalysisProblemData_ProblemDataChanged(object sender, EventArgs e) {
93      OnDataAnalysisProblemChanged(e);
94    }
95    #endregion
96
97    public override IDeepCloneable Clone(Cloner cloner) {
98      return new DataAnalysisProblem(this, cloner);
99    }
100
101    #region IProblem Members
102
103    public virtual IParameter SolutionCreatorParameter {
104      get { return null; }
105    }
106
107    public virtual ISolutionCreator SolutionCreator {
108      get { return null; }
109    }
110
111    public virtual IParameter EvaluatorParameter {
112      get { return null; }
113    }
114
115    public virtual IEvaluator Evaluator {
116      get { return null; }
117    }
118
119    public virtual IEnumerable<IOperator> Operators {
120      get { return new IOperator[0]; }
121    }
122
123    public event EventHandler SolutionCreatorChanged;
124    protected void RaiseSolutionCreatorChanged(EventArgs e) {
125      var changed = SolutionCreatorChanged;
126      if (changed != null)
127        changed(this, e);
128    }
129
130    public event EventHandler EvaluatorChanged;
131    protected void RaiseEvaluatorChanged(EventArgs e) {
132      var changed = EvaluatorChanged;
133      if (changed != null)
134        changed(this, e);
135    }
136
137    public event EventHandler OperatorsChanged;
138    protected void RaiseOperatorsChanged(EventArgs e) {
139      var changed = OperatorsChanged;
140      if (changed != null)
141        changed(this, e);
142    }
143
144    public event EventHandler Reset;
145    protected void RaiseReset(EventArgs e) {
146      var changed = Reset;
147      if (changed != null)
148        changed(this, e);
149    }
150    #endregion
151  }
152}
Note: See TracBrowser for help on using the repository browser.