Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/11/14 12:07:15 (11 years ago)
Author:
gkronber
Message:

#2109: minor code cleanup

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

Legend:

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

    r10968 r10974  
    3434namespace HeuristicLab.Problems.GrammaticalEvolution {
    3535  /// <summary>
    36   /// GenotypeToPhenotypeMapper
     36  /// Abstract base class for GenotypeToPhenotypeMappers
    3737  /// </summary>
    3838  public abstract class GenotypeToPhenotypeMapper : IntegerVectorOperator, IGenotypeToPhenotypeMapper {
     
    6666
    6767      // no terminal node exists for the given parent node
    68       if (possibleSymbolsList.Count() < 1) return null;
     68      if (!possibleSymbolsList.Any()) return null;
    6969
    7070      var newNode = possibleSymbolsList.SelectRandom(random).CreateTreeNode();
  • branches/GrammaticalEvolution/HeuristicLab.Problems.GrammaticalEvolution/Mappers/PIGEMapper.cs

    r10968 r10974  
    7171  public class PIGEMapper : GenotypeToPhenotypeMapper {
    7272
     73    private object nontVectorLocker = new object();
    7374    private IntegerVector nontVector;
    7475
     
    7879    }
    7980
    80     private IntegerVector GetNontVector(IRandom random, IntMatrix bounds, int length) {
     81    private static IntegerVector GetNontVector(IRandom random, IntMatrix bounds, int length) {
    8182      IntegerVector v = new IntegerVector(length);
    8283      v.Randomize(random, bounds);
     
    114115      tree.Root = rootNode;
    115116
    116       if (NontVector == null) {
    117         NontVector = GetNontVector(random, bounds, length);
     117      // Map can be called simultaniously on multiple threads
     118      lock (nontVectorLocker) {
     119        if (NontVector == null) {
     120          NontVector = GetNontVector(random, bounds, length);
     121        }
    118122      }
    119123
Note: See TracChangeset for help on using the changeset viewer.