Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1772_HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisBottomUpDiversityAnalyzer.cs @ 16147

Last change on this file since 16147 was 16130, checked in by bburlacu, 6 years ago

#1772: Merge trunk changes

File size: 3.5 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.Analysis;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Parameters;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
30  [Item("SymbolicDataAnalysisBottomUpDiversityAnalyzer", "A diversity analyzer based on the bottom-up distance between trees.")]
31  [StorableClass]
32  public class SymbolicDataAnalysisBottomUpDiversityAnalyzer : PopulationSimilarityAnalyzer {
33    private const string MatchConstantValuesParameterName = "MatchConstantValues";
34    private const string MatchVariableWeightsParameterName = "MatchVariableWeights";
35
36    public IFixedValueParameter<BoolValue> MatchConstantValuesParameter {
37      get { return (IFixedValueParameter<BoolValue>)Parameters[MatchConstantValuesParameterName]; }
38    }
39
40    public IFixedValueParameter<BoolValue> MatchVariableWeightsParameter {
41      get { return (IFixedValueParameter<BoolValue>)Parameters[MatchVariableWeightsParameterName]; }
42    }
43
44    public bool MatchConstantValues {
45      get { return MatchConstantValuesParameter.Value.Value; }
46      set {
47        MatchConstantValuesParameter.Value.Value = value;
48
49      }
50    }
51
52    public bool MatchVariableWeights {
53      get { return MatchVariableWeightsParameter.Value.Value; }
54      set {
55        MatchVariableWeightsParameter.Value.Value = value;
56      }
57    }
58
59    [StorableConstructor]
60    protected SymbolicDataAnalysisBottomUpDiversityAnalyzer(bool deserializing) : base(deserializing) { }
61
62    protected SymbolicDataAnalysisBottomUpDiversityAnalyzer(SymbolicDataAnalysisBottomUpDiversityAnalyzer original, Cloner cloner)
63      : base(original, cloner) {
64    }
65
66    public override IDeepCloneable Clone(Cloner cloner) {
67      return new SymbolicDataAnalysisBottomUpDiversityAnalyzer(this, cloner);
68    }
69
70    public SymbolicDataAnalysisBottomUpDiversityAnalyzer(SymbolicExpressionTreeBottomUpSimilarityCalculator similarityCalculator)
71      : base(new[] { similarityCalculator }) {
72      DiversityResultName = "Genotypic Diversity";
73      UpdateCounterParameter.ActualName = "GenotypicDiversityAnalyzerUpdateCounter";
74
75      Parameters.Add(new FixedValueParameter<BoolValue>(MatchConstantValuesParameterName, new BoolValue(true)));
76      Parameters.Add(new FixedValueParameter<BoolValue>(MatchVariableWeightsParameterName, new BoolValue(true)));
77    }
78
79    public override IOperation Apply() {
80      var bus = (SymbolicExpressionTreeBottomUpSimilarityCalculator)SimilarityCalculatorParameter.Value;
81      bus.MatchConstantValues = MatchConstantValues;
82      bus.MatchVariableWeights = MatchVariableWeights;
83      return base.Apply();
84    }
85  }
86}
Note: See TracBrowser for help on using the repository browser.