Changeset 4186 for trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/SequenceBasedCrossover.cs
- Timestamp:
- 08/10/10 17:40:41 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/SequenceBasedCrossover.cs
r4179 r4186 35 35 public SequenceBasedCrossover() 36 36 : base() { } 37 38 private Tour FindRoute(PotvinEncoding solution, int city) { 39 Tour found = null; 40 41 foreach (Tour tour in solution.Tours) { 42 if (tour.Cities.Contains(city)) { 43 found = tour; 44 break; 45 } 46 } 47 48 return found; 49 } 50 37 51 38 protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) { 52 39 PotvinEncoding child = parent1.Clone() as PotvinEncoding; … … 78 65 child.Unrouted.Add(city); 79 66 80 if (Repair(random, child, newTour)) 67 if (Feasible(newTour) && 68 Repair(random, child, newTour)) { 81 69 return child; 82 else {83 if (random.NextDouble() < 0.5)70 } else { 71 if (random.NextDouble() < 0.5) 84 72 return parent1.Clone() as PotvinEncoding; 85 73 else
Note: See TracChangeset
for help on using the changeset viewer.