Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/05/14 12:53:58 (11 years ago)
Author:
sawinkle
Message:

#2109: Fetched random number generator in Evaluator implementations from scope, so that the same results are produced using the same seed.

Location:
branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers
Files:
6 edited

Legend:

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

    r10277 r10280  
    2727using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    29 using HeuristicLab.Random;
    3029
    3130namespace HeuristicLab.Problems.GrammaticalEvolution {
     
    5150    /// Breath-first approach.
    5251    /// </summary>
     52    /// <param name="random">random number generator</param>
    5353    /// <param name="grammar">grammar definition</param>
    5454    /// <param name="genotype">integer vector, which should be mapped to a tree</param>
    5555    /// <returns>phenotype (a symbolic expression tree)</returns>
    56     public override SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar,
     56    public override SymbolicExpressionTree Map(IRandom random,
     57                                               ISymbolicExpressionGrammar grammar,
    5758                                               IntegerVector genotype) {
    5859
     
    6465
    6566      MapBreathFirstIteratively(startNode, genotype, grammar,
    66                                 genotype.Length, new MersenneTwister());
     67                                genotype.Length, random);
    6768
    6869      return tree;
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/DepthFirstMapper.cs

    r10277 r10280  
    2727using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    29 using HeuristicLab.Random;
    3029
    3130namespace HeuristicLab.Problems.GrammaticalEvolution {
     
    5150    /// Depth-first approach.
    5251    /// </summary>
     52    /// <param name="random">random number generator</param>
    5353    /// <param name="grammar">grammar definition</param>
    5454    /// <param name="genotype">integer vector, which should be mapped to a tree</param>
    5555    /// <returns>phenotype (a symbolic expression tree)</returns>
    56     public override SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar,
     56    public override SymbolicExpressionTree Map(IRandom random,
     57                                               ISymbolicExpressionGrammar grammar,
    5758                                               IntegerVector genotype) {
    5859
    5960      SymbolicExpressionTree tree = new SymbolicExpressionTree();
    6061      var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode();
    61       if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(new MersenneTwister());
     62      if (rootNode.HasLocalParameters) rootNode.ResetLocalParameters(random);
    6263      var startNode = (SymbolicExpressionTreeTopLevelNode)grammar.StartSymbol.CreateTreeNode();
    63       if (startNode.HasLocalParameters) startNode.ResetLocalParameters(new MersenneTwister());
     64      if (startNode.HasLocalParameters) startNode.ResetLocalParameters(random);
    6465      rootNode.AddSubtree(startNode);
    6566      tree.Root = rootNode;
    6667
    6768      MapDepthFirstIteratively(startNode, genotype, grammar,
    68                                genotype.Length, new MersenneTwister());
     69                               genotype.Length, random);
    6970      return tree;
    7071    }
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/GenotypeToPhenotypeMapper.cs

    r10277 r10280  
    4040    protected GenotypeToPhenotypeMapper() : base() { }
    4141
    42     public abstract SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar,
     42    public abstract SymbolicExpressionTree Map(IRandom random,
     43                                               ISymbolicExpressionGrammar grammar,
    4344                                               IntegerVector genotype);
    4445
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/IGenotypeToPhenotypeMapper.cs

    r10068 r10280  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Encodings.IntegerVectorEncoding;
    2324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    2829  /// </summary>
    2930  public interface IGenotypeToPhenotypeMapper : IIntegerVectorOperator {
    30     SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar,
     31    SymbolicExpressionTree Map(IRandom random,
     32                               ISymbolicExpressionGrammar grammar,
    3133                               IntegerVector genotype);
    3234  }
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/PIGEMapper.cs

    r10068 r10280  
    4848    /// PIGE approach.
    4949    /// </summary>
     50    /// <param name="random">random number generator</param>
    5051    /// <param name="grammar">grammar definition</param>
    5152    /// <param name="genotype">integer vector, which should be mapped to a tree</param>
    5253    /// <returns>phenotype (a symbolic expression tree)</returns>
    53     public override SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar,
     54    public override SymbolicExpressionTree Map(IRandom random,
     55                                               ISymbolicExpressionGrammar grammar,
    5456                                               IntegerVector genotype) {
    5557
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/RandomMapper.cs

    r10068 r10280  
    4848    /// Random approach.
    4949    /// </summary>
     50    /// <param name="random">random number generator</param>
    5051    /// <param name="grammar">grammar definition</param>
    5152    /// <param name="genotype">integer vector, which should be mapped to a tree</param>
    5253    /// <returns>phenotype (a symbolic expression tree)</returns>
    53     public override SymbolicExpressionTree Map(ISymbolicExpressionGrammar grammar,
     54    public override SymbolicExpressionTree Map(IRandom random,
     55                                               ISymbolicExpressionGrammar grammar,
    5456                                               IntegerVector genotype) {
    5557
Note: See TracChangeset for help on using the changeset viewer.