Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/06/14 20:41:57 (10 years ago)
Author:
sawinkle
Message:

#2109:

  • Implemented PIGEMapper. Due to that, it was necessary to modify the Map method interface to additionally take the bounds and length of the genotype.
  • Corrected and simplified the different mappers. Simplified the SampleArity method of /Mappers/GenotypeToPhenotypeMapper.cs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/GenotypeToPhenotypeMapper.cs

    r10280 r10290  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
     26using HeuristicLab.Data;
    2627using HeuristicLab.Encodings.IntegerVectorEncoding;
    2728using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    4041    protected GenotypeToPhenotypeMapper() : base() { }
    4142
    42     public abstract SymbolicExpressionTree Map(IRandom random,
     43    public abstract SymbolicExpressionTree Map(IRandom random, IntMatrix bounds, int length,
    4344                                               ISymbolicExpressionGrammar grammar,
    4445                                               IntegerVector genotype);
     
    9697      if (prodRuleCount < 1) return null;
    9798
    98       int prodRuleIndex = genotype[genotypeIndex % genotype.Length] % prodRuleCount;
     99      // genotypeIndex % genotype.Length
     100      int prodRuleIndex = genotype[genotypeIndex] % prodRuleCount;
    99101
    100102      var newNode = symbolList.ElementAt(prodRuleIndex).CreateTreeNode();
     
    109111    /// <param name="random">random number generator</param>
    110112    /// <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>
    112113    /// <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>
    115115    protected int SampleArity(IRandom random,
    116116                              ISymbolicExpressionTreeNode node,
    117                               int maxAllowedArity,
    118117                              ISymbolicExpressionGrammar grammar) {
    119118
    120119      int minArity = grammar.GetMinimumSubtreeCount(node.Symbol);
    121120      int maxArity = grammar.GetMaximumSubtreeCount(node.Symbol);
    122 
    123       if (maxAllowedArity < maxArity) {
    124         maxArity = maxAllowedArity;
    125       }
    126 
    127       if (maxAllowedArity < minArity) {
    128         return -1;
    129       }
    130121
    131122      if (minArity == maxArity) {
Note: See TracChangeset for help on using the changeset viewer.