Changeset 5867 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators
- Timestamp:
- 03/29/11 15:40:01 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs
r4752 r5867 44 44 : base(original, cloner) { 45 45 } 46 46 47 47 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 48 48 int selectedIndex = SelectRandomTourBiasedByLength(random, individual); 49 Tour route1 = 50 individual.Tours[selectedIndex]; 49 Tour route1 = individual.Tours[selectedIndex]; 51 50 52 for (int customer1Position = 0; customer1Position < route1.Stops.Count; customer1Position++) { 51 bool performed = false; 52 int customer1Position = 0; 53 while (customer1Position < route1.Stops.Count) { 54 performed = false; 55 53 56 foreach (Tour tour in individual.Tours) { 54 57 if (tour != route1) { … … 60 63 tour.Stops[customer2Position] = customer1; 61 64 if (ProblemInstance.Feasible(tour)) { 62 int route , place;65 int routeIdx, place; 63 66 if (FindInsertionPlace(individual, 64 customer2, selectedIndex, out route , out place)) {65 individual.Tours[route].Stops.Insert(place, customer2);66 67 customer2, selectedIndex, out routeIdx, out place)) { 68 individual.Tours[routeIdx].Stops.Insert(place, customer2); 69 route1.Stops.RemoveAt(customer1Position); 67 70 68 71 if (route1.Stops.Count == 0) 69 72 individual.Tours.Remove(route1); 70 73 71 74 //two-level exchange has been performed 72 return; 75 performed = true; 76 break; 73 77 } else { 74 78 tour.Stops[customer2Position] = customer2; … … 79 83 } 80 84 } 85 86 if (performed) 87 break; 81 88 } 89 90 if (!performed) 91 customer1Position++; 82 92 } 83 93 }
Note: See TracChangeset
for help on using the changeset viewer.