Changeset 6909 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift
- Timestamp:
- 10/12/11 15:45:48 (13 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift/PotvinPDShiftMultiMoveGenerator.cs
r6773 r6909 64 64 65 65 for (int i = 0; i < SampleSizeParameter.ActualValue.Value; i++) { 66 result.Add(PotvinPDShiftSingleMoveGenerator.Apply(individual, ProblemInstance, RandomParameter.ActualValue)); 66 var move = PotvinPDShiftSingleMoveGenerator.Apply(individual, ProblemInstance, RandomParameter.ActualValue); 67 if (move != null) 68 result.Add(move); 67 69 } 68 70 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift/PotvinPDShiftSingleMoveGenerator.cs
r6851 r6909 62 62 IPickupAndDeliveryProblemInstance pdp = problemInstance as IPickupAndDeliveryProblemInstance; 63 63 for (int i = 1; i <= individual.Cities; i++) { 64 if (pdp == null || pdp.GetDemand(i) >= 0)64 if (pdp == null || pdp.GetDemand(i) >= 0) 65 65 cities.Add(i); 66 66 } 67 67 68 int city = cities[rand.Next(cities.Count)]; 69 Tour oldTour = individual.Tours.Find(t => t.Stops.Contains(city)); 70 int oldTourIndex = individual.Tours.IndexOf(oldTour); 68 if (cities.Count > 1 && individual.Tours.Count > 1) { 69 int city = cities[rand.Next(cities.Count)]; 70 Tour oldTour = individual.Tours.Find(t => t.Stops.Contains(city)); 71 int oldTourIndex = individual.Tours.IndexOf(oldTour); 71 72 72 int max = individual.Tours.Count;73 if (individual.Tours.Count < problemInstance.Vehicles.Value)74 max = max - 1;73 int max = individual.Tours.Count; 74 if (individual.Tours.Count < problemInstance.Vehicles.Value) 75 max = max - 1; 75 76 76 int newTourIndex = rand.Next(max);77 if (newTourIndex >= oldTourIndex)78 newTourIndex++;77 int newTourIndex = rand.Next(max); 78 if (newTourIndex >= oldTourIndex) 79 newTourIndex++; 79 80 80 return new PotvinPDShiftMove(city, oldTourIndex, newTourIndex, individual); 81 return new PotvinPDShiftMove(city, oldTourIndex, newTourIndex, individual); 82 } else { 83 return null; 84 } 81 85 } 82 86
Note: See TracChangeset
for help on using the changeset viewer.