- Timestamp:
- 11/06/10 01:56:04 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/CloningRefactoring (added) merged: 4656-4693,4696-4697,4711-4714,4718-4719
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed
/branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting (added) merged: 4686-4687,4689-4693,4696-4697
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs
r4352 r4722 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 22 24 using HeuristicLab.Core; 23 using HeuristicLab. Encodings.PermutationEncoding;25 using HeuristicLab.Optimization; 24 26 using HeuristicLab.Parameters; 25 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 using HeuristicLab.Optimization;28 using System.Collections.Generic;29 28 30 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 38 37 [StorableConstructor] 39 38 protected PotvinCrossover(bool deserializing) : base(deserializing) { } 39 protected PotvinCrossover(PotvinCrossover original, Cloner cloner) 40 : base(original, cloner) { 41 } 40 42 41 43 public PotvinCrossover() { … … 68 70 protected bool Repair(IRandom random, PotvinEncoding solution, Tour newTour) { 69 71 bool success = true; 70 72 71 73 //remove duplicates from new tour 72 74 for (int i = 0; i < newTour.Cities.Count; i++) { … … 80 82 } 81 83 } 82 while (newTour.Cities.Contains(0))84 while (newTour.Cities.Contains(0)) 83 85 newTour.Cities.Remove(0); 84 86 … … 108 110 109 111 int route, place; 110 if (FindInsertionPlace(solution, unrouted, out route, out place)) {112 if (FindInsertionPlace(solution, unrouted, out route, out place)) { 111 113 solution.Tours[route].Cities.Insert(place, unrouted); 112 114 } else { -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs
r4352 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding;24 using HeuristicLab.Parameters;25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 25 28 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 32 30 [StorableConstructor] 33 31 private PotvinRouteBasedCrossover(bool deserializing) : base(deserializing) { } 34 32 private PotvinRouteBasedCrossover(PotvinRouteBasedCrossover original, Cloner cloner) 33 : base(original, cloner) { 34 } 35 public override IDeepCloneable Clone(Cloner cloner) { 36 return new PotvinRouteBasedCrossover(this, cloner); 37 } 35 38 public PotvinRouteBasedCrossover() 36 39 : base() { } 37 40 38 41 protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) { 39 42 PotvinEncoding child = parent2.Clone() as PotvinEncoding; … … 55 58 return child; 56 59 else { 57 if (random.NextDouble() < 0.5)60 if (random.NextDouble() < 0.5) 58 61 return parent1.Clone() as PotvinEncoding; 59 62 else -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs
r4352 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding;24 using HeuristicLab.Parameters;25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 25 28 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 32 30 [StorableConstructor] 33 31 private PotvinSequenceBasedCrossover(bool deserializing) : base(deserializing) { } 32 private PotvinSequenceBasedCrossover(PotvinSequenceBasedCrossover original, Cloner cloner) 33 : base(original, cloner) { 34 } 35 public override IDeepCloneable Clone(Cloner cloner) { 36 return new PotvinSequenceBasedCrossover(this, cloner); 37 } 34 38 35 39 public PotvinSequenceBasedCrossover() 36 40 : base() { } 37 41 38 42 protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) { 39 43 PotvinEncoding child = parent1.Clone() as PotvinEncoding; -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinLocalSearchManipulator.cs
r4352 r4722 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 22 24 using HeuristicLab.Core; 23 using HeuristicLab. Encodings.PermutationEncoding;25 using HeuristicLab.Data; 24 26 using HeuristicLab.Parameters; 25 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 using System.Collections.Generic;28 28 29 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 37 37 [StorableConstructor] 38 38 private PotvinLocalSearchManipulator(bool deserializing) : base(deserializing) { } 39 40 public PotvinLocalSearchManipulator() : base() { 39 private PotvinLocalSearchManipulator(PotvinLocalSearchManipulator original, Cloner cloner) 40 : base(original, cloner) { 41 } 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new PotvinLocalSearchManipulator(this, cloner); 44 } 45 public PotvinLocalSearchManipulator() 46 : base() { 41 47 Parameters.Add(new ValueParameter<IntValue>("Iterations", "The number of max iterations.", new IntValue(100))); 42 48 } … … 71 77 } 72 78 individual.Tours[currentTour].Cities.RemoveRange(currentCity, length); 73 79 74 80 currentCity++; 75 81 } … … 106 112 individual.Tours[insertionTour].Cities.InsertRange( 107 113 insertionPlace, 108 toBeInserted); 114 toBeInserted); 109 115 } 110 116 city++; … … 115 121 } 116 122 iterations++; 117 } while (insertionFound && 123 } while (insertionFound && 118 124 iterations < Iterations.Value.Value); 119 125 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs
r4352 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab. Encodings.PermutationEncoding;24 using HeuristicLab.Optimization; 24 25 using HeuristicLab.Parameters; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 using HeuristicLab.Optimization;28 27 29 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 37 36 [StorableConstructor] 38 37 protected PotvinManipulator(bool deserializing) : base(deserializing) { } 39 38 protected PotvinManipulator(PotvinManipulator original, Cloner cloner) 39 : base(original, cloner) { 40 } 40 41 public PotvinManipulator() { 41 42 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); … … 73 74 protected bool FindInsertionPlace(PotvinEncoding individual, int city, int routeToAvoid, out int route, out int place) { 74 75 return individual.FindInsertionPlace( 75 DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue, 76 DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue, 76 DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue, 77 DemandParameter.ActualValue, CapacityParameter.ActualValue, CoordinatesParameter.ActualValue, 77 78 DistanceMatrixParameter, UseDistanceMatrixParameter.ActualValue, 78 79 city, routeToAvoid, out route, out place); 79 80 } 80 81 81 82 public override IOperation Apply() { 82 83 IVRPEncoding solution = VRPToursParameter.ActualValue; … … 84 85 VRPToursParameter.ActualValue = PotvinEncoding.ConvertFrom(solution, DistanceMatrixParameter); 85 86 } 86 87 87 88 Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as PotvinEncoding); 88 89 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinOneLevelExchangeManipulator.cs
r4352 r4722 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 22 24 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding;24 using HeuristicLab.Parameters;25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 using System.Collections.Generic;28 26 29 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 33 31 [StorableConstructor] 34 32 private PotvinOneLevelExchangeMainpulator(bool deserializing) : base(deserializing) { } 33 private PotvinOneLevelExchangeMainpulator(PotvinOneLevelExchangeMainpulator original, Cloner cloner) 34 : base(original, cloner) { 35 } 36 public override IDeepCloneable Clone(Cloner cloner) { 37 return new PotvinOneLevelExchangeMainpulator(this, cloner); 38 } 39 public PotvinOneLevelExchangeMainpulator() : base() { } 35 40 36 public PotvinOneLevelExchangeMainpulator() : base() { }37 38 41 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 39 42 int selectedIndex = SelectRandomTourBiasedByLength(random, individual); … … 52 55 53 56 route1.Cities.RemoveAll( 54 new System.Predicate<int>( 57 new System.Predicate<int>( 55 58 delegate(int val) { 56 return (replaced.Contains(val)); 59 return (replaced.Contains(val)); 57 60 } 58 61 ) -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinTwoLevelExchangeManipulator.cs
r4352 r4722 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding;24 using HeuristicLab.Parameters;25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 using System.Collections.Generic;28 25 29 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 33 30 [StorableConstructor] 34 31 private PotvinTwoLevelExchangeManipulator(bool deserializing) : base(deserializing) { } 32 private PotvinTwoLevelExchangeManipulator(PotvinTwoLevelExchangeManipulator original, Cloner cloner) : base(original, cloner) { } 33 public override IDeepCloneable Clone(Cloner cloner) { 34 return new PotvinTwoLevelExchangeManipulator(this, cloner); 35 } 36 public PotvinTwoLevelExchangeManipulator() : base() { } 35 37 36 public PotvinTwoLevelExchangeManipulator() : base() { }37 38 38 protected override void Manipulate(IRandom random, PotvinEncoding individual) { 39 39 int selectedIndex = SelectRandomTourBiasedByLength(random, individual); … … 54 54 if (FindInsertionPlace(individual, 55 55 customer2, selectedIndex, out route, out place)) { 56 56 individual.Tours[route].Cities.Insert(place, customer2); 57 57 route1.Cities.RemoveAt(customer1Position); 58 58 -
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs
r4352 r4722 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.PermutationEncoding;26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using System.Drawing;28 using System.Collections.Generic;29 27 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 30 28 … … 32 30 [Item("PotvinEncoding", "Represents a potvin encoding of VRP solutions. It is implemented as described in Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172.")] 33 31 [StorableClass] 34 public class PotvinEncoding : TourEncoding { 32 public class PotvinEncoding : TourEncoding { 35 33 [Storable] 36 34 public List<int> Unrouted { get; set; } 37 35 38 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {39 PotvinEncoding clone = new PotvinEncoding();40 cloner.RegisterClonedObject(this, clone);41 clone.Tours = (ItemList<Tour>)cloner.Clone(this.Tours);42 clone.Unrouted = new List<int>(Unrouted);43 return clone;36 [StorableConstructor] 37 protected PotvinEncoding(bool deserializing) : base(deserializing) { } 38 protected PotvinEncoding(PotvinEncoding original, Cloner cloner) 39 : base(original, cloner) { 40 Tours = cloner.Clone(original.Tours); 41 Unrouted = new List<int>(original.Unrouted); 44 42 } 45 46 public PotvinEncoding(): base() {43 public PotvinEncoding() 44 : base() { 47 45 Unrouted = new List<int>(); 48 46 } 49 47 50 [StorableConstructor] 51 private PotvinEncoding(bool serializing) 52 : base() { 48 public override IDeepCloneable Clone(Cloner cloner) { 49 return new PotvinEncoding(this, cloner); 53 50 } 54 51 55 52 public static PotvinEncoding ConvertFrom(IVRPEncoding encoding, ILookupParameter<DoubleMatrix> distanceMatrix) { 56 53 PotvinEncoding solution = new PotvinEncoding(); … … 85 82 Tours[tour].Cities.Insert(i, city); 86 83 87 if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, 84 if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, 88 85 capacity, coordinates, distanceMatrix, useDistanceMatrix)) { 89 86 double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix); 90 87 91 88 double detour = newLength - length;
Note: See TracChangeset
for help on using the changeset viewer.