Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/06/15 22:41:24 (9 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/GroupCrossover.cs

    r12285 r12288  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     
    5354      for (var i = 0; i < length; i++) {
    5455        if (endNodes.Contains(i)) continue;
    55         if (endNodes.Contains(p1[i]) && endNodes.Contains(p2[i])) {
     56        var p1End = endNodes.Contains(p1[i]);
     57        var p2End = endNodes.Contains(p2[i]);
     58        if ((p1End && p2End) || (!p1End && !p2End)) {
    5659          child[i] = random.NextDouble() < 0.5 ? p1[i] : p2[i];
    57         } else if (endNodes.Contains(p1[i])) {
     60        } else if (p1End) {
    5861          child[i] = p1[i];
    59         } else if (endNodes.Contains(p2[i])) {
     62        } else {
    6063          child[i] = p2[i];
    61         } else {
    62           var a = p1[i];
    63           var b = p2[i];
    64           while (true) {
    65             if (endNodes.Contains(p2[a])) {
    66               child[i] = p2[a];
    67               break;
    68             }
    69             if (endNodes.Contains(p1[b])) {
    70               child[i] = p1[b];
    71               break;
    72             }
    73             var tmp = b;
    74             b = p2[a];
    75             a = p1[tmp];
    76           }
    7764        }
    7865      }
     66      child.LinearizeTreeStructures();
    7967      return child;
    8068    }
Note: See TracChangeset for help on using the changeset viewer.