Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/12/15 20:40:11 (9 years ago)
Author:
gkronber
Message:

#2283: added shuffling of terminal symbols to the royal pair problem to make sure that there is no bias from order of terminal symbols.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalPairProblem.cs

    r12290 r12391  
    55using System.Text;
    66using System.Text.RegularExpressions;
     7using HeuristicLab.Common;
    78using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     9using HeuristicLab.Random;
    810
    911namespace HeuristicLab.Problems.GrammaticalOptimization {
     
    1315    private readonly IGrammar grammar;
    1416    private readonly int numTerminals;
    15     public string Name { get { return "RoyalPair"; } }
     17    public string Name { get { return string.Format("RoyalPair({0})", numTerminals); } }
    1618
    1719    public RoyalPairProblem(int numTerminals = 2) {
     
    1921
    2022      var sentenceSymbol = 'S';
    21       var terminalSymbols = Enumerable.Range(0, numTerminals).Select(off => (char)((byte)'a' + off)).ToArray();
     23      var terminalSymbols = Enumerable.Range(0, numTerminals).Select(off => (char)((byte)'a' + off)).ToList();
     24      terminalSymbols.ShuffleInPlace(new MersenneTwister(31415));
     25
    2226      var nonTerminalSymbols = new char[] { sentenceSymbol };
    2327
Note: See TracChangeset for help on using the changeset viewer.