Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4942


Ignore:
Timestamp:
11/26/10 00:15:11 (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

    r4941 r4942  
    4747
    4848    private const string FunctionTreeGrammarParameterName = "FunctionTreeGrammar";
     49    private const string MinimumLevelDeltaParameterName = "MinimumLevelDelta";
     50    private const string MaximumLevelDeltaParameterName = "MaximumLevelDelta";
     51    private const string PreventMultipleComparisonContributionParameterName = "PreventMultipleComparisonContribution";
    4952
    5053    public IValueLookupParameter<GlobalSymbolicExpressionGrammar> FunctionTreeGrammarParameter {
     
    5558    }
    5659
     60    public IValueParameter<IntValue> MinimumLevelDeltaParameter {
     61      get { return (IValueParameter<IntValue>)Parameters[MinimumLevelDeltaParameterName]; }
     62    }
     63    public int MinimumLevelDelta {
     64      get { return MinimumLevelDeltaParameter.Value.Value; }
     65    }
     66    public IValueParameter<IntValue> MaximumLevelDeltaParameter {
     67      get { return (IValueParameter<IntValue>)Parameters[MaximumLevelDeltaParameterName]; }
     68    }
     69    public int MaximumLevelDelta {
     70      get { return MaximumLevelDeltaParameter.Value.Value; }
     71    }
     72    public IValueParameter<BoolValue> PreventMultipleComparisonContributionParameter {
     73      get { return (IValueParameter<BoolValue>)Parameters[PreventMultipleComparisonContributionParameterName]; }
     74    }
     75    public bool PreventMultipleComparisonContribution {
     76      get { return PreventMultipleComparisonContributionParameter.Value.Value; }
     77    }
    5778
    5879    [StorableConstructor]
     
    6182    public FineGrainedStructuralPopulationDiversityAnalyzer() : base() {
    6283      Parameters.Add(new ValueLookupParameter<GlobalSymbolicExpressionGrammar>(FunctionTreeGrammarParameterName, "The grammar that is used for symbolic regression models."));
     84      Parameters.Add(new ValueParameter<IntValue>(MinimumLevelDeltaParameterName, "Minimum value for the level delta of the analyzed genetic information items.", new IntValue(0)));
     85      Parameters.Add(new ValueParameter<IntValue>(MaximumLevelDeltaParameterName, "Maximum value for the level delta of the analyzed genetic information items.", new IntValue(int.MaxValue)));
     86      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)));
    6387    }
    6488
     
    6892
    6993    protected override double[,] CalculateSimilarities(SymbolicExpressionTree[] solutions) {
    70       Constant constant = null;
     94      double variableWeightSigma = 0;
     95      double constantMinimumValue = 0;
     96      double constantMaximumValue = 0;
     97      int minimumTimeOffset = 0;
     98      int maximumTimeOffset = 0;
    7199      foreach (Symbol symbol in FunctionTreeGrammar.Symbols) {
    72         if (symbol is Constant) {
    73           if (constant != null) throw new InvalidProgramException("There are more and one constnat definitions in the given function tree grammar.");
    74           constant = (Constant)symbol;
     100        Constant constant = symbol as Constant;
     101        if (constant !=null) {
     102          constantMinimumValue = constant.MinValue;
     103          constantMaximumValue = constant.MaxValue;
     104        }
     105        DataAnalysis.Symbolic.Symbols.Variable variable = symbol as DataAnalysis.Symbolic.Symbols.Variable;
     106        if (variable != null)
     107          variableWeightSigma = variable.WeightSigma;
     108        LaggedVariable laggedVariable = symbol as LaggedVariable;
     109        if (laggedVariable !=null) {
     110          minimumTimeOffset = laggedVariable.MinLag;
     111          maximumTimeOffset = laggedVariable.MaxLag;
    75112        }
    76113      }
     
    83120      IList<GeneticInformationItem>[] geneticInformationItemsLists = new List<GeneticInformationItem>[n];
    84121      for (int i = 0; i < n; i++) {
    85         // geneticInformationItemsList[i] = GeneticInformationItem.getGeneticInformationItems(solutions[i].Root, variableNames, MinimumLEvelDelta, MaximumLevelDelta);
    86         geneticInformationItemsLists[i] = GeneticInformationItem.getGeneticInformationItems(solutions[i].Root, variableNames, 0, int.MaxValue);
     122        geneticInformationItemsLists[i] = GeneticInformationItem.getGeneticInformationItems(solutions[i].Root, variableNames, MinimumLevelDelta, MaximumLevelDelta);
    87123      }
    88124      double[,] result = new double[n, n];
     
    97133            for (int k = 0; k < solution1GeneticItems.Count; k++) {
    98134              double bestPendantSimilarity;
    99               // GeneticInformationItem bestPendant = GeneticInformationItem.FindBestPendant(solution1GeneticItems[k],
    100               //   ConstantMinimum, ConstantMaximum, VariableWeightSigma, MaximumTreeHeight, MaximumTimeOffset,
    101               //   LevelDifferenceCoefficient, AncestorIndexCoefficient, ConstantValueCoefficient, VariableWeightSigma, TimeOffsetCoefficient,
    102               //   VariableWeightCoefficient, AdditiveSimilarityCalculation, out bestPendantSimilarity);
    103135              GeneticInformationItem bestPendant = GeneticInformationItem.FindBestPendant(solution1GeneticItems[k], solution2GeneticItems,
    104                 -10, 10, 1, 100, 10,
    105                 1, 1, 1, 1, 1, 1, true, out bestPendantSimilarity);
     136                constantMinimumValue, constantMaximumValue, variableWeightSigma,
     137                /* TODO: */ 100, 10, 1, 1, 1, 1, 1, 1, true, out bestPendantSimilarity);
    106138              if (bestPendant != null) {
    107139                similarity += bestPendantSimilarity;
    108                 // if (PreventMultipleComparisonContribution)
    109                 if (true)
     140                if (PreventMultipleComparisonContribution)
    110141                  solution2GeneticItems.Remove(bestPendant);
    111142              }
     
    117148      return result;
    118149    }
    119 
    120150
    121151    #region private class GeneticInformationItem
Note: See TracChangeset for help on using the changeset viewer.