- Timestamp:
- 06/20/11 13:36:49 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Prins
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Prins/Crossovers/PrinsPermutationCrossover.cs
r5445 r6449 46 46 47 47 protected override PrinsEncoding Crossover(IRandom random, PrinsEncoding parent1, PrinsEncoding parent2) { 48 //note - the inner crossover is called here and the resultis converted to a prins representation48 //note - the inner crossover is called here and the solution is converted to a prins representation 49 49 //some refactoring should be done here in the future - the crossover operation should be called directly 50 50 51 InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName; 52 IAtomicOperation op = this.ExecutionContext.CreateOperation( 53 InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope); 54 op.Operator.Execute((IExecutionContext)op, CancellationToken); 51 if (parent1.Length == parent2.Length) { 52 InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName; 53 IAtomicOperation op = this.ExecutionContext.CreateOperation( 54 InnerCrossoverParameter.ActualValue, this.ExecutionContext.Scope); 55 op.Operator.Execute((IExecutionContext)op, CancellationToken); 55 56 56 string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName;57 if (ExecutionContext.Scope.Variables.ContainsKey(childName)) {58 Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation;59 ExecutionContext.Scope.Variables.Remove(childName);57 string childName = InnerCrossoverParameter.ActualValue.ChildParameter.ActualName; 58 if (ExecutionContext.Scope.Variables.ContainsKey(childName)) { 59 Permutation permutation = ExecutionContext.Scope.Variables[childName].Value as Permutation; 60 ExecutionContext.Scope.Variables.Remove(childName); 60 61 61 return new PrinsEncoding(permutation, Cities, 62 DueTimeParameter.ActualValue, 63 ServiceTimeParameter.ActualValue, 64 ReadyTimeParameter.ActualValue, 65 DemandParameter.ActualValue, 66 CapacityParameter.ActualValue, 67 FleetUsageFactor.ActualValue, 68 TimeFactor.ActualValue, 69 DistanceFactor.ActualValue, 70 OverloadPenalty.ActualValue, 71 TardinessPenalty.ActualValue, 72 CoordinatesParameter.ActualValue, 73 UseDistanceMatrixParameter.ActualValue); 74 } else 75 return null; 62 return new PrinsEncoding(permutation, Cities, 63 DueTimeParameter.ActualValue, 64 ServiceTimeParameter.ActualValue, 65 ReadyTimeParameter.ActualValue, 66 DemandParameter.ActualValue, 67 CapacityParameter.ActualValue, 68 FleetUsageFactor.ActualValue, 69 TimeFactor.ActualValue, 70 DistanceFactor.ActualValue, 71 OverloadPenalty.ActualValue, 72 TardinessPenalty.ActualValue, 73 CoordinatesParameter.ActualValue, 74 UseDistanceMatrixParameter.ActualValue); 75 } else 76 return null; 77 } else { 78 return parent1.Clone() as PrinsEncoding; 79 } 76 80 } 77 81 } -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Prins/PrinsEncoding.cs
r5445 r6449 75 75 public override List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix, int maxVehicles = int.MaxValue) { 76 76 List<Tour> result = new List<Tour>(); 77 78 DistanceMatrix distMatrix = VRPUtilities.GetDistanceMatrix(coordinates, distanceMatrix, useDistanceMatrix); 77 79 78 80 //Split permutation into vector P … … 106 108 overloadPenalty, 107 109 tardinessPenalty, 108 coordinates, 109 distanceMatrix, 110 useDistanceMatrix); 110 distMatrix); 111 111 112 112 double cost = eval.Quality;
Note: See TracChangeset
for help on using the changeset viewer.