- Timestamp:
- 09/19/11 14:24:19 (13 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs
r6607 r6796 52 52 individual.Tours[selectedIndex]; 53 53 54 List<int> replaced = new List<int>(); 55 for (int i = 0; i < route1.Stops.Count; i++) { 54 int count = route1.Stops.Count; 55 int i = 0; 56 while(i < count) { 56 57 int insertedRoute, insertedPlace; 57 58 58 if (FindInsertionPlace(individual, route1.Stops[i], selectedIndex, allowInfeasible, out insertedRoute, out insertedPlace)) { 59 individual.Tours[insertedRoute].Stops.Insert(insertedPlace, route1.Stops[i]); 60 replaced.Add(route1.Stops[i]); 59 int city = route1.Stops[i]; 60 route1.Stops.Remove(city); 61 62 if (FindInsertionPlace(individual, city, selectedIndex, allowInfeasible, out insertedRoute, out insertedPlace)) { 63 individual.Tours[insertedRoute].Stops.Insert(insertedPlace, city); 64 } else { 65 route1.Stops.Insert(i, city); 66 i++; 61 67 } 68 69 count = route1.Stops.Count; 62 70 } 63 71 64 route1.Stops.RemoveAll(65 new System.Predicate<int>(66 delegate(int val) {67 return (replaced.Contains(val));68 }69 )70 );71 72 if (route1.Stops.Count == 0)73 individual.Tours.Remove(route1);74 72 } 75 73 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs
r6607 r6796 64 64 //customer1 can be feasibly inserted at the location of customer2 65 65 tour.Stops[customer2Position] = customer1; 66 route1.Stops.RemoveAt(customer1Position); 67 66 68 if (ProblemInstance.Feasible(tour)) { 67 69 int routeIdx, place; … … 69 71 customer2, selectedIndex, allowInfeasible, out routeIdx, out place)) { 70 72 individual.Tours[routeIdx].Stops.Insert(place, customer2); 71 route1.Stops.RemoveAt(customer1Position);72 73 if (route1.Stops.Count == 0)74 individual.Tours.Remove(route1);75 73 76 74 //two-level exchange has been performed … … 79 77 } else { 80 78 tour.Stops[customer2Position] = customer2; 79 route1.Stops.Insert(customer1Position, customer1); 81 80 } 82 81 } else { 83 82 tour.Stops[customer2Position] = customer2; 83 route1.Stops.Insert(customer1Position, customer1); 84 84 } 85 85 }
Note: See TracChangeset
for help on using the changeset viewer.