Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/06/15 22:41:24 (10 years ago)
Author:
abeham
Message:

#2319:

  • Changed encoding to represent linkages in LLE (as opposed to LLE-e)
  • Added GraftManipulator
  • Added repair procedure
  • Improved performance of some crossovers
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/LinearLinkage/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/Crossovers/LowestIndexFirstCrossover.cs

    r12285 r12288  
    4242    public static LinearLinkage Apply(IRandom random, ItemArray<LinearLinkage> parents) {
    4343      var len = parents[0].Length;
     44      var p = random.Next(parents.Length);
    4445      var child = new LinearLinkage(len);
    45       var childGroup = new List<HashSet<int>>();
    46       var currentParent = random.Next(parents.Length);
    47       var remaining = new HashSet<int>(Enumerable.Range(0, len));
     46      var remaining = new SortedSet<int>(Enumerable.Range(0, len));
    4847      do {
    49         var i = remaining.Min();
    50         var group = new HashSet<int>(parents[currentParent].GetGroupForward(i));
    51         group.IntersectWith(remaining);
    52         childGroup.Add(group);
    53         remaining.ExceptWith(group);
    54         currentParent = (currentParent + 1) % parents.Length;
     48        var i = remaining.Min;
     49        foreach (var g in parents[p].GetGroupForward(i)) {
     50          if (!remaining.Contains(g)) continue;
     51          child[i] = g;
     52          i = g;
     53          remaining.Remove(g);
     54        }
     55        child[i] = i;
     56        remaining.Remove(i);
     57
     58        p = (p + 1) % parents.Length;
    5559      } while (remaining.Count > 0);
    5660
    57       child.SetGroups(childGroup);
    5861      return child;
    5962    }
Note: See TracChangeset for help on using the changeset viewer.