Changeset 7807 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators
- Timestamp:
- 05/14/12 15:59:39 (13 years ago)
- Location:
- branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Crossovers/GQAPPathRelinking.cs
r7523 r7807 183 183 if (B.Any()) { 184 184 GQAPSolution pi; 185 if (maximization.Value) pi = B. ChooseProportionalRandom(random, 1, x => x.Quality.Value, false, true).First();186 else pi = B. ChooseProportionalRandom(random, 1, x => 1.0 / x.Quality.Value, false, true).First();185 if (maximization.Value) pi = B.SampleProportional(random, 1, B.Select(x => x.Quality.Value), false).First(); 186 else pi = B.SampleProportional(random, 1, B.Select(x => 1.0 / x.Quality.Value), false).First(); 187 187 var diff = IntegerVectorEqualityComparer.GetDifferingIndices(pi.Assignment, target); 188 188 var I = phi.Except(diff); 189 var i = I. ChooseUniformRandom(random);189 var i = I.SampleRandom(random); 190 190 fix.Add(i); 191 191 nonFix.Remove(i); … … 226 226 var T = nonFix.Where(x => x != equipment && assignment[x] == l && demands[x] <= maxSlack); 227 227 if (T.Any()) { 228 int i = T. ChooseProportionalRandom(random, 1, x => demands[x], false, true).First();229 var j = Enumerable.Range(0, capacities.Length).Where(x => slack[x] >= demands[i]). ChooseUniformRandom(random);228 int i = T.SampleProportional(random, 1, T.Select(x => demands[x]), false).First(); 229 var j = Enumerable.Range(0, capacities.Length).Where(x => slack[x] >= demands[i]).SampleRandom(random); 230 230 result[i] = j; 231 231 slack[j] -= demands[i]; -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators/DemandEquivalentSwapEquipmentManipluator.cs
r7523 r7807 80 80 groupedLocations[location2].Remove(equipment2); 81 81 if (!groupedLocations[location2].Any()) break; 82 equipment2 = groupedLocations[location2]. ChooseUniformRandom(random);82 equipment2 = groupedLocations[location2].SampleRandom(random); 83 83 } 84 84 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Manipulators/RelocateEquipmentManipluator.cs
r7523 r7807 79 79 } 80 80 81 var sourceLocation = overbookedLocations. ChooseUniformRandom(random);82 int equipmentToRelocate = groupedLocations[sourceLocation.Key]. ChooseUniformRandom(random);81 var sourceLocation = overbookedLocations.SampleRandom(random); 82 int equipmentToRelocate = groupedLocations[sourceLocation.Key].SampleRandom(random); 83 83 var bestFreeLocations = freeLocations.Where(x => capacities[x.Key] > x.Value + demands[equipmentToRelocate]); 84 84 85 85 if (bestFreeLocations.Any()) { // a feasible solution will still be feasible, an infeasible solution might become feasible 86 var selected = bestFreeLocations. ChooseUniformRandom(random);86 var selected = bestFreeLocations.SampleRandom(random); 87 87 assignment[equipmentToRelocate] = sourceLocation.Key; 88 88 } else { // the solution will become infeasible 89 sourceLocation = freeLocations. ChooseUniformRandom(random);89 sourceLocation = freeLocations.SampleRandom(random); 90 90 assignment[equipmentToRelocate] = sourceLocation.Key; 91 91 }
Note: See TracChangeset
for help on using the changeset viewer.