- Timestamp:
- 06/20/11 16:45:49 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs
r6449 r6455 115 115 newTour.Cities.Remove(0); 116 116 117 if (!newTour.Feasible(118 dueTime, serviceTime, readyTime, demand, capacity, distmatrix))119 return false;120 121 117 //remove duplicates from old tours 122 118 for (int i = 0; i < newTour.Cities.Count; i++) { … … 137 133 solution.Tours.Remove(tour); 138 134 } 135 136 if (!newTour.Feasible( 137 dueTime, serviceTime, readyTime, demand, capacity, distmatrix)) 138 return false; 139 139 140 140 //route unrouted vehicles -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinInsertionBasedCrossover.cs
r6448 r6455 26 26 using HeuristicLab.Data; 27 27 using System; 28 using HeuristicLab.Parameters; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { 30 [Item("PotvinInsertionBasedCrossover", "The IBX crossover for VRP representations. ")]31 [Item("PotvinInsertionBasedCrossover", "The IBX crossover for VRP representations. It is implemented as described in Berger, J and Solois, M and Begin, R (1998). A hybrid genetic algorithm for the vehicle routing problem with time windows. LNCS 1418. Springer, London 114-127.")] 31 32 [StorableClass] 32 33 public sealed class PotvinInsertionBasedCrossover : PotvinCrossover { 34 public IValueParameter<IntValue> Length { 35 get { return (IValueParameter<IntValue>)Parameters["Length"]; } 36 } 37 33 38 [StorableConstructor] 34 39 private PotvinInsertionBasedCrossover(bool deserializing) : base(deserializing) { } … … 40 45 } 41 46 public PotvinInsertionBasedCrossover() 42 : base() { } 47 : base() { 48 Parameters.Add(new ValueParameter<IntValue>("Length", "The maximum length of the replaced route.", new IntValue(1))); 49 } 43 50 44 51 protected static int SelectRandomTourBiasedByLength(IRandom random, PotvinEncoding individual) { … … 199 206 PotvinEncoding p1Clone = parent1.Clone() as PotvinEncoding; 200 207 201 int k = 1;//random.Next(1, Math.Min(10, parent1.Tours.Count + 1)); 208 int length = Math.Min(Length.Value.Value, parent1.Tours.Count) + 1; 209 int k = random.Next(1, length); 202 210 for (int i = 0; i < k; i++) { 203 211 int index = SelectRandomTourBiasedByLength(random, p1Clone); … … 254 262 child.Tours.Add(childTour); 255 263 if (!Repair(random, child, childTour, distMatrix, dueTime, readyTime, serviceTime, demand, capacity)) { 256 / /success = false;257 //break;264 /*success = false; 265 break;*/ 258 266 } 259 267 } … … 264 272 child.Tours.Add(childTour); 265 273 if (!Repair(random, child, childTour, distMatrix, dueTime, readyTime, serviceTime, demand, capacity)) { 266 / /success = false;267 //break;274 /*success = false; 275 break;*/ 268 276 } 269 277 } … … 285 293 return child; 286 294 else { 287 /*if (random.NextDouble() < 0.5)295 if (random.NextDouble() < 0.5) 288 296 return parent1.Clone() as PotvinEncoding; 289 297 else 290 return parent2.Clone() as PotvinEncoding; */ 291 return child; 298 return parent2.Clone() as PotvinEncoding; 292 299 } 293 300 }
Note: See TracChangeset
for help on using the changeset viewer.