- Timestamp:
- 09/01/10 11:13:46 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting
- Files:
-
- 28 deleted
- 8 edited
- 28 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting
-
Property
svn:mergeinfo
set to
/branches/VRP/HeuristicLab.Problems.VehicleRouting merged eligible
-
Property
svn:mergeinfo
set to
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/AlbaEncoding.cs
r4204 r4352 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 { 30 31 [Item("AlbaEncoding", "Represents an Alba encoding of VRP solutions. It is implemented as described in Alba, E. and Dorronsoro, B. (2004). Solving the Vehicle Routing Problem by Using Cellular Genetic Algorithms.")] 31 32 [StorableClass] 32 public class AlbaEncoding : Permutation , IVRPEncoding {33 public class AlbaEncoding : PermutationEncoding { 33 34 [Storable] 34 35 private int cities; 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 override List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix = null, int maxVehicles = int.MaxValue) { 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 … … 65 64 66 65 public int MaxVehicles { 67 get { return Length - Cities ; }66 get { return Length - Cities + 1; } 68 67 } 69 68 … … 79 78 80 79 public AlbaEncoding(Permutation permutation, int cities) 81 : base(PermutationTypes.RelativeUndirected) { 82 this.array = new int[permutation.Length]; 83 for (int i = 0; i < array.Length; i++) 84 this.array[i] = permutation[i]; 85 80 : base(permutation) { 86 81 this.cities = cities; 87 82 } … … 89 84 [StorableConstructor] 90 85 private AlbaEncoding(bool serializing) 91 : base( ) {86 : base(serializing) { 92 87 } 93 88 94 public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, int vehicles ) {95 ItemList<Tour> tours = encoding.Tours;89 public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, int vehicles, ILookupParameter<DoubleMatrix> distanceMatrix) { 90 List<Tour> tours = encoding.GetTours(distanceMatrix, vehicles); 96 91 97 92 int cities = 0; … … 132 127 public static AlbaEncoding ConvertFrom(List<int> routeParam) { 133 128 List<int> route = new List<int>(routeParam); 129 route.RemoveAt(routeParam.Count - 1); 134 130 135 131 int cities = 0; … … 156 152 157 153 internal static void RemoveUnusedParameters(ParameterCollection parameters) { 158 parameters.Remove("DistanceMatrix");159 154 parameters.Remove("UseDistanceMatrix"); 160 155 parameters.Remove("Capacity"); -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaCrossover.cs
r4206 r4352 53 53 54 54 if (!(solution is AlbaEncoding)) { 55 parents[i] = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value); 55 parents[i] = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value, 56 DistanceMatrixParameter); 56 57 } else { 57 58 parents[i] = solution; -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaManipulator.cs
r4206 r4352 62 62 IVRPEncoding solution = VRPToursParameter.ActualValue; 63 63 if (!(solution is AlbaEncoding)) { 64 VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value );64 VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value, DistanceMatrixParameter); 65 65 } 66 66 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveMaker.cs
r4208 r4352 26 26 27 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 28 [Item(" PermutationTranslocationMoveMaker", "An operator which makes translocation moves for the Alba representation.")]28 [Item("AlbaTranslocationMoveMaker", "An operator which makes translocation moves for the Alba representation.")] 29 29 [StorableClass] 30 30 public abstract class AlbaMoveMaker : AlbaMoveOperator { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveOperator.cs
r4204 r4352 41 41 IVRPEncoding solution = VRPToursParameter.ActualValue; 42 42 if (!(solution is AlbaEncoding)) { 43 VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value); 43 VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value, 44 DistanceMatrixParameter); 44 45 } 45 46 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/Interfaces/IAlbaIntraRouteInversionMoveOperator.cs
r4206 r4352 26 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 27 27 public interface IAlbaIntraRouteInversionMoveOperator : IVRPMoveOperator { 28 ILookupParameter< IntraRouteInversionMove> IntraRouteInversionMoveParameter { get; }28 ILookupParameter<AlbaIntraRouteInversionMove> IntraRouteInversionMoveParameter { get; } 29 29 } 30 30 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/Interfaces/IAlbaLambdaInterchangeMoveOperator.cs
r4204 r4352 26 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 27 27 public interface IAlbaLambdaInterchangeMoveOperator : IVRPMoveOperator { 28 ILookupParameter< LambdaInterchangeMove> LambdaInterchangeMoveParameter { get; }28 ILookupParameter<AlbaLambdaInterchangeMove> LambdaInterchangeMoveParameter { get; } 29 29 } 30 30 }
Note: See TracChangeset
for help on using the changeset viewer.