Changeset 6851 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/ExtendedPotvin/Creators/IterativeInsertionCreator.cs
- Timestamp:
- 09/29/11 15:51:56 (13 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/ExtendedPotvin
- Files:
-
- 2 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/ExtendedPotvin/Creators/IterativeInsertionCreator.cs
r6838 r6851 33 33 using HeuristicLab.Problems.VehicleRouting.Variants; 34 34 35 namespace HeuristicLab.Problems.VehicleRouting.Encodings. Potvin {35 namespace HeuristicLab.Problems.VehicleRouting.Encodings.ExtendedPotvin { 36 36 [Item("IterativeInsertionCreator", "Creates a randomly initialized VRP solution.")] 37 37 [StorableClass] 38 public sealed class IterativeInsertionCreator : PotvinCreator, IStochasticOperator {38 public sealed class IterativeInsertionCreator : ExtendedPotvinCreator, IStochasticOperator { 39 39 #region IStochasticOperator Members 40 40 public ILookupParameter<IRandom> RandomParameter { … … 65 65 66 66 private static double CalculateAngleToDepot(IVRPProblemInstance instance, int city) { 67 double dx = instance. Coordinates[0,0];68 double dy = instance. Coordinates[0,1];67 double dx = instance.GetCoordinates(0)[0]; 68 double dy = instance.GetCoordinates(0)[1]; 69 69 70 double cx = instance. Coordinates[city,0];71 double cy = instance. Coordinates[city,1];70 double cx = instance.GetCoordinates(city)[0]; 71 double cy = instance.GetCoordinates(city)[1]; 72 72 73 73 double alpha = Math.Atan((cx - dx) / (dy - cy)) * (180.0 / Math.PI); … … 82 82 } 83 83 84 private static PotvinEncoding CreateSolution(IVRPProblemInstance instance, IRandom random, bool adhereTimeWindows) {85 PotvinEncoding result = newPotvinEncoding(instance);84 private static ExtendedPotvinEncoding CreateSolution(IVRPProblemInstance instance, IRandom random, bool adhereTimeWindows) { 85 ExtendedPotvinEncoding result = new ExtendedPotvinEncoding(instance); 86 86 87 87 IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance; … … 89 89 List<int> customers = new List<int>(); 90 90 for (int i = 1; i <= instance.Cities.Value; i++) 91 if(pdp == null || pdp. Demand[i]>= 0)91 if(pdp == null || pdp.GetDemand(i) >= 0) 92 92 customers.Add(i); 93 93 … … 107 107 int index = (i + j) % customers.Count; 108 108 109 int stopIdx = result.FindBestInsertionPlace(currentTour, customers[index]); 109 int stopIdx = 0; 110 if(currentTour.Stops.Count > 0) 111 result.FindBestInsertionPlace(currentTour, customers[index]); 110 112 currentTour.Stops.Insert(stopIdx, customers[index]); 111 113 … … 122 124 currentTour.Stops.Remove(pdp.PickupDeliveryLocation[customers[index]]); 123 125 124 if (currentTour.Stops.Count >0)125 result.Tours. Add(currentTour);126 if (currentTour.Stops.Count == 0) 127 result.Tours.Remove(currentTour); 126 128 currentTour = new Tour(); 129 result.Tours.Add(currentTour); 127 130 128 131 currentTour.Stops.Add(customers[index]);
Note: See TracChangeset
for help on using the changeset viewer.