- Timestamp:
- 07/09/15 23:11:18 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/Crossovers/MultiLLECrossover.cs
r12286 r12701 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Reflection; 25 26 using HeuristicLab.Collections; 26 27 using HeuristicLab.Common; … … 61 62 ChildParameter.ActualName = "LLE"; 62 63 63 foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(ILinearLinkageCrossover) )) {64 foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(ILinearLinkageCrossover), typeof(LinearLinkageEncoding).Assembly)) { 64 65 if (!typeof(MultiOperator<ILinearLinkageCrossover>).IsAssignableFrom(type)) 65 66 Operators.Add((ILinearLinkageCrossover)Activator.CreateInstance(type), true); -
trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/LinearLinkage.cs
r12650 r12701 77 77 78 78 /// <summary> 79 /// This method parses the encoded array and gathers all items that 80 /// belong to the same group as element <paramref name="index"/>. 81 /// </summary> 82 /// <param name="index">The element whose group should be returned.</param> 79 /// This method parses the encoded array and gathers all elements 80 /// that belong to the same group as element <paramref name="index"/>. 81 /// </summary> 82 /// <param name="index">The element whose group should be returned. 83 /// </param> 83 84 /// <returns>The element at <paramref name="index"/> and all other 84 85 /// elements in the same group.</returns> 85 86 public IEnumerable<int> GetGroup(int index) { 86 // return current element 87 yield return index; 88 var next = array[index]; 89 if (next == index) yield break; 90 int prev; 91 // return succeeding elements in group 92 do { 93 yield return next; 94 prev = next; 95 next = array[next]; 96 } while (next != prev); 97 next = array[index]; 98 // return preceding elements in group 99 for (prev = index - 1; prev >= 0; prev--) { 100 if (array[prev] != next) continue; 101 next = prev; 102 yield return next; 103 } 104 } 105 106 /// <summary> 107 /// This method parses the encoded array and gathers the item itself as 108 /// well as subsequent items that belong to the same group as element 109 /// <paramref name="index"/>. 110 /// </summary> 111 /// <param name="index">The element from which items in the group should 112 /// be returned.</param> 113 /// <returns>The element at <paramref name="index"/> and all subsequent 87 foreach (var n in GetGroupForward(index)) 88 yield return n; 89 // the element index has already been yielded 90 foreach (var n in GetGroupBackward(index).Skip(1)) 91 yield return n; 92 } 93 94 /// <summary> 95 /// This method parses the encoded array and gathers the element 96 /// <paramref name="index"/> as well as subsequent elements that 97 /// belong to the same group. 98 /// </summary> 99 /// <param name="index">The element from which subsequent (having a 100 /// larger number) elements in the group should be returned. 101 /// </param> 102 /// <returns>The element <paramref name="index"/> and all subsequent 114 103 /// elements in the same group.</returns> 115 104 public IEnumerable<int> GetGroupForward(int index) { … … 123 112 next = array[next]; 124 113 } while (next != prev); 114 } 115 116 /// <summary> 117 /// This method parses the encoded array and gathers the element 118 /// given <paramref name="index"/> as well as preceeding elements that 119 /// belong to the same group. 120 /// </summary> 121 /// <remarks> 122 /// Warning, this code has performance O(index) as the array has to 123 /// be fully traversed backwards from the given index. 124 /// </remarks> 125 /// <param name="index">The element from which preceeding (having a 126 /// smaller number) elements in the group should be returned. 127 /// </param> 128 /// <returns>The element <paramref name="index"/> and all preceeding 129 /// elements in the same group.</returns> 130 public IEnumerable<int> GetGroupBackward(int index) { 131 yield return index; 132 var next = array[index]; 133 // return preceding elements in group 134 for (var prev = index - 1; prev >= 0; prev--) { 135 if (array[prev] != next) continue; 136 next = prev; 137 yield return next; 138 } 125 139 } 126 140 -
trunk/sources/HeuristicLab.Encodings.LinearLinkageEncoding/3.3/Manipulators/MultiLLEManipulator.cs
r12288 r12701 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Reflection; 25 26 using HeuristicLab.Collections; 26 27 using HeuristicLab.Common; … … 53 54 : base() { 54 55 Parameters.Add(new LookupParameter<LinearLinkage>("LLE", "The encoding vector that is to be manipulated.")); 55 foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(ILinearLinkageManipulator) )) {56 foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(ILinearLinkageManipulator), typeof(LinearLinkageEncoding).Assembly)) { 56 57 if (!typeof(MultiOperator<ILinearLinkageManipulator>).IsAssignableFrom(type)) 57 58 Operators.Add((ILinearLinkageManipulator)Activator.CreateInstance(type), true); … … 59 60 Operators.SetItemCheckedState(Operators.OfType<SwapItemManipulator>().First(), false); 60 61 Operators.SetItemCheckedState(Operators.OfType<GraftManipulator>().First(), false); 61 SelectedOperatorParameter.ActualName = "SelectedManipulat orOperator";62 SelectedOperatorParameter.ActualName = "SelectedManipulationOperator"; 62 63 } 63 64
Note: See TracChangeset
for help on using the changeset viewer.