Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13233 for trunk


Ignore:
Timestamp:
11/17/15 19:03:18 (9 years ago)
Author:
gkronber
Message:

#2512: synchronized access to PRNG in GEArtificialAntProblem

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.GrammaticalEvolution/3.4/ArtificialAnt/GEArtificialAntProblem.cs

    r12915 r13233  
    3333using HeuristicLab.Problems.GeneticProgramming.ArtificialAnt;
    3434using HeuristicLab.Problems.GrammaticalEvolution.Mappers;
     35using HeuristicLab.Random;
    3536
    3637namespace HeuristicLab.Problems.GrammaticalEvolution {
     
    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 (random) {
     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.