Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/25/15 17:53:25 (9 years ago)
Author:
bburlacu
Message:

#2326: Adapted code in the diversity analyzers according to the new base class. Improved wiring of similarity calculators and analyzers.

Location:
branches/SymbolicExpressionTreeDiversityAnalyzers/HeuristicLab.Problems.DataAnalysis.Symbolic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/SymbolicExpressionTreeDiversityAnalyzers/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/SymbolicExpressionTreeDiversityAnalyzers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisBottomUpDiversityAnalyzer.cs

    r12064 r12075  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HeuristicLab.Analysis;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     26using HeuristicLab.Optimization;
    2527using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2628
     
    2830  [Item("SymbolicDataAnalysisBottomUpDiversityAnalyzer", "A diversity analyzer based on the bottom-up distance between trees.")]
    2931  [StorableClass]
    30   public class SymbolicDataAnalysisBottomUpDiversityAnalyzer : SingleObjectivePopulationDiversityAnalyzer {
     32  public class SymbolicDataAnalysisBottomUpDiversityAnalyzer : PopulationSimilarityAnalyzer {
    3133    [StorableConstructor]
    3234    protected SymbolicDataAnalysisBottomUpDiversityAnalyzer(bool deserializing) : base(deserializing) { }
     
    4042    }
    4143
    42     public SymbolicDataAnalysisBottomUpDiversityAnalyzer() {
    43       SimilarityCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator { SolutionVariableName = "SymbolicExpressionTree" };
     44    public SymbolicDataAnalysisBottomUpDiversityAnalyzer(
     45      IEnumerable<ISingleObjectiveSolutionSimilarityCalculator> validSimilarityCalculators)
     46      : base(validSimilarityCalculators) {
     47      UpdateCounterParameter.ActualName = "GenotypicDiversityAnalyzerUpdateCounter";
    4448    }
    4549  }
  • branches/SymbolicExpressionTreeDiversityAnalyzers/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r12068 r12075  
    118118      set { ProblemDataParameter.Value = value; }
    119119    }
     120
    120121    public ISymbolicDataAnalysisGrammar SymbolicExpressionTreeGrammar {
    121122      get { return SymbolicExpressionTreeGrammarParameter.Value; }
     
    126127      set { SymbolicExpressionTreeInterpreterParameter.Value = value; }
    127128    }
     129
    128130    public IntValue MaximumSymbolicExpressionTreeDepth {
    129131      get { return MaximumSymbolicExpressionTreeDepthParameter.Value; }
     
    141143      get { return RelativeNumberOfEvaluatedSamplesParameter.Value; }
    142144    }
     145
    143146    public IntRange FitnessCalculationPartition {
    144147      get { return FitnessCalculationPartitionParameter.Value; }
     
    228231      Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
    229232      Operators.Add(new SymbolicExpressionTreeLengthAnalyzer());
    230       Operators.Add(new SymbolicDataAnalysisBottomUpDiversityAnalyzer());
    231233      Operators.Add(new SymbolicExpressionTreeBottomUpSimilarityCalculator());
     234      Operators.Add(new SymbolicDataAnalysisBottomUpDiversityAnalyzer(Operators.OfType<SymbolicExpressionTreeBottomUpSimilarityCalculator>()) { DiversityResultName = "Genotypic Diversity" });
    232235      ParameterizeOperators();
    233236    }
     
    349352        op.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
    350353      }
    351       foreach (var op in operators.OfType<SymbolicExpressionTreeBottomUpSimilarityCalculator>()) {
    352         op.SolutionVariableName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    353       }
    354       foreach (var op in operators.OfType<SymbolicDataAnalysisBottomUpDiversityAnalyzer>()) {
    355         var sim = Operators.OfType<SymbolicExpressionTreeBottomUpSimilarityCalculator>().FirstOrDefault();
    356         if (sim != null)
    357           op.SimilarityCalculator = sim;
    358       }
    359354    }
    360355
Note: See TracChangeset for help on using the changeset viewer.