Changeset 16692 for branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Crossovers
- Timestamp:
- 03/18/19 17:24:30 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Crossovers/GreedyPartitionCrossover.cs
r12285 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 44 44 public static LinearLinkage Apply(IRandom random, ItemArray<LinearLinkage> parents) { 45 45 var len = parents[0].Length; 46 47 var child = new LinearLinkage(len);48 46 var childGroup = new List<HashSet<int>>(); 49 47 var currentParent = random.Next(parents.Length); … … 69 67 } while (remaining); 70 68 71 child.SetGroups(childGroup); 72 return child; 69 return LinearLinkage.FromGroups(len, childGroup); 73 70 } 74 71 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Crossovers/GroupCrossover.cs
r12650 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 39 39 return new GroupCrossover(this, cloner); 40 40 } 41 41 42 42 public static LinearLinkage Apply(IRandom random, LinearLinkage p1, LinearLinkage p2) { 43 43 var length = p1.Length; 44 var child = new LinearLinkage(length); 45 var endNodes = new HashSet<int>(); 46 for (var i = 0; i < length; i++) { 47 if ((p1[i] == i && p2[i] == i) 48 || ((p1[i] == i || p2[i] == i) && random.NextDouble() < 0.5)) { 49 child[i] = i; 50 endNodes.Add(i); 44 var lleeP1 = p1.ToEndLinks(); 45 var lleeP2 = p2.ToEndLinks(); 46 var lleeChild = new int[length]; 47 var isTransfered = new bool[length]; 48 49 for (var i = p1.Length - 1; i >= 0; i--) { 50 lleeChild[i] = i; 51 52 // Step 1 53 var isEndP1 = p1[i] == i; 54 var isEndP2 = p2[i] == i; 55 if (isEndP1 & isEndP2 || (isEndP1 | isEndP2 && random.NextDouble() < 0.5)) { 56 isTransfered[i] = true; 57 continue; 58 } 59 60 // Step 2 61 var end1 = lleeP1[i]; 62 var end2 = lleeP2[i]; 63 64 if (isTransfered[end1] & isTransfered[end2]) { 65 var end = random.NextDouble() < 0.5 ? end1 : end2; 66 lleeChild[i] = end; 67 } else if (isTransfered[end1]) { 68 lleeChild[i] = end1; 69 } else if (isTransfered[end2]) { 70 lleeChild[i] = end2; 71 } else { 72 var next = random.NextDouble() < 0.5 ? p1[i] : p2[i]; 73 var end = lleeChild[next]; 74 lleeChild[i] = end; 51 75 } 52 76 } 53 for (var i = 0; i < length; i++) { 54 if (endNodes.Contains(i)) continue; 55 var p1End = endNodes.Contains(p1[i]); 56 var p2End = endNodes.Contains(p2[i]); 57 if ((p1End && p2End) || (!p1End && !p2End)) { 58 child[i] = random.NextDouble() < 0.5 ? p1[i] : p2[i]; 59 } else if (p1End) { 60 child[i] = p1[i]; 61 } else { 62 child[i] = p2[i]; 63 } 64 } 65 child.LinearizeTreeStructures(); 66 return child; 77 return LinearLinkage.FromEndLinks(lleeChild); 67 78 } 68 79 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Crossovers/LowestIndexFirstCrossover.cs
r12288 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 43 43 var len = parents[0].Length; 44 44 var p = random.Next(parents.Length); 45 var child = new LinearLinkage(len);45 var child = LinearLinkage.SingleElementGroups(len); 46 46 var remaining = new SortedSet<int>(Enumerable.Range(0, len)); 47 47 do { -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Crossovers/LowestIndexMaxCrossover.cs
r12288 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 44 44 public static LinearLinkage Apply(IRandom random, ItemArray<LinearLinkage> parents) { 45 45 var len = parents[0].Length; 46 var child = new LinearLinkage(len);46 var child = LinearLinkage.SingleElementGroups(len); 47 47 var remaining = new SortedSet<int>(Enumerable.Range(0, len)); 48 48 do { -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Crossovers/MultiLLECrossover.cs
r12701 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/Crossovers/SinglePointCrossover.cs
r12650 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 41 41 public static LinearLinkage Apply(IRandom random, LinearLinkage p1, LinearLinkage p2) { 42 42 var length = p1.Length; 43 var child = new LinearLinkage(length);43 var child = LinearLinkage.SingleElementGroups(length); 44 44 var bp = random.Next(length - 1); 45 45 for (var i = 0; i <= bp; i++) child[i] = p1[i];
Note: See TracChangeset
for help on using the changeset viewer.