- Timestamp:
- 12/12/16 13:53:16 (8 years ago)
- 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 56 56 57 57 public static LinearLinkage Apply(IRandom random, int length, int groups) { 58 var solution = new LinearLinkage(length);59 58 var groupNumbers = Enumerable.Range(0, length).Select(x => x % groups).Shuffle(random); 60 59 var grouping = Enumerable.Range(0, groups).Select(x => new List<int>()).ToList(); … … 63 62 grouping[g].Add(idx++); 64 63 65 solution.SetGroups(grouping); 66 return solution; 64 return LinearLinkage.FromGroups(length, grouping); 67 65 } 68 66 -
trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/Creators/MaxGroupsLinearLinkageCreator.cs
r14185 r14475 55 55 56 56 public static LinearLinkage Apply(IRandom random, int length, int maxGroups) { 57 var solution = new LinearLinkage(length);58 57 var groups = Enumerable.Range(0, length).Select(x => Tuple.Create(x, random.Next(maxGroups))) 59 58 .GroupBy(x => x.Item2) 60 59 .Select(x => x.Select(y => y.Item1).ToList()); 61 solution.SetGroups(groups); 62 return solution; 60 return LinearLinkage.FromGroups(length, groups); 63 61 } 64 62 -
trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/Creators/RandomLinearLinkageCreator.cs
r14185 r14475 41 41 42 42 public static LinearLinkage Apply(IRandom random, int length) { 43 var solution = new LinearLinkage(length);44 43 var groups = Enumerable.Range(0, length).Select(x => Tuple.Create(x, random.Next(length))) 45 44 .GroupBy(x => x.Item2) 46 45 .Select(x => x.Select(y => y.Item1).ToList()); 47 solution.SetGroups(groups); 48 return solution; 46 return LinearLinkage.FromGroups(length, groups); 49 47 } 50 48
Note: See TracChangeset
for help on using the changeset viewer.