Changeset 6618 for branches/GP.Grammar.Editor/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs
- Timestamp:
- 08/01/11 17:48:53 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs
r5445 r6618 69 69 DoubleArray dueTimeArray, 70 70 DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity, 71 DoubleMatrix coordinates, ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix, 72 int city, int routeToAvoid, out int route, out int place) { 71 DistanceMatrix distMatrix, 72 int city, int routeToAvoid, bool allowInfeasible, 73 out int route, out int place) { 73 74 route = -1; 74 75 place = -1; 75 double minDetour = 0; 76 bool bestFeasible = false; 77 double minDetour = double.MaxValue; 76 78 77 79 for (int tour = 0; tour < Tours.Count; tour++) { 78 80 if (tour != routeToAvoid) { 79 81 for (int i = 0; i <= Tours[tour].Cities.Count; i++) { 80 double length = Tours[tour].GetLength( coordinates, distanceMatrix, useDistanceMatrix);82 double length = Tours[tour].GetLength(distMatrix); 81 83 82 84 Tours[tour].Cities.Insert(i, city); 83 85 84 if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, 85 capacity, coordinates, distanceMatrix, useDistanceMatrix)) { 86 double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix); 86 bool feasible = Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, 87 capacity, distMatrix); 87 88 89 if (feasible || allowInfeasible && !bestFeasible) { 90 double newLength = Tours[tour].GetLength(distMatrix); 88 91 double detour = newLength - length; 89 92 90 if (route < = 0 || detour < minDetour) {93 if (route < 0 || detour < minDetour || feasible && !bestFeasible) { 91 94 route = tour; 92 95 place = i; 93 96 minDetour = detour; 97 98 if (feasible) 99 bestFeasible = true; 94 100 } 95 101 }
Note: See TracChangeset
for help on using the changeset viewer.