Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4948


Ignore:
Timestamp:
11/26/10 21:06:04 (14 years ago)
Author:
swinkler
Message:

Worked on structural population diversity analysis (#1278): Added parameters for similarity calculations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis.PopulationDiversityAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/FineGrainedStructuralPopulationDiversityAnalyzer.cs

    r4942 r4948  
    4646    // properties: min level delts, max level delta, etc.
    4747
     48    #region Properties and Parameters
     49
    4850    private const string FunctionTreeGrammarParameterName = "FunctionTreeGrammar";
    4951    private const string MinimumLevelDeltaParameterName = "MinimumLevelDelta";
    5052    private const string MaximumLevelDeltaParameterName = "MaximumLevelDelta";
    5153    private const string PreventMultipleComparisonContributionParameterName = "PreventMultipleComparisonContribution";
     54    private const string MaximumExpressionDepthParameterName = "MaxExpressionDepth";
     55    private const string LevelDifferenceCoefficientParameterName = "LevelDifferenceCoefficient";
     56    private const string AncestorIndexCoefficientParameterName = "AncestorIndexCoefficient";
     57    private const string ConstantValueCoefficientParameterName = "ConstantValueCoefficient";
     58    private const string VariableWeightCoefficientParameterName = "VariableWeightCoefficient";
     59    private const string TimeOffsetCoefficientParameterName = "TimeOffsetCoefficient";
     60    private const string VariableIndexCoefficientParameterName = "VariableIndexCoefficient";
     61    private const string AdditiveSimilarityCalculationParameterName = "AdditiveSimilarityCalculation";
    5262
    5363    public IValueLookupParameter<GlobalSymbolicExpressionGrammar> FunctionTreeGrammarParameter {
     
    5767      get { return FunctionTreeGrammarParameter.ActualValue; }
    5868    }
     69    public IValueLookupParameter<IntValue> MaximumExpressionDepthParameter {
     70      get { return (IValueLookupParameter<IntValue>)Parameters[MaximumExpressionDepthParameterName]; }
     71    }
     72    public int MaximumExpressionDepth {
     73      get { return MaximumExpressionDepthParameter.ActualValue.Value; }
     74    }
    5975
    6076    public IValueParameter<IntValue> MinimumLevelDeltaParameter {
     
    7692      get { return PreventMultipleComparisonContributionParameter.Value.Value; }
    7793    }
     94
     95    public IValueParameter<DoubleValue> LevelDifferenceCoefficientParameter {
     96      get { return (IValueParameter<DoubleValue>)Parameters[LevelDifferenceCoefficientParameterName]; }
     97    }
     98    public double LevelDifferenceCoefficient {
     99      get { return LevelDifferenceCoefficientParameter.Value.Value; }
     100    }
     101    public IValueParameter<DoubleValue> AncestorIndexCoefficientParameter {
     102      get { return (IValueParameter<DoubleValue>)Parameters[AncestorIndexCoefficientParameterName]; }
     103    }
     104    public double AncestorIndexCoefficient {
     105      get { return AncestorIndexCoefficientParameter.Value.Value; }
     106    }
     107    public IValueParameter<DoubleValue> ConstantValueCoefficientParameter {
     108      get { return (IValueParameter<DoubleValue>)Parameters[ConstantValueCoefficientParameterName]; }
     109    }
     110    public double ConstantValueCoefficient {
     111      get { return ConstantValueCoefficientParameter.Value.Value; }
     112    }
     113    public IValueParameter<DoubleValue> VariableWeightCoefficientParameter {
     114      get { return (IValueParameter<DoubleValue>)Parameters[VariableWeightCoefficientParameterName]; }
     115    }
     116    public double VariableWeightCoefficient {
     117      get { return VariableWeightCoefficientParameter.Value.Value; }
     118    }
     119    public IValueParameter<DoubleValue> TimeOffsetCoefficientParameter {
     120      get { return (IValueParameter<DoubleValue>)Parameters[TimeOffsetCoefficientParameterName]; }
     121    }
     122    public double TimeOffsetCoefficientCoefficient {
     123      get { return TimeOffsetCoefficientParameter.Value.Value; }
     124    }
     125    public IValueParameter<DoubleValue> VariableIndexCoefficientParameter {
     126      get { return (IValueParameter<DoubleValue>)Parameters[VariableIndexCoefficientParameterName]; }
     127    }
     128    public double VariableIndexCoefficient {
     129      get { return VariableIndexCoefficientParameter.Value.Value; }
     130    }
     131    public IValueParameter<BoolValue> AdditiveSimilarityCalculationParameter {
     132      get { return (IValueParameter<BoolValue>)Parameters[AdditiveSimilarityCalculationParameterName]; }
     133    }
     134    public bool AdditiveSimilarityCalculation {
     135      get { return AdditiveSimilarityCalculationParameter.Value.Value; }
     136    }
     137
     138    #endregion
    78139
    79140    [StorableConstructor]
     
    82143    public FineGrainedStructuralPopulationDiversityAnalyzer() : base() {
    83144      Parameters.Add(new ValueLookupParameter<GlobalSymbolicExpressionGrammar>(FunctionTreeGrammarParameterName, "The grammar that is used for symbolic regression models."));
     145      Parameters.Add(new ValueLookupParameter<IntValue>(MaximumExpressionDepthParameterName, "Maximal depth of the analyzed symbolic expressions."));
    84146      Parameters.Add(new ValueParameter<IntValue>(MinimumLevelDeltaParameterName, "Minimum value for the level delta of the analyzed genetic information items.", new IntValue(0)));
    85147      Parameters.Add(new ValueParameter<IntValue>(MaximumLevelDeltaParameterName, "Maximum value for the level delta of the analyzed genetic information items.", new IntValue(int.MaxValue)));
    86148      Parameters.Add(new ValueParameter<BoolValue>(PreventMultipleComparisonContributionParameterName, "Flag that denotes whether genetic information items are hindered from contributing to the similarity function multiple times.", new BoolValue(false)));
     149      Parameters.Add(new ValueParameter<DoubleValue>(LevelDifferenceCoefficientParameterName, "Weighting coefficient for level differences.", new DoubleValue(0.2)));
     150      Parameters.Add(new ValueParameter<DoubleValue>(AncestorIndexCoefficientParameterName, "Weighting coefficient for ancestor index differences.", new DoubleValue(0.2)));
     151      Parameters.Add(new ValueParameter<DoubleValue>(ConstantValueCoefficientParameterName, "Weighting coefficient for constant value differences.", new DoubleValue(0.2)));
     152      Parameters.Add(new ValueParameter<DoubleValue>(VariableWeightCoefficientParameterName, "Weighting coefficient for variable weight differences.", new DoubleValue(0.2)));
     153      Parameters.Add(new ValueParameter<DoubleValue>(TimeOffsetCoefficientParameterName, "Weighting coefficient for time lag differences.", new DoubleValue(0.2)));
     154      Parameters.Add(new ValueParameter<DoubleValue>(VariableIndexCoefficientParameterName, "Weighting coefficient for variable index differences.", new DoubleValue(0.2)));
     155      Parameters.Add(new ValueParameter<BoolValue>(AdditiveSimilarityCalculationParameterName, "Flag that denotes whether the similarity of genetic information items shall be calculated using additive calculation.", new BoolValue(true)));
    87156    }
    88157
     
    135204              GeneticInformationItem bestPendant = GeneticInformationItem.FindBestPendant(solution1GeneticItems[k], solution2GeneticItems,
    136205                constantMinimumValue, constantMaximumValue, variableWeightSigma,
    137                 /* TODO: */ 100, 10, 1, 1, 1, 1, 1, 1, true, out bestPendantSimilarity);
     206                MaximumExpressionDepth, minimumTimeOffset, maximumTimeOffset,
     207                LevelDifferenceCoefficient, AncestorIndexCoefficient, ConstantValueCoefficient, VariableWeightCoefficient,
     208                TimeOffsetCoefficientCoefficient, VariableIndexCoefficient, AdditiveSimilarityCalculation,
     209                out bestPendantSimilarity);
    138210              if (bestPendant != null) {
    139211                similarity += bestPendantSimilarity;
     
    210282      public static GeneticInformationItem FindBestPendant(GeneticInformationItem Item, IList<GeneticInformationItem> ComparisonItems,
    211283          double ConstantMinimum, double ConstantMaximum, double VariableWeightSigma,
    212           int MaximumTreeHeight, int MaximumTimeOffset,
     284          int MaximumTreeHeight, int MinimumTimeOffset, int MaximumTimeOffset,
    213285          double LevelDifferenceCoefficient, double AncestorIndexCoefficient,
    214286          double ConstantValueCoefficient, double VariableWeightCoefficient, double TimeOffsetCoefficient, double VariableIndexCoefficient,
     
    218290        double similarity, maxSimilarity = -double.MaxValue;
    219291        for (int i = 0; i < ComparisonItems.Count; i++) {
    220           similarity = Similarity(Item, ComparisonItems[i], ConstantMinimum, ConstantMaximum, VariableWeightSigma, MaximumTreeHeight, MaximumTimeOffset,
     292          similarity = Similarity(Item, ComparisonItems[i], ConstantMinimum, ConstantMaximum, VariableWeightSigma, MaximumTreeHeight, MinimumTimeOffset, MaximumTimeOffset,
    221293            LevelDifferenceCoefficient, AncestorIndexCoefficient, ConstantValueCoefficient, VariableWeightSigma, TimeOffsetCoefficient,
    222294            VariableWeightCoefficient, AdditiveSimilarityCalculation);
     
    235307      public static double Similarity(GeneticInformationItem Item1, GeneticInformationItem Item2,
    236308          double ConstantMinimum, double ConstantMaximum, double VariableWeightSigma,
    237           int MaximumTreeHeight, int MaximumTimeOffset,
     309          int MaximumTreeHeight, int MinimumTimeOffset, int MaximumTimeOffset,
    238310          double LevelDifferenceCoefficient, double AncestorIndexCoefficient,
    239311          double ConstantValueCoefficient, double VariableWeightCoefficient, double TimeOffsetCoefficient, double VariableIndexCoefficient,
     
    307379            double timeOffsetDifference = Math.Abs(Item1.DescendantTimeOffset - Item2.DescendantTimeOffset);
    308380            if (MaximumTimeOffset > 0)
    309               descendantTimeOffsetDifferencePunishment = timeOffsetDifference / MaximumTimeOffset;
     381              descendantTimeOffsetDifferencePunishment = timeOffsetDifference / (MaximumTimeOffset - MinimumTimeOffset);
    310382            descendantTimeOffsetDifferencePunishment *= TimeOffsetCoefficient;
    311383            punishmentContributionSum += TimeOffsetCoefficient;
Note: See TracChangeset for help on using the changeset viewer.