Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/09/15 00:16:03 (9 years ago)
Author:
bburlacu
Message:

#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:
1 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SchemaDiversification/DiversificationStatisticsOperator.cs

    r12966 r12988  
    2020#endregion
    2121
    22 using System.Linq;
     22using HeuristicLab.Analysis;
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2526using HeuristicLab.Operators;
     27using HeuristicLab.Optimization;
     28using HeuristicLab.Parameters;
    2629using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2730
     
    2932  [Item("SchemaCleanupOperator", "Operator which removes the schemas from the global scope after they have been evaluated.")]
    3033  [StorableClass]
    31   public class SchemaCleanupOperator : SingleSuccessorOperator {
    32     public SchemaCleanupOperator() { }
     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";
    3339
    34     protected SchemaCleanupOperator(SchemaCleanupOperator original, Cloner cloner) : base(original, cloner) { }
     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    }
    3552
    36     public override IDeepCloneable Clone(Cloner cloner) { return new SchemaCleanupOperator(this, cloner); }
     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); }
    3763
    3864    [StorableConstructor]
    39     protected SchemaCleanupOperator(bool deserializing) : base(deserializing) { }
     65    protected DiversificationStatisticsOperator(bool deserializing) : base(deserializing) { }
    4066
    4167    public override IOperation Apply() {
    42       foreach (var scope in ExecutionContext.Scope.SubScopes.Where(x => x.Name.Equals("Schema"))) {
    43         foreach (var subscope in scope.SubScopes) { subscope.Variables.Clear(); }
    44         scope.SubScopes.Clear();
    45         scope.Variables.Clear();
     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);
    4676      }
    47       ExecutionContext.Scope.SubScopes.RemoveAll(x => x.Name.Equals("Schema"));
     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
    4893      return base.Apply();
    4994    }
Note: See TracChangeset for help on using the changeset viewer.