Changeset 4752 for branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators
- Timestamp:
- 11/09/10 09:55:31 (14 years ago)
- Location:
- branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaCustomerInsertionManipulator.cs
r4365 r4752 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 using HeuristicLab.Data; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 35 36 public AlbaCustomerInsertionManipulator() 36 37 : base() { 38 } 39 40 public override IDeepCloneable Clone(Cloner cloner) { 41 return new AlbaCustomerInsertionManipulator(this, cloner); 42 } 43 44 private AlbaCustomerInsertionManipulator(AlbaCustomerInsertionManipulator original, Cloner cloner) 45 : base(original, cloner) { 37 46 } 38 47 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaCustomerInversionManipulator.cs
r4365 r4752 26 26 using HeuristicLab.Data; 27 27 using System.Collections.Generic; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 36 37 public AlbaCustomerInversionManipulator() 37 38 : base() { 39 } 40 41 public override IDeepCloneable Clone(Cloner cloner) { 42 return new AlbaCustomerInversionManipulator(this, cloner); 43 } 44 45 private AlbaCustomerInversionManipulator(AlbaCustomerInversionManipulator original, Cloner cloner) 46 : base(original, cloner) { 38 47 } 39 48 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaCustomerSwapManipulator.cs
r4365 r4752 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 using HeuristicLab.Data; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 35 36 public AlbaCustomerSwapManipulator() 36 37 : base() { 38 } 39 40 public override IDeepCloneable Clone(Cloner cloner) { 41 return new AlbaCustomerSwapManipulator(this, cloner); 42 } 43 44 private AlbaCustomerSwapManipulator(AlbaCustomerSwapManipulator original, Cloner cloner) 45 : base(original, cloner) { 37 46 } 38 47 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaIntraRouteInversionManipulator.cs
r4365 r4752 27 27 using System; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 38 39 : base() { 39 40 } 41 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new AlbaIntraRouteInversionManipulator(this, cloner); 44 } 45 46 private AlbaIntraRouteInversionManipulator(AlbaIntraRouteInversionManipulator original, Cloner cloner) 47 : base(original, cloner) { 48 } 40 49 41 50 public static void Apply(AlbaEncoding individual, int index1, int index2) { -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaLambdaInterchangeManipulator.cs
r4365 r4752 27 27 using System; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 43 44 Parameters.Add(new ValueParameter<IntValue>("Lambda", "The lambda value.", new IntValue(1))); 44 45 } 46 47 public override IDeepCloneable Clone(Cloner cloner) { 48 return new AlbaLambdaInterchangeManipulator(this, cloner); 49 } 50 51 private AlbaLambdaInterchangeManipulator(AlbaLambdaInterchangeManipulator original, Cloner cloner) 52 : base(original, cloner) { 53 } 45 54 46 55 public static void Apply(AlbaEncoding individual, int tour1Index, int position1, int length1, … … 100 109 protected override void Manipulate(IRandom rand, AlbaEncoding individual) { 101 110 List<Tour> tours = individual.GetTours(); 102 int lambda = LambdaParameter.Value.Value; 111 if (tours.Count > 1) { 112 int lambda = LambdaParameter.Value.Value; 103 113 104 int route1Index = rand.Next(tours.Count);105 Tour route1 = tours[route1Index];114 int route1Index = rand.Next(tours.Count); 115 Tour route1 = tours[route1Index]; 106 116 107 int route2Index = rand.Next(tours.Count - 1);108 if (route2Index >= route1Index)109 route2Index += 1;110 Tour route2 = tours[route2Index];111 117 112 int length1 = rand.Next(Math.Min(lambda + 1, route1.Stops.Count + 1)); 113 int index1 = rand.Next(route1.Stops.Count - length1 + 1); 118 int route2Index = rand.Next(tours.Count - 1); 119 if (route2Index >= route1Index) 120 route2Index += 1; 121 Tour route2 = tours[route2Index]; 114 122 115 int l2Min = 0; 116 if (length1 == 0) 117 l2Min = 1; 118 int length2 = rand.Next(l2Min, Math.Min(lambda + 1, route2.Stops.Count + 1)); 119 int index2 = rand.Next(route2.Stops.Count - length2 + 1); 123 int length1 = rand.Next(Math.Min(lambda + 1, route1.Stops.Count + 1)); 124 int index1 = rand.Next(route1.Stops.Count - length1 + 1); 120 125 121 Apply(individual, route1Index, index1, length1, 122 route2Index, index2, length2); 126 int l2Min = 0; 127 if (length1 == 0) 128 l2Min = 1; 129 int length2 = rand.Next(l2Min, Math.Min(lambda + 1, route2.Stops.Count + 1)); 130 int index2 = rand.Next(route2.Stops.Count - length2 + 1); 131 132 Apply(individual, route1Index, index1, length1, 133 route2Index, index2, length2); 134 } 123 135 } 124 136 } -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaManipulator.cs
r4376 r4752 28 28 using HeuristicLab.Problems.VehicleRouting.Interfaces; 29 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 30 using HeuristicLab.Common; 30 31 31 32 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 43 44 : base() { 44 45 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 46 } 47 48 protected AlbaManipulator(AlbaManipulator original, Cloner cloner) 49 : base(original, cloner) { 45 50 } 46 51 -
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Manipulators/AlbaPermutationManipulator.cs
r4365 r4752 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 using HeuristicLab.Data; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 42 43 } 43 44 45 public override IDeepCloneable Clone(Cloner cloner) { 46 return new AlbaPermutationManipualtor(this, cloner); 47 } 48 49 private AlbaPermutationManipualtor(AlbaPermutationManipualtor original, Cloner cloner) 50 : base(original, cloner) { 51 } 52 44 53 protected override void Manipulate(IRandom random, AlbaEncoding individual) { 45 54 InnerManipulatorParameter.ActualValue.PermutationParameter.ActualName = VRPToursParameter.ActualName;
Note: See TracChangeset
for help on using the changeset viewer.