- Timestamp:
- 09/01/10 11:13:46 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting
- Files:
-
- 5 deleted
- 4 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting
-
Property
svn:mergeinfo
set to
/branches/VRP/HeuristicLab.Problems.VehicleRouting merged eligible
-
Property
svn:mergeinfo
set to
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs
r4206 r4352 129 129 130 130 if (!(solution is PotvinEncoding)) { 131 parents[i] = PotvinEncoding.ConvertFrom(solution );131 parents[i] = PotvinEncoding.ConvertFrom(solution, DistanceMatrixParameter); 132 132 } else { 133 133 parents[i] = solution; -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs
r4206 r4352 82 82 IVRPEncoding solution = VRPToursParameter.ActualValue; 83 83 if (!(solution is PotvinEncoding)) { 84 VRPToursParameter.ActualValue = PotvinEncoding.ConvertFrom(solution );84 VRPToursParameter.ActualValue = PotvinEncoding.ConvertFrom(solution, DistanceMatrixParameter); 85 85 } 86 86 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs
r4177 r4352 27 27 using System.Drawing; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { 31 32 [Item("PotvinEncoding", "Represents a potvin encoding of VRP solutions. It is implemented as described in Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172.")] 32 33 [StorableClass] 33 public class PotvinEncoding : Item, IVRPEncoding { 34 public override Image ItemImage { 35 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; } 36 } 37 38 #region IVRPEncoding Members 39 [Storable] 40 public ItemList<Tour> Tours { get; set; } 41 42 public int Cities { 43 get 44 { 45 int cities = 0; 46 47 foreach (Tour tour in Tours) { 48 cities += tour.Cities.Count; 49 } 50 51 return cities; 52 } 53 } 54 #endregion 55 34 public class PotvinEncoding : TourEncoding { 56 35 [Storable] 57 36 public List<int> Unrouted { get; set; } … … 65 44 } 66 45 67 public PotvinEncoding() { 68 Tours = new ItemList<Tour>(); 46 public PotvinEncoding(): base() { 69 47 Unrouted = new List<int>(); 70 48 } 49 50 [StorableConstructor] 51 private PotvinEncoding(bool serializing) 52 : base() { 53 } 71 54 72 public static PotvinEncoding ConvertFrom(IVRPEncoding encoding ) {55 public static PotvinEncoding ConvertFrom(IVRPEncoding encoding, ILookupParameter<DoubleMatrix> distanceMatrix) { 73 56 PotvinEncoding solution = new PotvinEncoding(); 74 57 75 solution.Tours.AddRange( 76 encoding.Tours); 58 TourEncoding.ConvertFrom(encoding, solution, distanceMatrix); 77 59 78 60 return solution; … … 82 64 PotvinEncoding solution = new PotvinEncoding(); 83 65 84 Tour tour = new Tour(); 85 for (int i = 0; i < route.Count; i++) { 86 if (route[i] == 0) { 87 if (tour.Cities.Count > 0) { 88 solution.Tours.Add(tour); 89 tour = new Tour(); 90 } 91 } else { 92 tour.Cities.Add(route[i]); 93 } 94 } 66 TourEncoding.ConvertFrom(route, solution); 95 67 96 68 return solution; … … 115 87 if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, 116 88 capacity, coordinates, distanceMatrix, useDistanceMatrix)) { 117 double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);89 double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix); 118 90 119 91 double detour = newLength - length;
Note: See TracChangeset
for help on using the changeset viewer.