Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/16/14 16:32:48 (10 years ago)
Author:
bburlacu
Message:

#1772: Separated tree distance calculations in different classes which implement a new interface called IDistanceCalculator. The isomorphic tree distance calculates the distance based on the maximum common subtree between two symbolic expression trees, and the bottom-up tree distance returns a value based on the number of matching pairs of nodes in a bottom-up mapping. Introduced the distance calculator as a parameter in the SimilarityCalculator operator so that the diversity analyzer can use either of the two distances.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisPopulationDiversityAnalyzer.cs

    r10464 r11197  
    4949    private const string StoreHistoryParameterName = "StoreHistory";
    5050    // comparer parameters
    51     private const string MatchVariablesParameterName = "MatchVariableNames";
    52     private const string MatchVariableWeightsParameterName = "MatchVariableWeights";
    53     private const string MatchConstantValuesParameterName = "MatchConstantValues";
    5451    private const string SimilarityValuesParmeterName = "Similarity";
     52
     53    private const string DistanceCalculatorParameterName = "DistanceCalculator";
    5554
    5655    #endregion
     
    7877      get { return (IScopeTreeLookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    7978    }
    80     public ValueParameter<BoolValue> MatchVariableNamesParameter {
    81       get { return (ValueParameter<BoolValue>)Parameters[MatchVariablesParameterName]; }
    82     }
    83     public ValueParameter<BoolValue> MatchVariableWeightsParameter {
    84       get { return (ValueParameter<BoolValue>)Parameters[MatchVariableWeightsParameterName]; }
    85     }
    86     public ValueParameter<BoolValue> MatchConstantValuesParameter {
    87       get { return (ValueParameter<BoolValue>)Parameters[MatchConstantValuesParameterName]; }
    88     }
    8979    public ILookupParameter<DoubleValue> SimilarityParameter {
    9080      get { return (ILookupParameter<DoubleValue>)Parameters[SimilarityValuesParmeterName]; }
     81    }
     82    public IValueParameter<IDistanceCalculator> DistanceCalculatorParameter {
     83      get { return (IValueParameter<IDistanceCalculator>)Parameters[DistanceCalculatorParameterName]; }
    9184    }
    9285    #endregion
     
    122115      Parameters.Add(new ValueLookupParameter<ResultCollection>(ResultsParameterName, "The results collection where the analysis values should be stored."));
    123116      Parameters.Add(new LookupParameter<IntValue>(GenerationsParameterName, "The number of generations so far."));
    124       Parameters.Add(new ValueParameter<BoolValue>(MatchVariablesParameterName, "Specify if the symbolic expression tree comparer should match variable names.", new BoolValue(true)));
    125       Parameters.Add(new ValueParameter<BoolValue>(MatchVariableWeightsParameterName, "Specify if the symbolic expression tree comparer should match variable weights.", new BoolValue(true)));
    126       Parameters.Add(new ValueParameter<BoolValue>(MatchConstantValuesParameterName, "Specify if the symbolic expression tree comparer should match constant values.", new BoolValue(true)));
    127117      Parameters.Add(new ValueParameter<BoolValue>(StoreHistoryParameterName, "True if the tree lengths history of the population should be stored.", new BoolValue(false)));
    128118      Parameters.Add(new LookupParameter<DoubleValue>(SimilarityValuesParmeterName, ""));
    129119      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumSymbolicExpressionTreeDepthParameterName, "The maximal depth of the symbolic expression tree (a tree with one node has depth = 0)."));
     120      Parameters.Add(new ValueParameter<IDistanceCalculator>(DistanceCalculatorParameterName, "The distance calculator between trees.", new BottomUpDistanceCalculator()));
    130121      UpdateCounterParameter.Hidden = true;
    131122      UpdateIntervalParameter.Hidden = true;
     
    159150        SimilarityParameter.ActualValue = new DoubleValue();
    160151
    161         var comparer = new SymbolicExpressionTreeNodeSimilarityComparer {
    162           MatchConstantValues = MatchConstantValuesParameter.Value.Value,
    163           MatchVariableNames = MatchVariableNamesParameter.Value.Value,
    164           MatchVariableWeights = MatchVariableWeightsParameter.Value.Value
    165         };
    166 
    167152        var operations = new OperationCollection { Parallel = true };
    168153        foreach (var tree in trees) {
    169           var op = new SymbolicDataAnalysisExpressionTreeSimilarityCalculator {
     154          var op = new SymbolicDataAnalysisExpressionTreeSimilarityCalculator(DistanceCalculatorParameter.Value) {
    170155            CurrentSymbolicExpressionTree = tree,
    171             SimilarityComparer = comparer,
    172156            MaximumTreeDepth = MaximumSymbolicExpressionTreeDepth.Value
    173157          };
Note: See TracChangeset for help on using the changeset viewer.