Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1418: Reintegrated branch into trunk.

File size: 5.1 KB
RevLine 
[3253]1#region License Information
2/* HeuristicLab
[5445]3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[3253]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;
[4068]24using System.Drawing;
[3376]25using HeuristicLab.Common;
[3253]26using HeuristicLab.Core;
[4068]27using HeuristicLab.Optimization;
28using HeuristicLab.Parameters;
[3253]29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[5809]30using HeuristicLab.PluginInfrastructure;
[3253]31
[3373]32namespace HeuristicLab.Problems.DataAnalysis {
[3528]33  [Item("Data Analysis Problem", "Represents a data analysis problem.")]
[3253]34  [StorableClass]
[5809]35  [NonDiscoverableType]
[4419]36  public class DataAnalysisProblem : ParameterizedNamedItem, IDataAnalysisProblem, IStorableContent {
[3373]37    private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData";
[4419]38
39    public string Filename { get; set; }
40
[3253]41    public override Image ItemImage {
[5287]42      get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
[3253]43    }
44
45    #region Parameter Properties
[3373]46    public ValueParameter<DataAnalysisProblemData> DataAnalysisProblemDataParameter {
47      get { return (ValueParameter<DataAnalysisProblemData>)Parameters[DataAnalysisProblemDataParameterName]; }
[3253]48    }
49    #endregion
[3264]50    #region properties
[3373]51    public DataAnalysisProblemData DataAnalysisProblemData {
52      get { return DataAnalysisProblemDataParameter.Value; }
[3264]53    }
54    #endregion
[3253]55
[4118]56    [StorableConstructor]
57    protected DataAnalysisProblem(bool deserializing) : base(deserializing) { }
[4722]58    protected DataAnalysisProblem(DataAnalysisProblem original, Cloner cloner)
59      : base(original, cloner) {
60      RegisterParameterEvents();
61      RegisterParameterValueEvents();
62    }
63
[3373]64    public DataAnalysisProblem()
[3253]65      : base() {
[3373]66      Parameters.Add(new ValueParameter<DataAnalysisProblemData>(DataAnalysisProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem.", new DataAnalysisProblemData()));
[3545]67      RegisterParameterEvents();
68      RegisterParameterValueEvents();
[3253]69    }
70
[3545]71    [StorableHook(HookType.AfterDeserialization)]
[4722]72    private void AfterDeserialization() {
[3545]73      RegisterParameterEvents();
74      RegisterParameterValueEvents();
75    }
76
77    #region events
[3884]78    protected virtual void OnDataAnalysisProblemChanged(EventArgs e) {
79      RaiseReset(e);
80    }
[3545]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) {
[4722]100      return new DataAnalysisProblem(this, cloner);
[3545]101    }
[3877]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
[3253]153  }
154}
Note: See TracBrowser for help on using the repository browser.