Changeset 4942
- Timestamp:
- 11/26/10 00:15:11 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis.PopulationDiversityAnalysis/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/Analyzers/FineGrainedStructuralPopulationDiversityAnalyzer.cs
r4941 r4942 47 47 48 48 private const string FunctionTreeGrammarParameterName = "FunctionTreeGrammar"; 49 private const string MinimumLevelDeltaParameterName = "MinimumLevelDelta"; 50 private const string MaximumLevelDeltaParameterName = "MaximumLevelDelta"; 51 private const string PreventMultipleComparisonContributionParameterName = "PreventMultipleComparisonContribution"; 49 52 50 53 public IValueLookupParameter<GlobalSymbolicExpressionGrammar> FunctionTreeGrammarParameter { … … 55 58 } 56 59 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 } 57 78 58 79 [StorableConstructor] … … 61 82 public FineGrainedStructuralPopulationDiversityAnalyzer() : base() { 62 83 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))); 63 87 } 64 88 … … 68 92 69 93 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; 71 99 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; 75 112 } 76 113 } … … 83 120 IList<GeneticInformationItem>[] geneticInformationItemsLists = new List<GeneticInformationItem>[n]; 84 121 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); 87 123 } 88 124 double[,] result = new double[n, n]; … … 97 133 for (int k = 0; k < solution1GeneticItems.Count; k++) { 98 134 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);103 135 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); 106 138 if (bestPendant != null) { 107 139 similarity += bestPendantSimilarity; 108 // if (PreventMultipleComparisonContribution) 109 if (true) 140 if (PreventMultipleComparisonContribution) 110 141 solution2GeneticItems.Remove(bestPendant); 111 142 } … … 117 148 return result; 118 149 } 119 120 150 121 151 #region private class GeneticInformationItem
Note: See TracChangeset
for help on using the changeset viewer.