Changeset 10290 for branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/GenotypeToPhenotypeMapper.cs
- Timestamp:
- 01/06/14 20:41:57 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/GenotypeToPhenotypeMapper.cs
r10280 r10290 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 26 27 using HeuristicLab.Encodings.IntegerVectorEncoding; 27 28 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 40 41 protected GenotypeToPhenotypeMapper() : base() { } 41 42 42 public abstract SymbolicExpressionTree Map(IRandom random, 43 public abstract SymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length, 43 44 ISymbolicExpressionGrammar grammar, 44 45 IntegerVector genotype); … … 96 97 if (prodRuleCount < 1) return null; 97 98 98 int prodRuleIndex = genotype[genotypeIndex % genotype.Length] % prodRuleCount; 99 // genotypeIndex % genotype.Length 100 int prodRuleIndex = genotype[genotypeIndex] % prodRuleCount; 99 101 100 102 var newNode = symbolList.ElementAt(prodRuleIndex).CreateTreeNode(); … … 109 111 /// <param name="random">random number generator</param> 110 112 /// <param name="node">node, for which a random arity is determined</param> 111 /// <param name="maxAllowedArity">the resulting arity must not exceed this maximum arity</param>112 113 /// <param name="grammar">symbolic expression grammar to use</param> 113 /// <returns>random arity in the interval [minArity, maxArity] of the node or 114 /// -1, if minArity exceeds maxAllowedArity</returns> 114 /// <returns>random arity in the interval [minArity, maxArity]</returns> 115 115 protected int SampleArity(IRandom random, 116 116 ISymbolicExpressionTreeNode node, 117 int maxAllowedArity,118 117 ISymbolicExpressionGrammar grammar) { 119 118 120 119 int minArity = grammar.GetMinimumSubtreeCount(node.Symbol); 121 120 int maxArity = grammar.GetMaximumSubtreeCount(node.Symbol); 122 123 if (maxAllowedArity < maxArity) {124 maxArity = maxAllowedArity;125 }126 127 if (maxAllowedArity < minArity) {128 return -1;129 }130 121 131 122 if (minArity == maxArity) {
Note: See TracChangeset
for help on using the changeset viewer.