Changeset 3137 for trunk/sources/HeuristicLab.Selection
- Timestamp:
- 03/20/10 03:49:15 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Selection/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Selection/3.3/BestSelector.cs
r3128 r3137 53 53 54 54 if (copy) { 55 for (int i = 0, j = 0; i < count; i++, j++) { 55 int j = 0; 56 for (int i = 0; i < count; i++) { 57 selected[i] = (IScope)scopes[list[j].index].Clone(); 58 j++; 56 59 if (j >= list.Count) j = 0; 57 selected[i] = (IScope)scopes[list[j].index].Clone();58 60 } 59 61 } else { 60 int i; 61 for (i = 0; i < count; i++) { 62 selected[i] = scopes[list[i].index]; 62 for (int i = 0; i < count; i++) { 63 selected[i] = scopes[list[0].index]; 64 scopes[list[0].index] = null; 65 list.RemoveAt(0); 63 66 } 64 // remove the selected scopes starting from the scope with the highest index 65 if (i < list.Count) list.RemoveRange(i, list.Count - i); 66 list = list.OrderBy(x => x.index).ToList(); 67 do { 68 i--; 69 scopes.RemoveAt(list[i].index); 70 } while (i > 0); 67 scopes.RemoveAll(x => x == null); 71 68 } 72 69 return selected; -
trunk/sources/HeuristicLab.Selection/3.3/LinearRankSelector.cs
r3096 r3137 55 55 for (int i = 0; i < count; i++) { 56 56 int selectedLot = random.Next(lotSum) + 1; 57 int index= 0;58 int currentLot = list[ index].lots;57 int j = 0; 58 int currentLot = list[j].lots; 59 59 while (currentLot < selectedLot) { 60 index++;61 currentLot += list[ index].lots;60 j++; 61 currentLot += list[j].lots; 62 62 } 63 63 if (copy) 64 selected[i] = (IScope)scopes[list[ index].index].Clone();64 selected[i] = (IScope)scopes[list[j].index].Clone(); 65 65 else { 66 selected[i] = scopes[list[ index].index];67 scopes .RemoveAt(list[index].index);68 lotSum -= list[ index].lots;69 list.RemoveAt( index);66 selected[i] = scopes[list[j].index]; 67 scopes[list[j].index] = null; 68 lotSum -= list[j].lots; 69 list.RemoveAt(j); 70 70 } 71 71 } 72 if (!copy) scopes.RemoveAll(x => x == null); 72 73 return selected; 73 74 } -
trunk/sources/HeuristicLab.Selection/3.3/WorstSelector.cs
r3096 r3137 51 51 var list = temp.ToList(); 52 52 53 i nt j = 0;54 for (int i = 0; i < count; i++) {55 if (copy) {53 if (copy) { 54 int j = 0; 55 for (int i = 0; i < count; i++) { 56 56 selected[i] = (IScope)scopes[list[j].index].Clone(); 57 57 j++; 58 58 if (j >= list.Count) j = 0; 59 } else {60 selected[i] = scopes[list[j].index];61 scopes.RemoveAt(list[j].index);62 list.RemoveAt(j);63 59 } 60 } else { 61 for (int i = 0; i < count; i++) { 62 selected[i] = scopes[list[0].index]; 63 scopes[list[0].index] = null; 64 list.RemoveAt(0); 65 } 66 scopes.RemoveAll(x => x == null); 64 67 } 65 68 return selected;
Note: See TracChangeset
for help on using the changeset viewer.