Changeset 4377 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP
- Timestamp:
- 09/10/10 11:26:30 (14 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPEvaluator.cs
r4376 r4377 47 47 48 48 protected override void EvaluateTour(VRPEvaluation eval, IVRPProblemInstance instance, Tour tour) { 49 base.EvaluateTour(eval, instance, tour);50 51 49 IHomogenousCapacitatedProblemInstance cvrpInstance = instance as IHomogenousCapacitatedProblemInstance; 50 DoubleArray demand = instance.Demand; 52 51 53 52 double delivered = 0.0; 54 53 double overweight = 0.0; 54 double distance = 0.0; 55 55 56 for (int i = 0; i < tour.Stops.Count; i++) { 57 delivered += instance.Demand[tour.Stops[i]]; 56 //simulate a tour, start and end at depot 57 for (int i = 0; i <= tour.Stops.Count; i++) { 58 int start = 0; 59 if (i > 0) 60 start = tour.Stops[i - 1]; 61 int end = 0; 62 if (i < tour.Stops.Count) 63 end = tour.Stops[i]; 64 65 //drive there 66 double currentDistace = instance.GetDistance(start, end); 67 distance += currentDistace; 68 69 delivered += demand[end]; 58 70 } 71 72 eval.Quality += instance.FleetUsageFactor.Value; 73 eval.Quality += instance.DistanceFactor.Value * distance; 74 75 eval.Distance = distance; 76 eval.VehicleUtilization = 1; 59 77 60 78 double capacity = cvrpInstance.Capacity.Value; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPTW/CVRPTWEvaluator.cs
r4374 r4377 51 51 52 52 protected override void EvaluateTour(VRPEvaluation eval, IVRPProblemInstance instance, Tour tour) { 53 base.EvaluateTour(eval, instance, tour); 53 IHomogenousCapacitatedProblemInstance cvrpInstance = instance as IHomogenousCapacitatedProblemInstance; 54 DoubleArray demand = instance.Demand; 54 55 55 56 ITimeWindowedProblemInstance vrptw = instance as ITimeWindowedProblemInstance; 57 DoubleArray dueTime = vrptw.DueTime; 58 DoubleArray readyTime = vrptw.ReadyTime; 59 DoubleArray serviceTimes = vrptw.ServiceTime; 56 60 57 61 double time = 0.0; … … 59 63 double serviceTime = 0.0; 60 64 double tardiness = 0.0; 65 double delivered = 0.0; 66 double overweight = 0.0; 67 double distance = 0.0; 61 68 62 69 //simulate a tour, start and end at depot … … 72 79 double currentDistace = vrptw.GetDistance(start, end); 73 80 time += currentDistace; 81 distance += currentDistace; 74 82 75 83 //check if it was serviced on time 76 if (time > vrptw.DueTime[end])77 tardiness += time - vrptw.DueTime[end];84 if (time > dueTime[end]) 85 tardiness += time - dueTime[end]; 78 86 79 87 //wait 80 88 double currentWaitingTime = 0.0; 81 if (time < vrptw.ReadyTime[end])82 currentWaitingTime = vrptw.ReadyTime[end] - time;89 if (time < readyTime[end]) 90 currentWaitingTime = readyTime[end] - time; 83 91 waitingTime += currentWaitingTime; 84 92 time += currentWaitingTime; 85 93 86 94 //service 87 double currentServiceTime = vrptw.ServiceTime[end];95 double currentServiceTime = serviceTimes[end]; 88 96 serviceTime += currentServiceTime; 89 97 time += currentServiceTime; 98 delivered += demand[end]; 90 99 } 100 101 eval.Quality += instance.FleetUsageFactor.Value; 102 eval.Quality += instance.DistanceFactor.Value * distance; 103 eval.Distance = distance; 104 eval.VehicleUtilization = 1; 105 106 double capacity = cvrpInstance.Capacity.Value; 107 if (delivered > capacity) { 108 overweight = delivered - capacity; 109 } 110 111 (eval as CVRPEvaluation).Overload = overweight; 112 double penalty = overweight * cvrpInstance.OverloadPenalty.Value; 113 eval.Penalty += penalty; 114 eval.Quality += penalty; 91 115 92 116 (eval as CVRPTWEvaluation).Tardiness = tardiness; 93 117 (eval as CVRPTWEvaluation).TravelTime = time; 94 118 95 doublepenalty = tardiness * vrptw.TardinessPenalty.Value;119 penalty = tardiness * vrptw.TardinessPenalty.Value; 96 120 eval.Penalty += penalty; 97 121 eval.Quality += penalty;
Note: See TracChangeset
for help on using the changeset viewer.