Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationPruningAnalyzer.cs @ 17912

Last change on this file since 17912 was 17181, checked in by swagner, 5 years ago

#2875: Merged r17180 from trunk to stable

File size: 4.3 KB
RevLine 
[11145]1#region License Information
2/* HeuristicLab
[17181]3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[11145]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
[10368]22using HeuristicLab.Common;
23using HeuristicLab.Core;
[12745]24using HeuristicLab.Data;
[10368]25using HeuristicLab.Parameters;
[17097]26using HEAL.Attic;
[10368]27
28namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
29  [Item("SymbolicClassificationPruningAnalyzer", "An analyzer that prunes introns from the population.")]
[17097]30  [StorableType("26701D59-DEB6-4CBF-89DC-C5C3F310B634")]
[10368]31  public sealed class SymbolicClassificationPruningAnalyzer : SymbolicDataAnalysisSingleObjectivePruningAnalyzer {
[11145]32    private const string PruningOperatorParameterName = "PruningOperator";
[12745]33    public IValueParameter<SymbolicClassificationPruningOperator> PruningOperatorParameter {
34      get { return (IValueParameter<SymbolicClassificationPruningOperator>)Parameters[PruningOperatorParameterName]; }
[10368]35    }
[12745]36
37    protected override SymbolicDataAnalysisExpressionPruningOperator PruningOperator {
38      get { return PruningOperatorParameter.Value; }
[10368]39    }
40
[12745]41    private SymbolicClassificationPruningAnalyzer(SymbolicClassificationPruningAnalyzer original, Cloner cloner) : base(original, cloner) { }
42    public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicClassificationPruningAnalyzer(this, cloner); }
43
[11145]44    [StorableConstructor]
[17097]45    private SymbolicClassificationPruningAnalyzer(StorableConstructorFlag _) : base(_) { }
[11145]46
[10368]47    public SymbolicClassificationPruningAnalyzer() {
[12745]48      Parameters.Add(new ValueParameter<SymbolicClassificationPruningOperator>(PruningOperatorParameterName, "The operator used to prune trees", new SymbolicClassificationPruningOperator(new SymbolicClassificationSolutionImpactValuesCalculator())));
[10368]49    }
[12745]50
51    [StorableHook(HookType.AfterDeserialization)]
52    private void AfterDeserialization() {
53      // BackwardsCompatibility3.3
54
55      #region Backwards compatible code, remove with 3.4
56      if (Parameters.ContainsKey(PruningOperatorParameterName)) {
57        var oldParam = Parameters[PruningOperatorParameterName] as ValueParameter<SymbolicDataAnalysisExpressionPruningOperator>;
58        if (oldParam != null) {
59          Parameters.Remove(oldParam);
60          Parameters.Add(new ValueParameter<SymbolicClassificationPruningOperator>(PruningOperatorParameterName, "The operator used to prune trees", new SymbolicClassificationPruningOperator(new SymbolicClassificationSolutionImpactValuesCalculator())));
61        }
62      } else {
63        // not yet contained
64        Parameters.Add(new ValueParameter<SymbolicClassificationPruningOperator>(PruningOperatorParameterName, "The operator used to prune trees", new SymbolicClassificationPruningOperator(new SymbolicClassificationSolutionImpactValuesCalculator())));
65      }
66
67      if (Parameters.ContainsKey("PruneOnlyZeroImpactNodes")) {
68        PruningOperator.PruneOnlyZeroImpactNodes = ((IFixedValueParameter<BoolValue>)Parameters["PruneOnlyZeroImpactNodes"]).Value.Value;
69        Parameters.Remove(Parameters["PruneOnlyZeroImpactNodes"]);
70      }
71      if (Parameters.ContainsKey("ImpactThreshold")) {
72        PruningOperator.NodeImpactThreshold = ((IFixedValueParameter<DoubleValue>)Parameters["ImpactThreshold"]).Value.Value;
73        Parameters.Remove(Parameters["ImpactThreshold"]);
74      }
75      if (Parameters.ContainsKey("ImpactValuesCalculator")) {
76        PruningOperator.ImpactValuesCalculator = ((ValueParameter<SymbolicDataAnalysisSolutionImpactValuesCalculator>)Parameters["ImpactValuesCalculator"]).Value;
77        Parameters.Remove(Parameters["ImpactValuesCalculator"]);
78      }
79      #endregion
80    }
[10368]81  }
82}
Note: See TracBrowser for help on using the repository browser.