Changeset 10029
- Timestamp:
- 10/07/13 21:04:53 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/GEEvaluator.cs
r10022 r10029 40 40 ISingleObjectiveEvaluator, ISymbolicExpressionTreeGrammarBasedOperator { 41 41 42 // TODO: replace these horrible global variables ...43 private static int genotypeIndex = 0;44 private static int currSubtreeCount = 1;45 46 42 #region Parameter Properties 47 43 public ILookupParameter<DoubleValue> QualityParameter { … … 96 92 97 93 /// <summary> 98 /// Genotype-to-Phenotype mapper (depth-first approach). 94 /// Maps an integer vector to a symbolic expression tree, using a 95 /// genotype-to-phenotype mapper. 99 96 /// </summary> 100 97 /// <returns>solution tree</returns> … … 109 106 tree.Root = rootNode; 110 107 111 genotypeIndex = 0;112 currSubtreeCount = 1;108 int genotypeIndex = 0; 109 int currSubtreeCount = 1; 113 110 114 111 MapGenoToPhenoDepthFirstRec(startNode, integerVectorGenome, 115 grammar, integerVectorGenome.Length); 112 grammar, integerVectorGenome.Length, 113 ref genotypeIndex, ref currSubtreeCount); 116 114 117 115 SymbolicExpressionTreeParameter.ActualValue = tree; … … 120 118 121 119 120 /// <summary> 121 /// Genotype-to-Phenotype mapper (recursive depth-first approach). 122 /// Appends maximum allowed children (non-terminal symbols) to 123 /// <paramref name="currentNode"/>, as long as <paramref name="currSubtreeCount"/> 124 /// doesn't exceed <paramref name="maxSubtreeCount"/>. 125 /// If at most <paramref name="maxSubtreeCount"/> subtrees were created, 126 /// each non-full node is filled with randomly chosen nodes 127 /// (non-terminal and terminal), and each non-terminal node is again filled with a terminal node. 128 /// </summary> 129 /// <param name="currentNode">current parent node</param> 130 /// <param name="integerVectorGenome">integer vector used for mapping</param> 131 /// <param name="grammar">grammar definition to determine the allowed child symbols for currentNode </param> 132 /// <param name="maxSubtreeCount">maximum allowed subtrees (= number of used genomes)</param> 133 /// <param name="genotypeIndex">current index in integer vector</param> 134 /// <param name="currSubtreeCount">number of already determined subtrees (filled or still incomplete)</param> 122 135 private void MapGenoToPhenoDepthFirstRec(ISymbolicExpressionTreeNode currentNode, 123 136 IntegerVector integerVectorGenome, 124 137 ISymbolicExpressionGrammar grammar, 125 int maxSubtreeCount) { 138 int maxSubtreeCount, 139 ref int genotypeIndex, 140 ref int currSubtreeCount) { 126 141 if (currSubtreeCount < maxSubtreeCount) { 127 142 … … 138 153 while (newNode.Symbol.MaximumArity > newNode.SubtreeCount) { 139 154 MapGenoToPhenoDepthFirstRec(newNode, integerVectorGenome, 140 grammar, maxSubtreeCount); 155 grammar, maxSubtreeCount, 156 ref genotypeIndex, ref currSubtreeCount); 141 157 } 142 158 } … … 156 172 157 173 /// <summary> 158 /// Randomly returns a terminal node for the given parentNode.174 /// Randomly returns a terminal node for the given <paramref name="parentNode"/>. 159 175 /// (A terminal has got a minimum and maximum arity of 0.) 160 176 /// </summary> … … 174 190 175 191 /// <summary> 176 /// Utility method, which returns the number of elements of the parameter symbolList.192 /// Utility method, which returns the number of elements of <paramref name="symbolList"/>. 177 193 /// </summary> 178 194 /// <param name="symbolList">enumerable symbol list to count the elements for</param> … … 190 206 191 207 /// <summary> 192 /// Returns a randomly chosen child node for the given parentNode.208 /// Returns a randomly chosen child node for the given <paramref name="parentNode"/>. 193 209 /// </summary> 194 210 /// <param name="parentNode">parent node to find a child node randomly for</param> … … 204 220 var symbolList = grammar.GetAllowedChildSymbols(parentNode.Symbol); 205 221 int prodRuleCount = GetNumberOfAllowedChildSymbols(symbolList); 206 int prodRuleIndex = integerVectorGenome[genotypeIndex ] % prodRuleCount;222 int prodRuleIndex = integerVectorGenome[genotypeIndex % integerVectorGenome.Length] % prodRuleCount; 207 223 int currentIndex = 0; 208 224
Note: See TracChangeset
for help on using the changeset viewer.