Changeset 9750 for branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape.VRP/Manipulators/OrOptManipulator.cs
- Timestamp:
- 07/25/13 09:21:45 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape.VRP/Manipulators/OrOptManipulator.cs
r7159 r9750 48 48 49 49 public static void Apply(IRandom random, PotvinEncoding individual) { 50 List<Tour> tours = individual.Tours.FindAll(t => t. Cities.Count >= 2);50 List<Tour> tours = individual.Tours.FindAll(t => t.Stops.Count >= 2); 51 51 52 52 if (tours.Count > 0) { … … 54 54 Tour tour = tours[tourIdx]; 55 55 56 int segmentStart = random.Next(tour. Cities.Count);56 int segmentStart = random.Next(tour.Stops.Count); 57 57 int segmentLength; 58 58 if (segmentStart == 0) { 59 segmentLength = 1 + random.Next(tour. Cities.Count - 1);59 segmentLength = 1 + random.Next(tour.Stops.Count - 1); 60 60 } else { 61 segmentLength = 1 + random.Next(tour. Cities.Count - segmentStart);61 segmentLength = 1 + random.Next(tour.Stops.Count - segmentStart); 62 62 } 63 63 64 List<int> segment = tour. Cities.GetRange(segmentStart, segmentLength);65 tour. Cities.RemoveRange(segmentStart, segmentLength);64 List<int> segment = tour.Stops.GetRange(segmentStart, segmentLength); 65 tour.Stops.RemoveRange(segmentStart, segmentLength); 66 66 int newPos; 67 if (tour.Cities.Count == 1)67 if (tour.Stops.Count == 1) 68 68 newPos = 0; 69 69 else 70 newPos = random.Next(tour. Cities.Count - 1);70 newPos = random.Next(tour.Stops.Count - 1); 71 71 72 72 if (newPos >= segmentStart) 73 73 newPos++; 74 tour. Cities.InsertRange(newPos, segment);74 tour.Stops.InsertRange(newPos, segment); 75 75 } 76 76 }
Note: See TracChangeset
for help on using the changeset viewer.