Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/12/16 13:53:16 (8 years ago)
Author:
sraggl
Message:

#2666
Updated LinearLinkageEncoding by:

  • Speeding up GroupCrossover and SetGroups and GetGroups
  • making Constructor private adding static initializer Methods
Location:
trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/Creators
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/Creators/ExactGroupsLinearLinkageCreator.cs

    r14185 r14475  
    5656
    5757    public static LinearLinkage Apply(IRandom random, int length, int groups) {
    58       var solution = new LinearLinkage(length);
    5958      var groupNumbers = Enumerable.Range(0, length).Select(x => x % groups).Shuffle(random);
    6059      var grouping = Enumerable.Range(0, groups).Select(x => new List<int>()).ToList();
     
    6362        grouping[g].Add(idx++);
    6463
    65       solution.SetGroups(grouping);
    66       return solution;
     64      return LinearLinkage.FromGroups(length, grouping);
    6765    }
    6866
  • trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/Creators/MaxGroupsLinearLinkageCreator.cs

    r14185 r14475  
    5555
    5656    public static LinearLinkage Apply(IRandom random, int length, int maxGroups) {
    57       var solution = new LinearLinkage(length);
    5857      var groups = Enumerable.Range(0, length).Select(x => Tuple.Create(x, random.Next(maxGroups)))
    5958                                              .GroupBy(x => x.Item2)
    6059                                              .Select(x => x.Select(y => y.Item1).ToList());
    61       solution.SetGroups(groups);
    62       return solution;
     60      return LinearLinkage.FromGroups(length, groups);
    6361    }
    6462
  • trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/Creators/RandomLinearLinkageCreator.cs

    r14185 r14475  
    4141
    4242    public static LinearLinkage Apply(IRandom random, int length) {
    43       var solution = new LinearLinkage(length);
    4443      var groups = Enumerable.Range(0, length).Select(x => Tuple.Create(x, random.Next(length)))
    4544                                              .GroupBy(x => x.Item2)
    4645                                              .Select(x => x.Select(y => y.Item1).ToList());
    47       solution.SetGroups(groups);
    48       return solution;
     46      return LinearLinkage.FromGroups(length, groups);
    4947    }
    5048
Note: See TracChangeset for help on using the changeset viewer.