- Timestamp:
- 08/16/10 15:20:29 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs
r4177 r4230 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>(); 48 } 49 50 [StorableConstructor] 51 private PotvinEncoding(bool serializing) 52 : base() { 70 53 } 71 54 … … 73 56 PotvinEncoding solution = new PotvinEncoding(); 74 57 75 solution.Tours.AddRange( 76 encoding.Tours); 58 TourEncoding.ConvertFrom(encoding, solution); 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.