Changeset 6759 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/IterativeInsertionCreator.cs
- Timestamp:
- 09/14/11 13:00:09 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Creators/IterativeInsertionCreator.cs
r6713 r6759 31 31 using HeuristicLab.Problems.VehicleRouting.Interfaces; 32 32 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 33 using HeuristicLab.Problems.VehicleRouting.Variants; 33 34 34 35 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 84 85 PotvinEncoding result = new PotvinEncoding(instance); 85 86 87 IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance; 88 86 89 List<int> customers = new List<int>(); 87 for (int i = 0; i < instance.Cities.Value; i++) 88 customers.Add(i + 1); 90 for (int i = 1; i <= instance.Cities.Value; i++) 91 if(pdp == null || pdp.Demand[i] >= 0) 92 customers.Add(i); 93 89 94 customers.Sort(delegate(int city1, int city2) 90 95 { … … 104 109 currentTour.Stops.Insert(stopIdx, customers[index]); 105 110 111 if (pdp != null) { 112 stopIdx = result.FindBestInsertionPlace(currentTour, pdp.PickupDeliveryLocation[customers[index]]); 113 currentTour.Stops.Insert(stopIdx, pdp.PickupDeliveryLocation[customers[index]]); 114 } 115 106 116 CVRPEvaluation evaluation = instance.Evaluate(currentTour) as CVRPEvaluation; 107 117 if (result.Tours.Count < instance.Vehicles.Value && 108 118 ((adhereTimeWindows && !instance.Feasible(evaluation)) || ((!adhereTimeWindows) && evaluation.Overload > double.Epsilon))) { 109 currentTour.Stops.RemoveAt(stopIdx); 119 currentTour.Stops.Remove(customers[index]); 120 if (pdp != null) 121 currentTour.Stops.Remove(pdp.PickupDeliveryLocation[customers[index]]); 110 122 111 123 if(currentTour.Stops.Count > 0)
Note: See TracChangeset
for help on using the changeset viewer.