Changeset 5368 for trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs
- Timestamp:
- 01/25/11 09:46:11 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs
r4722 r5368 38 38 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 39 39 int selectedIndex = SelectRandomTourBiasedByLength(random, individual); 40 Tour route1 = 41 individual.Tours[selectedIndex]; 40 Tour route1 = individual.Tours[selectedIndex]; 42 41 43 for (int customer1Position = 0; customer1Position < route1.Cities.Count; customer1Position++) { 42 bool performed = false; 43 int customer1Position = 0; 44 while (customer1Position < route1.Cities.Count) { 45 performed = false; 46 44 47 foreach (Tour tour in individual.Tours) { 45 48 if (tour != route1) { … … 51 54 tour.Cities[customer2Position] = customer1; 52 55 if (Feasible(tour)) { 53 int route , place;56 int routeIdx, place; 54 57 if (FindInsertionPlace(individual, 55 customer2, selectedIndex, out route , out place)) {56 individual.Tours[route].Cities.Insert(place, customer2);57 route1.Cities.RemoveAt(customer1Position);58 customer2, selectedIndex, out routeIdx, out place)) { 59 individual.Tours[routeIdx].Cities.Insert(place, customer2); 60 route1.Cities.RemoveAt(customer1Position); 58 61 59 if (route1.Cities.Count == 0)62 if (route1.Cities.Count == 0) 60 63 individual.Tours.Remove(route1); 61 64 62 65 //two-level exchange has been performed 63 return; 66 performed = true; 67 break; 64 68 } else { 65 69 tour.Cities[customer2Position] = customer2; … … 70 74 } 71 75 } 76 77 if (performed) 78 break; 72 79 } 80 81 if (!performed) 82 customer1Position++; 73 83 } 74 84 }
Note: See TracChangeset
for help on using the changeset viewer.