Changeset 13281


Ignore:
Timestamp:
11/19/15 11:43:07 (3 years ago)
Author:
gkronber
Message:

#2512: merged r13233, r13243 from trunk to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.GrammaticalEvolution

  • stable/HeuristicLab.Problems.GrammaticalEvolution/3.4/ArtificialAnt/GEArtificialAntProblem.cs

    r12915 r13281  
    2222#endregion
    2323
    24 using System.Diagnostics.Contracts;
    2524using System.Linq;
    2625using HeuristicLab.Common;
     
    3332using HeuristicLab.Problems.GeneticProgramming.ArtificialAnt;
    3433using HeuristicLab.Problems.GrammaticalEvolution.Mappers;
     34using HeuristicLab.Random;
    3535
    3636namespace HeuristicLab.Problems.GrammaticalEvolution {
     
    9898    }
    9999
     100    private readonly object syncRoot = new object();
    100101    public override double Evaluate(Individual individual, IRandom random) {
    101102      var vector = individual.IntegerVector();
     
    106107      var mapper = GenotypeToPhenotypeMapperParameter.Value;
    107108
    108       var tree = mapper.Map(random, bounds, len, grammar, vector);
     109      // Evaluate might be called concurrently therefore access to random has to be synchronized.
     110      // However, results depend on the order of execution. Therefore, results might be different for the same seed when using the parallel engine.
     111      IRandom fastRand;
     112      lock (syncRoot) {
     113        fastRand = new FastRandom(random.Next());
     114      }
     115      var tree = mapper.Map(fastRand, bounds, len, grammar, vector);
    109116
    110117      Interpreter interpreter = new Interpreter(tree, World, MaxTimeSteps);
Note: See TracChangeset for help on using the changeset viewer.