Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/14/16 10:16:50 (8 years ago)
Author:
sraggl
Message:

#2701 Merged with trunk to get new version of LinearLinkageEncoding
Improved MoveGenerator

Location:
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/LinearLinkageMemPR.cs

    r14484 r14487  
    250250      var p1 = p1Scope.Solution;
    251251      var p2 = p2Scope.Solution;
    252       var transfered = new bool[p1.Length];
    253       var subspace = new bool[p1.Length];
    254       var lleeChild = new int[p1.Length];
    255       var lleep1 = p1.ToLLEe();
    256       var lleep2 = p2.ToLLEe();
    257       for (var i = p1.Length - 1; i >= 0; i--) {
    258         // Step 1
    259         subspace[i] = p1[i] != p2[i];
    260         var p1IsEnd = p1[i] == i;
    261         var p2IsEnd = p2[i] == i;
    262         if (p1IsEnd & p2IsEnd) {
    263           transfered[i] = true;
    264         } else if (p1IsEnd | p2IsEnd) {
    265           transfered[i] = Context.Random.NextDouble() < 0.5;
    266         }
    267         lleeChild[i] = i;
    268 
    269         // Step 2
    270         if (transfered[i]) continue;
    271         var end1 = lleep1[i];
    272         var end2 = lleep2[i];
    273         var containsEnd1 = transfered[end1];
    274         var containsEnd2 = transfered[end2];
    275         if (containsEnd1 & containsEnd2) {
    276           if (Context.Random.NextDouble() < 0.5) {
    277             lleeChild[i] = end1;
    278           } else {
    279             lleeChild[i] = end2;
    280           }
    281         } else if (containsEnd1) {
    282           lleeChild[i] = end1;
    283         } else if (containsEnd2) {
    284           lleeChild[i] = end2;
    285         } else {
    286           if (Context.Random.NextDouble() < 0.5) {
    287             lleeChild[i] = lleeChild[p1[i]];
    288           } else {
    289             lleeChild[i] = lleeChild[p2[i]];
    290           }
    291         }
    292       }
    293       var child = new Encodings.LinearLinkageEncoding.LinearLinkage(lleeChild.Length);
    294       child.FromLLEe(lleeChild);
    295      
    296       return ToScope(child);
     252      return ToScope(GroupCrossover.Apply(Context.Random, p1, p2));
    297253    }
    298254
  • branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/SolutionModel/Univariate/UnivariateSolutionModel.cs

    r14466 r14487  
    6363    public Encodings.LinearLinkageEncoding.LinearLinkage Sample() {
    6464      var N = Frequencies.Rows;
    65       var centroid = new Encodings.LinearLinkageEncoding.LinearLinkage(N);
     65      var centroid = Encodings.LinearLinkageEncoding.LinearLinkage.SingleElementGroups(N);
    6666      var dict = new Dictionary<int, int>();
    6767      for (var i = N - 1; i >= 0; i--) {
Note: See TracChangeset for help on using the changeset viewer.