Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblem.cs @ 6027

Last change on this file since 6027 was 5809, checked in by mkommend, 14 years ago

#1418: Reintegrated branch into trunk.

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