source: branches/2839_HiveProjectManagement/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveAnalyzer.cs @ 16057

Last change on this file since 16057 was 16057, checked in by jkarder, 4 years ago

#2839:

File size: 3.7 KB
Line 
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
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Parameters;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
29  /// <summary>
30  /// Abstract base class for single objective symbolic data analysis analyzers.
31  /// </summary>
32  [StorableClass]
33  public abstract class SymbolicDataAnalysisSingleObjectiveAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicDataAnalysisSingleObjectiveAnalyzer {
34    private const string QualityParameterName = "Quality";
35    private const string MaximizationParameterName = "Maximization";
36    private const string ApplyLinearScalingParameterName = "ApplyLinearScaling";
37
38    #region parameter properties
39    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
40      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters[QualityParameterName]; }
41    }
42    public ILookupParameter<BoolValue> MaximizationParameter {
43      get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; }
44    }
45    public ILookupParameter<BoolValue> ApplyLinearScalingParameter {
46      get { return (ILookupParameter<BoolValue>)Parameters[ApplyLinearScalingParameterName]; }
47    }
48    #endregion
49    #region properties
50    public ItemArray<DoubleValue> Quality {
51      get { return QualityParameter.ActualValue; }
52    }
53    public BoolValue Maximization {
54      get { return MaximizationParameter.ActualValue; }
55    }
56    #endregion
57    [StorableConstructor]
58    protected SymbolicDataAnalysisSingleObjectiveAnalyzer(bool deserializing) : base(deserializing) { }
59    protected SymbolicDataAnalysisSingleObjectiveAnalyzer(SymbolicDataAnalysisSingleObjectiveAnalyzer original, Cloner cloner)
60      : base(original, cloner) {
61    }
62    public SymbolicDataAnalysisSingleObjectiveAnalyzer()
63      : base() {
64      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName, "The qualities of the trees that should be analyzed."));
65      Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "The direction of optimization."));
66      Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating."));
67    }
68
69    [StorableHook(HookType.AfterDeserialization)]
70    private void AfterDeserialization() {
71      if (Parameters.ContainsKey(ApplyLinearScalingParameterName) && !(Parameters[ApplyLinearScalingParameterName] is LookupParameter<BoolValue>))
72        Parameters.Remove(ApplyLinearScalingParameterName);
73      if (!Parameters.ContainsKey(ApplyLinearScalingParameterName))
74        Parameters.Add(new LookupParameter<BoolValue>(ApplyLinearScalingParameterName, "Flag that indicates if the individual should be linearly scaled before evaluating."));
75    }
76  }
77}
Note: See TracBrowser for help on using the repository browser.