Changeset 5201 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/LambdaInterchange/AlbaStochasticLambdaInterchangeSingleMoveGenerator.cs
- Timestamp:
- 01/03/11 16:18:37 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Moves/LambdaInterchange/AlbaStochasticLambdaInterchangeSingleMoveGenerator.cs
r4752 r5201 67 67 List<Tour> tours = individual.GetTours(); 68 68 69 int route1Index = rand.Next(tours.Count); 70 Tour route1 = tours[route1Index]; 69 if (tours.Count > 1) { 70 int route1Index = rand.Next(tours.Count); 71 Tour route1 = tours[route1Index]; 71 72 72 int route2Index = rand.Next(tours.Count - 1); 73 if (route2Index >= route1Index) 74 route2Index += 1; 75 Tour route2 = tours[route2Index]; 73 int route2Index = rand.Next(tours.Count - 1); 74 if (route2Index >= route1Index) 75 route2Index += 1; 76 76 77 int length1 = rand.Next(Math.Min(lambda + 1, route1.Stops.Count + 1)); 78 int index1 = rand.Next(route1.Stops.Count - length1 + 1); 77 Tour route2 = tours[route2Index]; 79 78 80 int l2Min = 0; 81 if (length1 == 0) 82 l2Min = 1; 83 int length2 = rand.Next(l2Min, Math.Min(lambda + 1, route2.Stops.Count + 1)); 84 int index2 = rand.Next(route2.Stops.Count - length2 + 1); 79 int length1 = rand.Next(Math.Min(lambda + 1, route1.Stops.Count + 1)); 80 int index1 = rand.Next(route1.Stops.Count - length1 + 1); 85 81 86 return new AlbaLambdaInterchangeMove(route1Index, index1, length1, route2Index, index2, length2, individual); 82 int l2Min = 0; 83 if (length1 == 0) 84 l2Min = 1; 85 int length2 = rand.Next(l2Min, Math.Min(lambda + 1, route2.Stops.Count + 1)); 86 int index2 = rand.Next(route2.Stops.Count - length2 + 1); 87 88 return new AlbaLambdaInterchangeMove(route1Index, index1, length1, route2Index, index2, length2, individual); 89 } else { 90 return new AlbaLambdaInterchangeMove(0, 0, 0, 0, 0, 0, individual); 91 } 87 92 } 88 93
Note: See TracChangeset
for help on using the changeset viewer.