[11145] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15584] | 3 | * Copyright (C) 2002-2018 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] | 22 | using HeuristicLab.Common;
|
---|
| 23 | using HeuristicLab.Core;
|
---|
[12745] | 24 | using HeuristicLab.Data;
|
---|
[10368] | 25 | using HeuristicLab.Parameters;
|
---|
| 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
|
---|
| 29 | [Item("SymbolicClassificationPruningAnalyzer", "An analyzer that prunes introns from the population.")]
|
---|
| 30 | [StorableClass]
|
---|
| 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]
|
---|
| 45 | private SymbolicClassificationPruningAnalyzer(bool deserializing) : base(deserializing) { }
|
---|
| 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 | }
|
---|