- Timestamp:
- 08/16/10 15:20:29 (14 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/AlbaEncoding.cs
r4204 r4230 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 using System.Collections.Generic; 28 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 35 36 36 37 #region IVRPEncoding Members 37 public ItemList<Tour> Tours { 38 get { 39 ItemList<Tour> result = new ItemList<Tour>(); 40 41 Tour tour = new Tour(); 42 for (int i = 0; i < this.array.Length; i++) { 43 if (this.array[i] >= cities) { 44 if (tour.Cities.Count > 0) { 45 result.Add(tour); 38 public List<Tour> GetTours() { 39 List<Tour> result = new List<Tour>(); 46 40 47 tour = new Tour(); 48 } 49 } else { 50 tour.Cities.Add(this.array[i] + 1); 41 Tour tour = new Tour(); 42 for (int i = 0; i < this.array.Length; i++) { 43 if (this.array[i] >= cities) { 44 if (tour.Cities.Count > 0) { 45 result.Add(tour); 46 47 tour = new Tour(); 51 48 } 49 } else { 50 tour.Cities.Add(this.array[i] + 1); 52 51 } 52 } 53 53 54 55 56 54 if (tour.Cities.Count > 0) { 55 result.Add(tour); 56 } 57 57 58 return result; 59 } 58 return result; 60 59 } 61 60 … … 93 92 94 93 public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, int vehicles) { 95 ItemList<Tour> tours = encoding.Tours;94 List<Tour> tours = encoding.GetTours(); 96 95 97 96 int cities = 0; -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/IntraRouteInversionManipulator.cs
r4206 r4230 56 56 57 57 List<Tour> validTours = new List<Tour>(); 58 foreach (Tour tour in individual. Tours) {58 foreach (Tour tour in individual.GetTours()) { 59 59 if (tour.Cities.Count >= 4) 60 60 validTours.Add(tour); -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/LambdaInterchangeManipulator.cs
r4206 r4230 26 26 using HeuristicLab.Data; 27 27 using System; 28 using System.Collections.Generic; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 45 46 public static void Apply(AlbaEncoding individual, int tour1Index, int position1, int length1, 46 47 int tour2Index, int position2, int length2) { 47 Tour tour1 = individual.Tours[tour1Index]; 48 List<Tour> tours = individual.GetTours(); 49 50 Tour tour1 = tours[tour1Index]; 48 51 int tour1Start = -1; 49 52 for (int i = 0; i < individual.Length; i++) { … … 54 57 } 55 58 56 Tour tour2 = individual.Tours[tour2Index];59 Tour tour2 = tours[tour2Index]; 57 60 int tour2Start = -1; 58 61 for (int i = 0; i < individual.Length; i++) { … … 96 99 97 100 protected override void Manipulate(IRandom rand, AlbaEncoding individual) { 101 List<Tour> tours = individual.GetTours(); 98 102 int lambda = LambdaParameter.Value.Value; 99 100 int route1Index = rand.Next(individual.Tours.Count);101 Tour route1 = individual.Tours[route1Index];102 103 103 int route2Index = rand.Next(individual.Tours.Count - 1); 104 int route1Index = rand.Next(tours.Count); 105 Tour route1 = tours[route1Index]; 106 107 int route2Index = rand.Next(tours.Count - 1); 104 108 if (route2Index >= route1Index) 105 109 route2Index += 1; 106 Tour route2 = individual.Tours[route2Index];110 Tour route2 = tours[route2Index]; 107 111 108 112 int length1 = rand.Next(Math.Min(lambda + 1, route1.Cities.Count + 1)); -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/StochasticIntraRouteInversionSingleMoveGenerator.cs
r4206 r4230 59 59 60 60 List<Tour> validTours = new List<Tour>(); 61 foreach (Tour tour in individual. Tours) {61 foreach (Tour tour in individual.GetTours()) { 62 62 if (tour.Cities.Count >= 4) 63 63 validTours.Add(tour); -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/ExhaustiveLambdaInterchangeMoveGenerator.cs
r4206 r4230 42 42 List<LambdaInterchangeMove> moves = new List<LambdaInterchangeMove>(); 43 43 44 for (int tour1Index = 0; tour1Index < individual.Tours.Count; tour1Index++) { 45 Tour tour1 = individual.Tours[tour1Index]; 46 for (int tour2Index = tour1Index + 1; tour2Index < individual.Tours.Count; tour2Index++) { 47 Tour tour2 = individual.Tours[tour2Index]; 44 List<Tour> tours = individual.GetTours(); 45 46 for (int tour1Index = 0; tour1Index < tours.Count; tour1Index++) { 47 Tour tour1 = tours[tour1Index]; 48 for (int tour2Index = tour1Index + 1; tour2Index < tours.Count; tour2Index++) { 49 Tour tour2 = tours[tour2Index]; 48 50 49 51 for (int length1 = 0; length1 <= Math.Min(lambda, tour1.Cities.Count); length1++) { -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/StochasticLambdaInterchangeSingleMoveGenerator.cs
r4206 r4230 55 55 56 56 public static LambdaInterchangeMove Apply(AlbaEncoding individual, int cities, int lambda, IRandom rand) { 57 int route1Index = rand.Next(individual.Tours.Count); 58 Tour route1 = individual.Tours[route1Index]; 57 List<Tour> tours = individual.GetTours(); 59 58 60 int route2Index = rand.Next(individual.Tours.Count - 1); 59 int route1Index = rand.Next(tours.Count); 60 Tour route1 = tours[route1Index]; 61 62 int route2Index = rand.Next(tours.Count - 1); 61 63 if (route2Index >= route1Index) 62 64 route2Index += 1; 63 Tour route2 = individual.Tours[route2Index];65 Tour route2 = tours[route2Index]; 64 66 65 67 int length1 = rand.Next(Math.Min(lambda + 1, route1.Cities.Count + 1));
Note: See TracChangeset
for help on using the changeset viewer.