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