- Timestamp:
- 09/29/11 15:51:56 (13 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances
- Files:
-
- 6 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPEvaluator.cs
r6838 r6851 38 38 [Item("CVRPEvaluator", "Represents a single depot CVRP evaluator.")] 39 39 [StorableClass] 40 public class CVRPEvaluator: SingleDepotVRPEvaluator {40 public class CVRPEvaluator: VRPEvaluator { 41 41 public ILookupParameter<DoubleValue> OverloadParameter { 42 42 get { return (ILookupParameter<DoubleValue>)Parameters["Overload"]; } … … 79 79 80 80 //drive there 81 double currentDistace = instance.GetDistance(start, end );81 double currentDistace = instance.GetDistance(start, end, solution); 82 82 distance += currentDistace; 83 83 … … 103 103 } 104 104 105 protected override double GetTourInsertionCosts(IVRPProblemInstance instance, TourInsertionInfo tourInsertionInfo, int index, int customer,105 protected override double GetTourInsertionCosts(IVRPProblemInstance instance, IVRPEncoding solution, TourInsertionInfo tourInsertionInfo, int index, int customer, 106 106 out bool feasible) { 107 107 CVRPInsertionInfo insertionInfo = tourInsertionInfo.GetStopInsertionInfo(index) as CVRPInsertionInfo; … … 113 113 double overloadPenalty = cvrp.OverloadPenalty.Value; 114 114 115 double distance = instance.GetDistance(insertionInfo.Start, insertionInfo.End );115 double distance = instance.GetDistance(insertionInfo.Start, insertionInfo.End, solution); 116 116 double newDistance = 117 instance.GetDistance(insertionInfo.Start, customer ) +118 instance.GetDistance(customer, insertionInfo.End );117 instance.GetDistance(insertionInfo.Start, customer, solution) + 118 instance.GetDistance(customer, insertionInfo.End, solution); 119 119 costs += instance.DistanceFactor.Value * (newDistance - distance); 120 120 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPTW/CVRPPDTW/CVRPPDTWEvaluator.cs
r6838 r6851 85 85 86 86 //drive there 87 double currentDistace = vrptw.GetDistance(start, end );87 double currentDistace = vrptw.GetDistance(start, end, solution); 88 88 time += currentDistace; 89 89 distance += currentDistace; … … 166 166 } 167 167 168 protected override double GetTourInsertionCosts(IVRPProblemInstance instance, TourInsertionInfo tourInsertionInfo, int index, int customer,168 protected override double GetTourInsertionCosts(IVRPProblemInstance instance, IVRPEncoding solution, TourInsertionInfo tourInsertionInfo, int index, int customer, 169 169 out bool feasible) { 170 170 CVRPPDTWInsertionInfo insertionInfo = tourInsertionInfo.GetStopInsertionInfo(index) as CVRPPDTWInsertionInfo; … … 187 187 double pickupPenalty = pdp.PickupViolationPenalty.Value; 188 188 189 double distance = instance.GetDistance(insertionInfo.Start, insertionInfo.End );189 double distance = instance.GetDistance(insertionInfo.Start, insertionInfo.End, solution); 190 190 double newDistance = 191 instance.GetDistance(insertionInfo.Start, customer ) +192 instance.GetDistance(customer, insertionInfo.End );191 instance.GetDistance(insertionInfo.Start, customer, solution) + 192 instance.GetDistance(customer, insertionInfo.End, solution); 193 193 costs += instance.DistanceFactor.Value * (newDistance - distance); 194 194 … … 215 215 if (index > 0) 216 216 time = (tourInsertionInfo.GetStopInsertionInfo(index - 1) as CVRPTWInsertionInfo).LeaveTime; 217 time += instance.GetDistance(insertionInfo.Start, customer );217 time += instance.GetDistance(insertionInfo.Start, customer, solution); 218 218 if (time > dueTime[customer]) { 219 219 tardiness += time - dueTime[customer]; … … 222 222 time += readyTime[customer] - time; 223 223 time += serviceTimes[customer]; 224 time += instance.GetDistance(customer, insertionInfo.End );224 time += instance.GetDistance(customer, insertionInfo.End, solution); 225 225 226 226 double additionalTime = time - (tourInsertionInfo.GetStopInsertionInfo(index) as CVRPTWInsertionInfo).ArrivalTime; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPTW/CVRPTWEvaluator.cs
r6838 r6851 92 92 93 93 //drive there 94 double currentDistace = vrptw.GetDistance(start, end );94 double currentDistace = vrptw.GetDistance(start, end, solution); 95 95 time += currentDistace; 96 96 distance += currentDistace; … … 150 150 } 151 151 152 protected override double GetTourInsertionCosts(IVRPProblemInstance instance, TourInsertionInfo tourInsertionInfo, int index, int customer,152 protected override double GetTourInsertionCosts(IVRPProblemInstance instance, IVRPEncoding solution, TourInsertionInfo tourInsertionInfo, int index, int customer, 153 153 out bool feasible) { 154 154 CVRPTWInsertionInfo insertionInfo = tourInsertionInfo.GetStopInsertionInfo(index) as CVRPTWInsertionInfo; … … 166 166 double tardinessPenalty = vrptw.TardinessPenalty.Value; 167 167 168 double distance = instance.GetDistance(insertionInfo.Start, insertionInfo.End );168 double distance = instance.GetDistance(insertionInfo.Start, insertionInfo.End, solution); 169 169 double newDistance = 170 instance.GetDistance(insertionInfo.Start, customer ) +171 instance.GetDistance(customer, insertionInfo.End );170 instance.GetDistance(insertionInfo.Start, customer, solution) + 171 instance.GetDistance(customer, insertionInfo.End, solution); 172 172 costs += instance.DistanceFactor.Value * (newDistance - distance); 173 173 … … 186 186 if (index > 0) 187 187 time = (tourInsertionInfo.GetStopInsertionInfo(index - 1) as CVRPTWInsertionInfo).LeaveTime; 188 time += instance.GetDistance(insertionInfo.Start, customer );188 time += instance.GetDistance(insertionInfo.Start, customer, solution); 189 189 if (time > dueTime[customer]) { 190 190 tardiness += time - dueTime[customer]; … … 193 193 time += readyTime[customer] - time; 194 194 time += serviceTimes[customer]; 195 time += instance.GetDistance(customer, insertionInfo.End );195 time += instance.GetDistance(customer, insertionInfo.End, solution); 196 196 197 197 double additionalTime = time - (tourInsertionInfo.GetStopInsertionInfo(index) as CVRPTWInsertionInfo).ArrivalTime; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/SingleDepotVRPEvaluator.cs
r6838 r6851 57 57 58 58 //drive there 59 double currentDistace = instance.GetDistance(start, end );59 double currentDistace = instance.GetDistance(start, end, solution); 60 60 distance += currentDistace; 61 61 … … 75 75 } 76 76 77 protected override double GetTourInsertionCosts(IVRPProblemInstance instance, TourInsertionInfo tourInsertionInfo, int index, int customer,77 protected override double GetTourInsertionCosts(IVRPProblemInstance instance, IVRPEncoding solution, TourInsertionInfo tourInsertionInfo, int index, int customer, 78 78 out bool feasible) { 79 79 StopInsertionInfo insertionInfo = tourInsertionInfo.GetStopInsertionInfo(index); … … 82 82 feasible = true; 83 83 84 double distance = instance.GetDistance(insertionInfo.Start, insertionInfo.End );84 double distance = instance.GetDistance(insertionInfo.Start, insertionInfo.End, solution); 85 85 double newDistance = 86 instance.GetDistance(insertionInfo.Start, customer ) +87 instance.GetDistance(customer, insertionInfo.End );86 instance.GetDistance(insertionInfo.Start, customer, solution) + 87 instance.GetDistance(customer, insertionInfo.End, solution); 88 88 89 89 costs += instance.DistanceFactor.Value * (newDistance - distance); -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPEvaluator.cs
r6838 r6851 103 103 } 104 104 105 protected abstract double GetTourInsertionCosts(IVRPProblemInstance instance, TourInsertionInfo tourInsertionInfo, int index, int customer, out bool feasible);105 protected abstract double GetTourInsertionCosts(IVRPProblemInstance instance, IVRPEncoding solution, TourInsertionInfo tourInsertionInfo, int index, int customer, out bool feasible); 106 106 107 public double GetInsertionCosts(IVRPProblemInstance instance, VRPEvaluation eval, int customer, int tour, int index, out bool feasible) {107 public double GetInsertionCosts(IVRPProblemInstance instance, IVRPEncoding solution, VRPEvaluation eval, int customer, int tour, int index, out bool feasible) { 108 108 bool tourFeasible; 109 109 double costs = GetTourInsertionCosts( 110 110 instance, 111 solution, 111 112 eval.InsertionInfo.GetTourInsertionInfo(tour), index, 112 113 customer, out tourFeasible); -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs
r6838 r6851 188 188 } 189 189 190 public virtual double[] GetCoordinates(int city) { 191 double[] coordinates = new double[Coordinates.Columns]; 192 193 for (int i = 0; i < Coordinates.Columns; i++) { 194 coordinates[i] = Coordinates[city, i]; 195 } 196 197 return coordinates; 198 } 199 200 public virtual double GetDemand(int city) { 201 return Demand[city]; 202 } 203 190 204 //cache for performance improvement 191 205 private DoubleMatrix distanceMatrix = null; 192 206 private IVRPEvaluator evaluator = null; 193 207 194 public double GetDistance(int start, int end) {208 public virtual double GetDistance(int start, int end, IVRPEncoding solution) { 195 209 double distance = 0.0; 196 210 if (distanceMatrix == null && UseDistanceMatrix.Value) { … … 206 220 } 207 221 222 public virtual double GetInsertionDistance(int start, int customer, int end, IVRPEncoding solution) { 223 double distance = GetDistance(start, end, solution); 224 double newDistance = 225 GetDistance(start, customer, solution) + 226 GetDistance(customer, end, solution); 227 228 return newDistance - distance; 229 } 230 208 231 public bool Feasible(IVRPEncoding solution) { 209 232 return evaluator.Feasible( … … 230 253 } 231 254 232 public double GetInsertionCosts(VRPEvaluation eval, int customer, int tour, int index, out bool feasible) {233 return evaluator.GetInsertionCosts(this, eval, customer, tour, index, out feasible);255 public double GetInsertionCosts(VRPEvaluation eval, IVRPEncoding solution, int customer, int tour, int index, out bool feasible) { 256 return evaluator.GetInsertionCosts(this, solution, eval, customer, tour, index, out feasible); 234 257 } 235 258
Note: See TracChangeset
for help on using the changeset viewer.