Changeset 14492 for branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/LinearLinkageMemPR.cs
- Timestamp:
- 12/14/16 20:45:46 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MemPRAlgorithm/HeuristicLab.Algorithms.MemPR/3.3/LinearLinkage/LinearLinkageMemPR.cs
r14487 r14492 120 120 tabu[i, current[i]] = quality; 121 121 } 122 122 123 123 // this dictionary holds the last relevant links 124 var links = new BidirectionalDictionary<int, int>(); 124 var groupItems = new List<int>(); 125 var lleb = current.ToBackLinks(); 125 126 Move bestOfTheRest = null; 126 127 var bestOfTheRestF = double.NaN; … … 128 129 for (var iter = 0; iter < int.MaxValue; iter++) { 129 130 // clear the dictionary before a new pass through the array is made 130 links.Clear();131 groupItems.Clear(); 131 132 for (var i = 0; i < current.Length; i++) { 132 133 if (subspace != null && !subspace[i]) { 133 links.RemoveBySecond(i); 134 links.Add(i, current[i]); 134 if (lleb[i] != i) 135 groupItems.Remove(lleb[i]); 136 groupItems.Add(i); 135 137 continue; 136 138 } … … 141 143 if (bestOfTheRest != null) { 142 144 bestOfTheRest.Apply(current); 145 bestOfTheRest.ApplyToLLEb(lleb); 143 146 currentScope.Fitness = bestOfTheRestF; 144 147 quality = bestOfTheRestF; … … 162 165 break; 163 166 } else { 164 foreach (var move in MoveGenerator.GenerateForItem(i, next, links)) {167 foreach (var move in MoveGenerator.GenerateForItem(i, groupItems, current, lleb)) { 165 168 // we intend to break link i -> next 166 169 var qualityToBreak = tabu[i, next]; … … 185 188 if (isAspired) bestQuality = quality; 186 189 187 move. UpdateLinks(links);190 move.ApplyToLLEb(lleb); 188 191 189 192 if (FitnessComparer.IsBetter(maximization, moveF, bestOfTheWalkF)) { … … 209 212 } 210 213 } 211 links.RemoveBySecond(i); 212 links.Add(i, current[i]); 214 if (lleb[i] != i) 215 groupItems.Remove(lleb[i]); 216 groupItems.Add(i); 213 217 if (evaluations >= maxEvals) break; 214 218 if (token.IsCancellationRequested) break;
Note: See TracChangeset
for help on using the changeset viewer.