Changeset 7791 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift
- Timestamp:
- 05/10/12 15:31:22 (13 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift/PotvinPDShiftExhaustiveMoveGenerator.cs
r6851 r7791 54 54 55 55 int max = individual.Tours.Count; 56 if (individual.Tours.Count <problemInstance.Vehicles.Value)56 if (individual.Tours.Count >= problemInstance.Vehicles.Value) 57 57 max = max - 1; 58 58 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift/PotvinPDShiftMoveMaker.cs
r7080 r7791 30 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 31 31 using HeuristicLab.Problems.VehicleRouting.Variants; 32 using System.Collections.Generic; 32 33 33 34 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 60 61 61 62 public static void Apply(PotvinEncoding solution, PotvinPDShiftMove move, IVRPProblemInstance problemInstance) { 62 if (move.Tour >= solution.Tours.Count) 63 bool newTour = false; 64 65 if (move.Tour >= solution.Tours.Count) { 63 66 solution.Tours.Add(new Tour()); 67 newTour = true; 68 } 64 69 Tour tour = solution.Tours[move.Tour]; 65 70 … … 80 85 } 81 86 87 if (newTour) { 88 List<int> vehicles = new List<int>(); 89 for (int i = move.Tour; i < problemInstance.Vehicles.Value; i++) { 90 vehicles.Add(solution.GetVehicleAssignment(i)); 91 } 92 93 double bestQuality = double.MaxValue; 94 int bestVehicle = -1; 95 96 int originalVehicle = solution.GetVehicleAssignment(move.Tour); 97 foreach (int vehicle in vehicles) { 98 solution.VehicleAssignment[move.Tour] = vehicle; 99 100 double quality = problemInstance.EvaluateTour(tour, solution).Quality; 101 if (quality < bestQuality) { 102 bestQuality = quality; 103 bestVehicle = vehicle; 104 } 105 } 106 107 solution.VehicleAssignment[move.Tour] = originalVehicle; 108 109 int index = -1; 110 for (int i = move.Tour; i < solution.VehicleAssignment.Length; i++) { 111 if (solution.VehicleAssignment[i] == bestVehicle) { 112 index = i; 113 break; 114 } 115 } 116 solution.VehicleAssignment[index] = originalVehicle; 117 solution.VehicleAssignment[move.Tour] = bestVehicle; 118 } 119 82 120 solution.Repair(); 83 121 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift/PotvinPDShiftMoveTabuCriterion.cs
r6857 r7791 140 140 quality += attribute.Tardiness * vrptw.TardinessPenalty.Value; 141 141 142 IPickupAndDeliveryProblemInstance pdp = instance as IPickupAndDeliveryProblemInstance; 143 if (pdp != null) 144 quality += attribute.PickupViolations * pdp.PickupViolationPenalty.Value; 145 142 146 if (!useAspiration || moveQuality >= quality) { 143 147 if (attribute.City == move.City && attribute.Tour == move.Tour) { -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift/PotvinPDShiftMoveTabuMaker.cs
r6773 r7791 54 54 get { return (ILookupParameter<DoubleValue>)Parameters["Tardiness"]; } 55 55 } 56 public ILookupParameter<IntValue> PickupViolationsParameter { 57 get { return (ILookupParameter<IntValue>)Parameters["PickupViolations"]; } 58 } 56 59 57 60 [StorableConstructor] … … 67 70 Parameters.Add(new LookupParameter<DoubleValue>("Overload", "The overload of the individual")); 68 71 Parameters.Add(new LookupParameter<DoubleValue>("Tardiness", "The tardiness of the individual")); 72 Parameters.Add(new LookupParameter<IntValue>("PickupViolations", "The number of pickup violations.")); 69 73 } 70 74 … … 89 93 if (TardinessParameter.ActualValue != null) 90 94 tardiness = TardinessParameter.ActualValue.Value; 95 96 int pickupViolations = 0; 97 if (PickupViolationsParameter.ActualValue != null) 98 pickupViolations = PickupViolationsParameter.ActualValue.Value; 91 99 92 return new PotvinPDRelocateMoveAttribute(baseQuality, move.OldTour, move.City, distance, overload, tardiness );100 return new PotvinPDRelocateMoveAttribute(baseQuality, move.OldTour, move.City, distance, overload, tardiness, pickupViolations); 93 101 } 94 102 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Moves/PickupDelivery/PDShift/PotvinPDShiftSingleMoveGenerator.cs
r6909 r7791 66 66 } 67 67 68 if (cities.Count > 1 && individual.Tours.Count >1) {68 if (cities.Count >= 1) { 69 69 int city = cities[rand.Next(cities.Count)]; 70 70 Tour oldTour = individual.Tours.Find(t => t.Stops.Contains(city)); … … 72 72 73 73 int max = individual.Tours.Count; 74 if (individual.Tours.Count <problemInstance.Vehicles.Value)74 if (individual.Tours.Count >= problemInstance.Vehicles.Value) 75 75 max = max - 1; 76 76
Note: See TracChangeset
for help on using the changeset viewer.