Changeset 4268 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR/GVREncoding.cs
- Timestamp:
- 08/19/10 16:51:30 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/GVR/GVREncoding.cs
r4230 r4268 37 37 38 38 [Storable] 39 private IntValue vehicles { get; set; }40 41 [Storable]42 39 private DoubleArray demand { get; set; } 43 40 44 public override List<Tour> GetTours( ) {41 public override List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix = null, int maxVehicles = int.MaxValue) { 45 42 List<Tour> tours = new List<Tour>(); 43 Tour newTour = new Tour(); 44 double currentDemand = 0; 46 45 47 46 int toursProcessed = 0; 48 47 foreach (Tour tour in base.Tours) { 49 Tour newTour = new Tour(); 50 double currentDemand = 0; 48 if (maxVehicles > tours.Count) { 49 newTour = new Tour(); 50 currentDemand = 0; 51 } 51 52 52 53 foreach (int city in tour.Cities) { 53 54 currentDemand += demand[city]; 54 55 55 if ( vehicles.Value > tours.Count + base.Tours.Count - toursProcessed&&56 if (maxVehicles > tours.Count && 56 57 currentDemand > capacity.Value) { 57 58 if(newTour.Cities.Count > 0) … … 66 67 } 67 68 68 if (newTour.Cities.Count > 0) 69 if (newTour.Cities.Count > 0 && 70 maxVehicles > tours.Count) 69 71 tours.Add(newTour); 72 70 73 toursProcessed++; 71 74 } … … 75 78 76 79 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) { 77 GVREncoding clone = new GVREncoding(capacity, demand , vehicles);80 GVREncoding clone = new GVREncoding(capacity, demand); 78 81 cloner.RegisterClonedObject(this, clone); 79 82 clone.Tours = (ItemList<Tour>)cloner.Clone(this.Tours); … … 82 85 } 83 86 84 public GVREncoding(DoubleValue capacity, DoubleArray demand , IntValue vehicles)87 public GVREncoding(DoubleValue capacity, DoubleArray demand) 85 88 : base() { 86 89 this.capacity = capacity; 87 90 this.demand = demand; 88 this.vehicles = vehicles;89 91 } 90 92 … … 94 96 } 95 97 96 public static GVREncoding ConvertFrom(IVRPEncoding encoding, DoubleValue capacity, DoubleArray demand, IntValue vehicles) { 97 GVREncoding solution = new GVREncoding(capacity, demand, vehicles); 98 public static GVREncoding ConvertFrom(IVRPEncoding encoding, DoubleValue capacity, DoubleArray demand, 99 ILookupParameter<DoubleMatrix> distanceMatrix) { 100 GVREncoding solution = new GVREncoding(capacity, demand); 98 101 99 TourEncoding.ConvertFrom(encoding, solution );102 TourEncoding.ConvertFrom(encoding, solution, distanceMatrix); 100 103 101 104 return solution; 102 105 } 103 106 104 public static GVREncoding ConvertFrom(List<int> route, DoubleValue capacity, DoubleArray demand , IntValue vehicles) {105 GVREncoding solution = new GVREncoding(capacity, demand , vehicles);107 public static GVREncoding ConvertFrom(List<int> route, DoubleValue capacity, DoubleArray demand) { 108 GVREncoding solution = new GVREncoding(capacity, demand); 106 109 107 110 TourEncoding.ConvertFrom(route, solution);
Note: See TracChangeset
for help on using the changeset viewer.