Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/DiversificationStatisticsOperator.cs @ 12988

Last change on this file since 12988 was 12988, checked in by bburlacu, 9 years ago

#1772: Performance improvement changes

  • QueryMatch.cs: eliminate unnecessary ToList() call and expensive GetBranchLevel calls
  • Diversification: eliminated creation of shallow copies of the individual subscopes as it was either too slow (due to events being registered/deregistered when variables are added to the scope) or too leaky (if attempting to clear the scopes without clearing the variables then the code is leaking EventHandlers)
  • Aggregated diversification statistics separately with the help of some parameters set up in the SchemaCreator and SchemaEvaluator
  • Made code in the UpdateEstimatedValuesOperator perform exactly as in the evaluator (updating quality and estimated values)
  • Removed no longer needed SchemaCleanupOperator
  • Do not evaluate intermediate vertices in the genealogy analyzer if the TrimOlderGenerations flag is activated

New functionality:

  • parameter to control the fraction of the population to be considered by the diversification strategy
  • parameter to control whether individuals may be matched by any schema and mutated only once (exclusive matching)
  • parameter to control whether linear scaling should be applied to the estimated values used for the calculation of phenotypic similarity (default: yes)
File size: 4.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Operators;
27using HeuristicLab.Optimization;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30
31namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
32  [Item("SchemaCleanupOperator", "Operator which removes the schemas from the global scope after they have been evaluated.")]
33  [StorableClass]
34  public class DiversificationStatisticsOperator : SingleSuccessorOperator {
35    private const string NumberOfChangedTreesParameterName = "NumberOfChangedTrees";
36    private const string NumberOfSchemasParameterName = "NumberOfSchemas";
37    private const string AverageSchemaLengthParameterName = "AverageSchemaLength";
38    private const string ResultCollectionParameterName = "Results";
39
40    public ILookupParameter<IntValue> NumberOfChangedTreesParameter {
41      get { return (ILookupParameter<IntValue>)Parameters[NumberOfChangedTreesParameterName]; }
42    }
43    public ILookupParameter<IntValue> NumberOfSchemasParameter {
44      get { return (ILookupParameter<IntValue>)Parameters[NumberOfSchemasParameterName]; }
45    }
46    public ILookupParameter<DoubleValue> AverageSchemaLengthParameter {
47      get { return (ILookupParameter<DoubleValue>)Parameters[AverageSchemaLengthParameterName]; }
48    }
49    public ILookupParameter<ResultCollection> ResultCollectionParameter {
50      get { return (ILookupParameter<ResultCollection>)Parameters[ResultCollectionParameterName]; }
51    }
52
53    public DiversificationStatisticsOperator() {
54      Parameters.Add(new LookupParameter<IntValue>(NumberOfChangedTreesParameterName));
55      Parameters.Add(new LookupParameter<IntValue>(NumberOfSchemasParameterName));
56      Parameters.Add(new LookupParameter<DoubleValue>(AverageSchemaLengthParameterName));
57      Parameters.Add(new LookupParameter<ResultCollection>(ResultCollectionParameterName));
58    }
59
60    protected DiversificationStatisticsOperator(DiversificationStatisticsOperator original, Cloner cloner) : base(original, cloner) { }
61
62    public override IDeepCloneable Clone(Cloner cloner) { return new DiversificationStatisticsOperator(this, cloner); }
63
64    [StorableConstructor]
65    protected DiversificationStatisticsOperator(bool deserializing) : base(deserializing) { }
66
67    public override IOperation Apply() {
68
69      var results = ResultCollectionParameter.ActualValue;
70      DataTable table;
71      if (!results.ContainsKey("NumberOfChangedTrees")) {
72        table = new DataTable();
73        results.Add(new Result("NumberOfChangedTrees", table));
74        var row = new DataRow("Changed trees");
75        table.Rows.Add(row);
76      }
77      if (!results.ContainsKey("AverageSchemaLength")) {
78        table = new DataTable();
79        results.Add(new Result("AverageSchemaLength", table));
80        var row = new DataRow("Average schema length");
81        table.Rows.Add(row);
82      }
83      if (!results.ContainsKey("NumberOfSchemas")) {
84        table = new DataTable();
85        results.Add(new Result("NumberOfSchemas", table));
86        var row = new DataRow("Number of schemas");
87        table.Rows.Add(row);
88      }
89      ((DataTable)results["NumberOfChangedTrees"].Value).Rows["Changed trees"].Values.Add(NumberOfChangedTreesParameter.ActualValue.Value);
90      ((DataTable)results["AverageSchemaLength"].Value).Rows["Average schema length"].Values.Add(AverageSchemaLengthParameter.ActualValue.Value);
91      ((DataTable)results["NumberOfSchemas"].Value).Rows["Number of schemas"].Values.Add(NumberOfSchemasParameter.ActualValue.Value);
92
93      return base.Apply();
94    }
95  }
96}
Note: See TracBrowser for help on using the repository browser.