Changeset 6907 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs
- Timestamp:
- 10/12/11 13:41:14 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs
r6857 r6907 61 61 this.Unrouted = new List<int>(original.Unrouted); 62 62 this.VehicleAssignment = cloner.Clone<Permutation>(original.VehicleAssignment); 63 } 64 65 public override void Repair() { 66 List<Tour> toBeRemoved = new List<Tour>(); 67 foreach (Tour tour in Tours) { 68 if (tour.Stops.Count == 0) 69 toBeRemoved.Add(tour); 70 } 71 72 foreach (Tour tour in toBeRemoved) { 73 int index = Tours.IndexOf(tour); 74 if (index < VehicleAssignment.Length) { 75 int vehicle = VehicleAssignment[index]; 76 77 Tours.Remove(tour); 78 for (int i = index; i < VehicleAssignment.Length - 1; i++) { 79 VehicleAssignment[i] = VehicleAssignment[i + 1]; 80 } 81 VehicleAssignment[VehicleAssignment.Length - 1] = vehicle; 82 } 83 } 84 85 while (Tours.Count > ProblemInstance.Vehicles.Value) { 86 Tour tour = Tours[Tours.Count - 1]; 87 Tours[Tours.Count - 2].Stops.AddRange(tour.Stops); 88 89 Tours.Remove(tour); 90 } 63 91 } 64 92
Note: See TracChangeset
for help on using the changeset viewer.