- Timestamp:
- 08/20/10 11:43:31 (14 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR/GVREncoding.cs
r4268 r4270 40 40 41 41 public override List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix = null, int maxVehicles = int.MaxValue) { 42 List<Tour> tours = new List<Tour>(); 43 Tour newTour = new Tour(); 44 double currentDemand = 0; 42 List<Tour> tours = new List<Tour>(); 45 43 46 int toursProcessed = 0;47 44 foreach (Tour tour in base.Tours) { 48 if (maxVehicles > tours.Count) { 49 newTour = new Tour(); 50 currentDemand = 0; 51 } 45 Tour newTour = new Tour(); 46 double currentDemand = 0; 52 47 53 48 foreach (int city in tour.Cities) { 54 49 currentDemand += demand[city]; 55 50 56 if (maxVehicles > tours.Count && 57 currentDemand > capacity.Value) { 51 if (currentDemand > capacity.Value) { 58 52 if(newTour.Cities.Count > 0) 59 53 tours.Add(newTour); … … 67 61 } 68 62 69 if (newTour.Cities.Count > 0 && 70 maxVehicles > tours.Count) 63 if (newTour.Cities.Count > 0) 71 64 tours.Add(newTour); 65 } 72 66 73 toursProcessed++; 74 } 67 //repair if there are too many vehicles used 68 while (tours.Count > maxVehicles) { 69 Tour tour = tours[tours.Count - 1]; 70 tours[tours.Count - 2].Cities.AddRange(tour.Cities); 71 72 tours.Remove(tour); 73 } 75 74 76 75 return tours; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR/Manipulators/GVRInsertionManipulator.cs
r4231 r4270 55 55 } else { 56 56 Tour newTour = individual.Tours[random.Next(individual.Tours.Count)]; 57 int newPosition = newTour.Cities.Count;57 int newPosition = random.Next(newTour.Cities.Count + 1); 58 58 59 59 newTour.Cities.Insert(newPosition, customer);
Note: See TracChangeset
for help on using the changeset viewer.