1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2018 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 HeuristicLab.Common;
|
---|
23 | using HeuristicLab.Core;
|
---|
24 | using HeuristicLab.Data;
|
---|
25 | using HeuristicLab.Parameters;
|
---|
26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Problems.DataAnalysis {
|
---|
29 | [Item("Transformation", "A transformation applied to a DataAnalysisProblemData")]
|
---|
30 | [StorableClass]
|
---|
31 | public sealed class DataAnalysisTransformation : ParameterizedNamedItem, IDataAnalysisTransformation {
|
---|
32 | #region Parameter Properties
|
---|
33 | private IFixedValueParameter<StringValue> OriginalVariableParameter {
|
---|
34 | get { return (IFixedValueParameter<StringValue>)Parameters["Original Variable"]; }
|
---|
35 | }
|
---|
36 |
|
---|
37 | private IFixedValueParameter<StringValue> TransformedVariableParameter {
|
---|
38 | get { return (IFixedValueParameter<StringValue>)Parameters["Transformed Variable"]; }
|
---|
39 | }
|
---|
40 |
|
---|
41 | private ValueParameter<ITransformation> TransformationParameter {
|
---|
42 | get { return (ValueParameter<ITransformation>)Parameters["Transformation"]; }
|
---|
43 | }
|
---|
44 | #endregion
|
---|
45 |
|
---|
46 | #region Properties
|
---|
47 | public string OriginalVariable {
|
---|
48 | get { return OriginalVariableParameter.Value.Value; }
|
---|
49 | }
|
---|
50 |
|
---|
51 | public string TransformedVariable {
|
---|
52 | get { return TransformedVariableParameter.Value.Value; }
|
---|
53 | }
|
---|
54 |
|
---|
55 | public ITransformation Transformation {
|
---|
56 | get { return TransformationParameter.Value; }
|
---|
57 | }
|
---|
58 | #endregion
|
---|
59 |
|
---|
60 | #region Constructor, Cloning & Persistence
|
---|
61 | public DataAnalysisTransformation(string originalVariable, string transformedVariable, ITransformation transformation)
|
---|
62 | : base() {
|
---|
63 | Parameters.Add(new FixedValueParameter<StringValue>("Original Variable", new StringValue(originalVariable).AsReadOnly()));
|
---|
64 | Parameters.Add(new FixedValueParameter<StringValue>("Transformed Variable", new StringValue(transformedVariable).AsReadOnly()));
|
---|
65 | Parameters.Add(new ValueParameter<ITransformation>("Transformation", transformation)); // TODO: should be readonly/fixed
|
---|
66 | }
|
---|
67 |
|
---|
68 | private DataAnalysisTransformation(DataAnalysisTransformation original, Cloner cloner)
|
---|
69 | : base(original, cloner) {
|
---|
70 | }
|
---|
71 |
|
---|
72 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
73 | return new DataAnalysisTransformation(this, cloner);
|
---|
74 | }
|
---|
75 |
|
---|
76 | [StorableConstructor]
|
---|
77 | private DataAnalysisTransformation(bool deserializing)
|
---|
78 | : base(deserializing) { }
|
---|
79 |
|
---|
80 | [StorableHook(HookType.AfterDeserialization)]
|
---|
81 | #endregion
|
---|
82 |
|
---|
83 | public override string ToString() {
|
---|
84 | return $"{Transformation} ({OriginalVariable} -> {TransformedVariable})";
|
---|
85 | }
|
---|
86 | }
|
---|
87 | } |
---|