Changeset 4690 for branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba
- Timestamp:
- 10/29/10 20:30:20 (14 years ago)
- Location:
- branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/AlbaEncoding.cs
r4352 r4690 34 34 [Storable] 35 35 private int cities; 36 36 37 37 #region IVRPEncoding Members 38 38 public override List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix = null, int maxVehicles = int.MaxValue) { … … 64 64 65 65 public int MaxVehicles { 66 get { return Length - Cities + 1; 66 get { return Length - Cities + 1; } 67 67 } 68 68 69 69 #endregion 70 70 71 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) { 72 AlbaEncoding clone = new AlbaEncoding( 73 new Permutation(this.PermutationType, this.array), cities); 74 cloner.RegisterClonedObject(this, clone); 75 clone.readOnly = readOnly; 76 return clone; 71 72 [StorableConstructor] 73 protected AlbaEncoding(bool deserializing) : base(deserializing) { } 74 protected AlbaEncoding(AlbaEncoding original, Cloner cloner) 75 : base(original, cloner) { 76 cities = original.cities; 77 readOnly = original.readOnly; 77 78 } 78 79 … … 82 83 } 83 84 84 [StorableConstructor] 85 private AlbaEncoding(bool serializing) 86 : base(serializing) { 85 public override IDeepCloneable Clone(Cloner cloner) { 86 return new AlbaEncoding(this, cloner); 87 87 } 88 88 … … 103 103 foreach (Tour tour in tours) { 104 104 foreach (int city in tour.Cities) { 105 106 105 array[arrayIndex] = city - 1; 106 arrayIndex++; 107 107 } 108 108 … … 119 119 arrayIndex++; 120 120 } 121 121 122 122 AlbaEncoding solution = new AlbaEncoding(new Permutation(PermutationTypes.RelativeUndirected, new IntArray(array)), cities); 123 123 … … 128 128 List<int> route = new List<int>(routeParam); 129 129 route.RemoveAt(routeParam.Count - 1); 130 130 131 131 int cities = 0; 132 132 for (int i = 0; i < route.Count; i++) { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaCrossover.cs
r4352 r4690 26 26 using HeuristicLab.Data; 27 27 using HeuristicLab.Optimization; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 34 35 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 35 36 } 36 37 37 38 [StorableConstructor] 38 39 protected AlbaCrossover(bool deserializing) : base(deserializing) { } 39 40 protected AlbaCrossover(AlbaCrossover original, Cloner cloner) : base(original, cloner) { } 40 41 public AlbaCrossover() 41 42 : base() { 42 43 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 43 44 44 45 AlbaEncoding.RemoveUnusedParameters(Parameters); 45 46 } … … 61 62 ParentsParameter.ActualValue = parents; 62 63 63 ChildParameter.ActualValue = 64 ChildParameter.ActualValue = 64 65 Crossover(RandomParameter.ActualValue, parents[0] as AlbaEncoding, parents[1] as AlbaEncoding); 65 66 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaPermutationCrossover.cs
r4352 r4690 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 { … … 36 37 [StorableConstructor] 37 38 private AlbaPermutationCrossover(bool deserializing) : base(deserializing) { } 38 39 private AlbaPermutationCrossover(AlbaPermutationCrossover original, Cloner cloner) 40 : base(original, cloner) { 41 } 39 42 public AlbaPermutationCrossover() 40 43 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaCustomerInsertionManipulator.cs
r4352 r4690 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 { … … 32 33 [StorableConstructor] 33 34 private AlbaCustomerInsertionManipulator(bool deserializing) : base(deserializing) { } 34 35 private AlbaCustomerInsertionManipulator(AlbaCustomerInsertionManipulator original, Cloner cloner) 36 : base(original, cloner) { 37 } 35 38 public AlbaCustomerInsertionManipulator() 36 39 : base() { 40 } 41 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new AlbaCustomerInsertionManipulator(this, cloner); 37 44 } 38 45 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaCustomerInversionManipulator.cs
r4352 r4690 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 { … … 33 34 [StorableConstructor] 34 35 private AlbaCustomerInversionManipulator(bool deserializing) : base(deserializing) { } 35 36 private AlbaCustomerInversionManipulator(AlbaCustomerInversionManipulator original, Cloner cloner) 37 : base(original, cloner) { 38 } 36 39 public AlbaCustomerInversionManipulator() 37 40 : base() { 38 41 } 39 42 43 public override IDeepCloneable Clone(Cloner cloner) { 44 return new AlbaCustomerInversionManipulator(this, cloner); 45 } 40 46 protected override void Manipulate(IRandom random, AlbaEncoding individual) { 41 47 int breakPoint1, breakPoint2; -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaCustomerSwapManipulator.cs
r4352 r4690 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 { … … 32 33 [StorableConstructor] 33 34 private AlbaCustomerSwapManipulator(bool deserializing) : base(deserializing) { } 34 35 private AlbaCustomerSwapManipulator(AlbaCustomerSwapManipulator original, Cloner cloner) : base(original, cloner) { } 35 36 public AlbaCustomerSwapManipulator() 36 37 : base() { 38 } 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new AlbaCustomerSwapManipulator(this, cloner); 37 41 } 38 42 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaIntraRouteInversionManipulator.cs
r4352 r4690 27 27 using System; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 31 32 [Item("AlbaIntraRouteInversionManipulator", "An operator which applies the SLS operation to a VRP representation. It is implemented as described in Alba, E. and Dorronsoro, B. (2004). Solving the Vehicle Routing Problem by Using Cellular Genetic Algorithms.")] 32 33 [StorableClass] 33 public sealed class AlbaIntraRouteInversionManipulator : AlbaManipulator { 34 public sealed class AlbaIntraRouteInversionManipulator : AlbaManipulator { 34 35 [StorableConstructor] 35 36 private AlbaIntraRouteInversionManipulator(bool deserializing) : base(deserializing) { } 36 37 private AlbaIntraRouteInversionManipulator(AlbaIntraRouteInversionManipulator original, Cloner cloner) : base(original, cloner) { } 37 38 public AlbaIntraRouteInversionManipulator() 38 39 : base() { 39 } 40 } 41 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new AlbaIntraRouteInversionManipulator(this, cloner); 44 } 40 45 41 46 public static void Apply(AlbaEncoding individual, int index1, int index2) { … … 72 77 73 78 int currentTourEnd = currentTourStart; 74 while (currentTourEnd < individual.Length && 79 while (currentTourEnd < individual.Length && 75 80 individual[currentTourEnd] < individual.Cities) { 76 81 currentTourEnd++; -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaLambdaInterchangeManipulator.cs
r4352 r4690 27 27 using System; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 35 36 get { return (IValueParameter<IntValue>)Parameters["Lambda"]; } 36 37 } 37 38 38 39 [StorableConstructor] 39 40 private AlbaLambdaInterchangeManipulator(bool deserializing) : base(deserializing) { } 40 41 private AlbaLambdaInterchangeManipulator(AlbaLambdaInterchangeManipulator original, Cloner cloner) : base(original, cloner) { } 41 42 public AlbaLambdaInterchangeManipulator() 42 43 : base() { 43 44 44 Parameters.Add(new ValueParameter<IntValue>("Lambda", "The lambda value.", new IntValue(1))); 45 } 45 46 46 public static void Apply(AlbaEncoding individual, int tour1Index, int position1, int length1, 47 public override IDeepCloneable Clone(Cloner cloner) { 48 return new AlbaLambdaInterchangeManipulator(this, cloner); 49 } 50 51 public static void Apply(AlbaEncoding individual, int tour1Index, int position1, int length1, 47 52 int tour2Index, int position2, int length2) { 48 53 List<Tour> tours = individual.GetTours(); -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaManipulator.cs
r4352 r4690 26 26 using HeuristicLab.Data; 27 27 using HeuristicLab.Optimization; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 37 38 [StorableConstructor] 38 39 protected AlbaManipulator(bool deserializing) : base(deserializing) { } 39 40 protected AlbaManipulator(AlbaManipulator original, Cloner cloner) : base(original, cloner) { } 40 41 public AlbaManipulator() 41 42 : base() { 42 43 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 43 44 44 45 AlbaEncoding.RemoveUnusedParameters(Parameters); 45 46 } 46 47 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaPermutationManipulator.cs
r4416 r4690 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 { … … 36 37 [StorableConstructor] 37 38 private AlbaPermutationManipualtor(bool deserializing) : base(deserializing) { } 38 39 private AlbaPermutationManipualtor(AlbaPermutationManipualtor original, Cloner cloner) : base(original, cloner) { } 39 40 public AlbaPermutationManipualtor() 40 41 : base() { 41 Parameters.Add(new ValueLookupParameter<IPermutationManipulator>("InnerManipulator", "The permutation manipulator.", new TranslocationManipulator())); 42 Parameters.Add(new ValueLookupParameter<IPermutationManipulator>("InnerManipulator", "The permutation manipulator.", new TranslocationManipulator())); 43 } 44 45 public override IDeepCloneable Clone(Cloner cloner) { 46 return new AlbaPermutationManipualtor(this, cloner); 42 47 } 43 48 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveMaker.cs
r4352 r4690 24 24 using HeuristicLab.Parameters; 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Common; 26 27 27 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 60 61 get { return (ILookupParameter<DoubleValue>)Parameters["Tardiness"]; } 61 62 } 62 63 63 64 [StorableConstructor] 64 65 protected AlbaMoveMaker(bool deserializing) : base(deserializing) { } 65 66 protected AlbaMoveMaker(AlbaMoveMaker original, Cloner cloner) : base(original, cloner) { } 66 67 public AlbaMoveMaker() 67 68 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveOperator.cs
r4352 r4690 25 25 using HeuristicLab.Data; 26 26 using HeuristicLab.Parameters; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 29 30 [Item("AlbaMoveOperator", "A move operator for an Alba VRP representation.")] 30 31 [StorableClass] 31 public abstract class AlbaMoveOperator : VRPMoveOperator { 32 public abstract class AlbaMoveOperator : VRPMoveOperator { 32 33 [StorableConstructor] 33 34 protected AlbaMoveOperator(bool deserializing) : base(deserializing) { } 34 35 public AlbaMoveOperator() : base()36 {35 protected AlbaMoveOperator(AlbaMoveOperator original, Cloner cloner) : base(original, cloner) { } 36 public AlbaMoveOperator() 37 : base() { 37 38 AlbaEncoding.RemoveUnusedParameters(Parameters); 38 39 } … … 41 42 IVRPEncoding solution = VRPToursParameter.ActualValue; 42 43 if (!(solution is AlbaEncoding)) { 43 VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value, 44 VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value, 44 45 DistanceMatrixParameter); 45 46 } -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaPermutationMoveOperator.cs
r4352 r4690 25 25 using HeuristicLab.Data; 26 26 using HeuristicLab.Parameters; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { 29 30 [Item("AlbaPermutationMoveOperator", "A move operator for an Alba VRP representation using an inner permutation move operator.")] 30 31 [StorableClass] 31 public abstract class AlbaPermutationMoveOperator : AlbaMoveOperator { 32 public abstract class AlbaPermutationMoveOperator : AlbaMoveOperator { 32 33 [Storable] 33 34 protected abstract IPermutationMoveOperator PermutationMoveOperatorParameter { get; set; } … … 35 36 [StorableConstructor] 36 37 protected AlbaPermutationMoveOperator(bool deserializing) : base(deserializing) { } 37 38 protected AlbaPermutationMoveOperator(AlbaPermutationMoveOperator original, Cloner cloner) : base(original, cloner) { } 38 39 public AlbaPermutationMoveOperator() 39 : base() 40 { 40 : base() { 41 41 } 42 42 43 43 public override IOperation Apply() { 44 44 IOperation next = base.Apply(); 45 45 46 46 IVRPEncoding solution = VRPToursParameter.ActualValue; 47 47 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaExhaustiveIntraRouteInversionMoveGenerator.cs
r4352 r4690 27 27 using HeuristicLab.Parameters; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 34 35 [StorableConstructor] 35 36 private AlbaExhaustiveIntraRouteInversionGenerator(bool deserializing) : base(deserializing) { } 36 37 private AlbaExhaustiveIntraRouteInversionGenerator(AlbaExhaustiveIntraRouteInversionGenerator original, Cloner cloner) : base(original, cloner) { } 37 38 public AlbaExhaustiveIntraRouteInversionGenerator() 38 39 : base() { 40 } 41 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new AlbaExhaustiveIntraRouteInversionGenerator(this, cloner); 39 44 } 40 45 … … 44 49 int currentTourStart = 0; 45 50 int currentTourEnd = 0; 46 while (currentTourEnd != individual.Length) {51 while (currentTourEnd != individual.Length) { 47 52 currentTourEnd = currentTourStart; 48 while (individual[currentTourEnd] < individual.Cities && 53 while (individual[currentTourEnd] < individual.Cities && 49 54 currentTourEnd < individual.Length) { 50 55 currentTourEnd++; … … 53 58 int tourLength = currentTourEnd - currentTourStart; 54 59 if (tourLength >= 4) { 55 for (int i = 0; i <= tourLength - 4; i++ 60 for (int i = 0; i <= tourLength - 4; i++) { 56 61 for (int j = i + 2; j <= tourLength - 2; j++) { 57 62 AlbaIntraRouteInversionMove move = new AlbaIntraRouteInversionMove( 58 currentTourStart + i, 59 currentTourStart + j, 63 currentTourStart + i, 64 currentTourStart + j, 60 65 individual); 61 66 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaIntraRouteInversionEvaluator.cs
r4352 r4690 26 26 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba; 27 27 using HeuristicLab.Data; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting { … … 37 38 [StorableConstructor] 38 39 private AlbaIntraRouteInversionMoveEvaluator(bool deserializing) : base(deserializing) { } 39 40 private AlbaIntraRouteInversionMoveEvaluator(AlbaIntraRouteInversionMoveEvaluator original, Cloner cloner) : base(original, cloner) { } 40 41 public AlbaIntraRouteInversionMoveEvaluator() 41 42 : base() { 42 Parameters.Add(new LookupParameter<AlbaIntraRouteInversionMove>("AlbaIntraRouteInversionMove", "The move to evaluate.")); 43 Parameters.Add(new LookupParameter<AlbaIntraRouteInversionMove>("AlbaIntraRouteInversionMove", "The move to evaluate.")); 44 } 45 46 public override IDeepCloneable Clone(Cloner cloner) { 47 return new AlbaIntraRouteInversionMoveEvaluator(this, cloner); 43 48 } 44 49 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaIntraRouteInversionMove.cs
r4352 r4690 32 32 public class AlbaIntraRouteInversionMove : TwoIndexMove, IVRPMove { 33 33 public IVRPEncoding Individual { get { return Permutation as AlbaEncoding; } } 34 34 35 [StorableConstructor] 36 protected AlbaIntraRouteInversionMove(bool deserializing) : base(deserializing) { } 37 protected AlbaIntraRouteInversionMove(AlbaIntraRouteInversionMove original, Cloner cloner) 38 : base(original, cloner) { 39 Permutation = cloner.Clone(original.Permutation); 40 } 35 41 public AlbaIntraRouteInversionMove() 36 42 : base() { … … 43 49 public AlbaIntraRouteInversionMove(int index1, int index2, AlbaEncoding permutation) 44 50 : base(index1, index2, permutation) { 45 51 this.Permutation = permutation.Clone() as AlbaEncoding; 46 52 } 47 53 48 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) { 49 AlbaIntraRouteInversionMove clone = new AlbaIntraRouteInversionMove( 50 Index1, Index2); 51 52 if (Permutation != null) 53 clone.Permutation = (AlbaEncoding)cloner.Clone(Permutation); 54 55 cloner.RegisterClonedObject(this, clone); 56 return clone; 54 public override IDeepCloneable Clone(Cloner cloner) { 55 return new AlbaIntraRouteInversionMove(this, cloner); 57 56 } 58 57 … … 61 60 public TourEvaluation GetMoveQuality( 62 61 IntValue vehicles, 63 DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, 62 DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, 64 63 DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates, 65 64 DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, 66 65 DoubleValue overloadPenalty, DoubleValue tardinessPenalty, 67 66 ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) { 68 69 70 71 67 return AlbaIntraRouteInversionMoveEvaluator.GetMoveQuality(Permutation as AlbaEncoding, this, vehicles, 68 dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity, 69 coordinates, fleetUsageFactor, timeFactor, distanceFactor, 70 overloadPenalty, tardinessPenalty, distanceMatrix, useDistanceMatrix); 72 71 } 73 72 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaIntraRouteInversionMoveGenerator.cs
r4352 r4690 27 27 using HeuristicLab.Parameters; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 42 43 [StorableConstructor] 43 44 protected AlbaIntraRouteInversionMoveGenerator(bool deserializing) : base(deserializing) { } 44 45 protected AlbaIntraRouteInversionMoveGenerator(AlbaIntraRouteInversionMoveGenerator original, Cloner cloner) : base(original, cloner) { } 45 46 public AlbaIntraRouteInversionMoveGenerator() 46 47 : base() { 47 48 48 Parameters.Add(new LookupParameter<AlbaIntraRouteInversionMove>("AlbaIntraRouteInversionMove", "The moves that should be generated in subscopes.")); 49 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes.")); 49 50 } 50 51 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaIntraRouteInversionMoveMaker.cs
r4352 r4690 26 26 using HeuristicLab.Parameters; 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 46 47 [StorableConstructor] 47 48 private AlbaIntraRouteInversionMoveMaker(bool deserializing) : base(deserializing) { } 48 49 private AlbaIntraRouteInversionMoveMaker(AlbaIntraRouteInversionMoveMaker original, Cloner cloner) 50 : base(original, cloner) { 51 } 49 52 public AlbaIntraRouteInversionMoveMaker() 50 53 : base() { … … 52 55 Parameters.Add(new LookupParameter<AlbaIntraRouteInversionMove>("AlbaIntraRouteInversionMove", "The move to make.")); 53 56 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move.")); 57 } 58 59 public override IDeepCloneable Clone(Cloner cloner) { 60 return new AlbaIntraRouteInversionMoveMaker(this, cloner); 54 61 } 55 62 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaStochasticIntraRouteInversionMutliMoveGenerator.cs
r4352 r4690 28 28 using System.Collections.Generic; 29 29 using HeuristicLab.Data; 30 using HeuristicLab.Common; 30 31 31 32 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 40 41 get { return (IValueLookupParameter<IntValue>)Parameters["SampleSize"]; } 41 42 } 42 43 43 44 [StorableConstructor] 44 45 private AlbaStochasticIntraRouteInversionMultiMoveGenerator(bool deserializing) : base(deserializing) { } 45 46 private AlbaStochasticIntraRouteInversionMultiMoveGenerator(AlbaStochasticIntraRouteInversionMultiMoveGenerator original, Cloner cloner) : base(original, cloner) { } 46 47 public AlbaStochasticIntraRouteInversionMultiMoveGenerator() 47 48 : base() { 48 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 49 Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to generate.")); 49 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 50 Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to generate.")); 51 } 52 53 public override IDeepCloneable Clone(Cloner cloner) { 54 return new AlbaStochasticIntraRouteInversionMultiMoveGenerator(this, cloner); 50 55 } 51 56 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/AlbaStochasticIntraRouteInversionSingleMoveGenerator.cs
r4352 r4690 28 28 using System.Collections.Generic; 29 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 30 using HeuristicLab.Common; 30 31 31 32 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 41 42 42 43 #endregion 43 44 44 45 public ILookupParameter<IRandom> RandomParameter { 45 46 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 46 47 } 47 48 48 49 [StorableConstructor] 49 50 private AlbaStochasticIntraRouteInversionSingleMoveGenerator(bool deserializing) : base(deserializing) { } 50 51 private AlbaStochasticIntraRouteInversionSingleMoveGenerator(AlbaStochasticIntraRouteInversionSingleMoveGenerator original, Cloner cloner) : base(original, cloner) { } 51 52 public AlbaStochasticIntraRouteInversionSingleMoveGenerator() 52 53 : base() { 53 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 54 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 55 } 56 57 public override IDeepCloneable Clone(Cloner cloner) { 58 return new AlbaStochasticIntraRouteInversionSingleMoveGenerator(this, cloner); 54 59 } 55 60 … … 75 80 76 81 int currentTourEnd = currentTourStart; 77 while (currentTourEnd < individual.Length && 82 while (currentTourEnd < individual.Length && 78 83 individual[currentTourEnd] < individual.Cities) { 79 84 currentTourEnd++; … … 93 98 94 99 AlbaIntraRouteInversionMove move = Apply(individual, Cities, RandomParameter.ActualValue); 95 if (move != null)100 if (move != null) 96 101 moves.Add(move); 97 102 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaExhaustiveLambdaInterchangeMoveGenerator.cs
r4352 r4690 27 27 using HeuristicLab.Parameters; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 34 35 [StorableConstructor] 35 36 private AlbaExhaustiveLambdaInterchangeMoveGenerator(bool deserializing) : base(deserializing) { } 36 37 public AlbaExhaustiveLambdaInterchangeMoveGenerator() 38 : base() { 37 private AlbaExhaustiveLambdaInterchangeMoveGenerator(AlbaExhaustiveLambdaInterchangeMoveGenerator original, Cloner cloner) : base(original, cloner) { } 38 public AlbaExhaustiveLambdaInterchangeMoveGenerator() : base() { } 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new AlbaExhaustiveLambdaInterchangeMoveGenerator(this, cloner); 39 41 } 40 42 … … 50 52 51 53 for (int length1 = 0; length1 <= Math.Min(lambda, tour1.Cities.Count); length1++) { 52 for (int length2 = 0; length2 <= Math.Min(lambda, tour2.Cities.Count); length2++) {53 if (length1 != 0 || length2 != 0) {54 for (int index1 = 0; index1 < tour1.Cities.Count - length1 + 1; index1++) {55 for (int index2 = 0; index2 < tour2.Cities.Count - length2 + 1; index2++) {56 moves.Add(new AlbaLambdaInterchangeMove(tour1Index, index1, length1, 54 for (int length2 = 0; length2 <= Math.Min(lambda, tour2.Cities.Count); length2++) { 55 if (length1 != 0 || length2 != 0) { 56 for (int index1 = 0; index1 < tour1.Cities.Count - length1 + 1; index1++) { 57 for (int index2 = 0; index2 < tour2.Cities.Count - length2 + 1; index2++) { 58 moves.Add(new AlbaLambdaInterchangeMove(tour1Index, index1, length1, 57 59 tour2Index, index2, length2, individual)); 58 60 } -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMove.cs
r4352 r4690 52 52 [Storable] 53 53 public int Length2 { get; protected set; } 54 54 55 [StorableConstructor] 56 protected AlbaLambdaInterchangeMove(bool deserializing) : base(deserializing) { } 57 protected AlbaLambdaInterchangeMove(AlbaLambdaInterchangeMove original, Cloner cloner) : base(original, cloner) { 58 Tour1 = original.Tour1; 59 Position1 = original.Position1; 60 Length1 = original.Length1; 61 62 Tour2 = original.Tour2; 63 Position2 = original.Position2; 64 Length2 = original.Length2; 65 66 Individual = cloner.Clone(original.Individual); 67 } 68 55 69 public AlbaLambdaInterchangeMove(): base() { 56 70 Tour1 = -1; … … 76 90 77 91 this.Individual = permutation.Clone() as AlbaEncoding; 78 }79 80 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {81 AlbaLambdaInterchangeMove clone = new AlbaLambdaInterchangeMove();82 83 clone.Tour1 = Tour1;84 clone.Position1 = Position1;85 clone.Length1 = Length1;86 87 clone.Tour2 = Tour2;88 clone.Position2 = Position2;89 clone.Length2 = Length2;90 91 if (Individual != null)92 clone.Individual = (AlbaEncoding)cloner.Clone(Individual);93 94 cloner.RegisterClonedObject(this, clone);95 return clone;96 92 } 97 93 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveEvaluator.cs
r4352 r4690 26 26 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba; 27 27 using HeuristicLab.Data; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting { … … 37 38 [StorableConstructor] 38 39 private AlbaLambdaInterchangeMoveEvaluator(bool deserializing) : base(deserializing) { } 39 40 private AlbaLambdaInterchangeMoveEvaluator(AlbaLambdaInterchangeMoveEvaluator original, Cloner cloner) 41 : base(original, cloner) { 42 } 40 43 public AlbaLambdaInterchangeMoveEvaluator() 41 44 : base() { … … 43 46 } 44 47 48 public override IDeepCloneable Clone(Cloner cloner) { 49 return new AlbaLambdaInterchangeMoveEvaluator(this, cloner); 50 } 45 51 public static TourEvaluation GetMoveQuality(AlbaEncoding individual, AlbaLambdaInterchangeMove move, 46 52 IntValue vehicles, -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveGenerator.cs
r4352 r4690 28 28 using System.Collections.Generic; 29 29 using HeuristicLab.Data; 30 using HeuristicLab.Common; 30 31 31 32 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 51 52 [StorableConstructor] 52 53 protected AlbaLambdaInterchangeMoveGenerator(bool deserializing) : base(deserializing) { } 53 54 protected AlbaLambdaInterchangeMoveGenerator(AlbaLambdaInterchangeMoveGenerator original, Cloner cloner) 55 : base(original, cloner) { 56 } 54 57 public AlbaLambdaInterchangeMoveGenerator() 55 58 : base() { 56 57 58 59 Parameters.Add(new LookupParameter<AlbaLambdaInterchangeMove>("AlbaLambdaInterchangeMove", "The moves that should be generated in subscopes.")); 60 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes.")); 61 Parameters.Add(new ValueParameter<IntValue>("Lambda", "The lambda value.", new IntValue(1))); 59 62 } 60 63 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaLambdaInterchangeMoveMaker.cs
r4352 r4690 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 using System.Collections.Generic; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 47 48 [StorableConstructor] 48 49 private AlbaLambdaInterchangeMoveMaker(bool deserializing) : base(deserializing) { } 49 50 protected AlbaLambdaInterchangeMoveMaker(AlbaLambdaInterchangeMoveMaker original, Cloner cloner) 51 : base(original, cloner) { 52 } 50 53 public AlbaLambdaInterchangeMoveMaker() 51 54 : base() { … … 53 56 Parameters.Add(new LookupParameter<AlbaLambdaInterchangeMove>("AlbaLambdaInterchangeMove", "The move to make.")); 54 57 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The relative quality of the move.")); 58 } 59 60 public override IDeepCloneable Clone(Cloner cloner) { 61 return new AlbaLambdaInterchangeMoveMaker(this, cloner); 55 62 } 56 63 … … 64 71 public override IOperation Apply() { 65 72 IOperation next = base.Apply(); 66 73 67 74 AlbaLambdaInterchangeMove move = LambdaInterchangeMoveParameter.ActualValue; 68 75 DoubleValue moveQuality = MoveQualityParameter.ActualValue; 69 76 DoubleValue quality = QualityParameter.ActualValue; 70 77 71 78 //perform move 72 79 VRPToursParameter.ActualValue = move.MakeMove(); -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaStochasticLambdaInterchangeMutliMoveGenerator.cs
r4352 r4690 28 28 using System.Collections.Generic; 29 29 using HeuristicLab.Data; 30 using HeuristicLab.Common; 30 31 31 32 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 40 41 get { return (IValueLookupParameter<IntValue>)Parameters["SampleSize"]; } 41 42 } 42 43 43 44 [StorableConstructor] 44 45 private AlbaStochasticLambdaInterchangeMultiMoveGenerator(bool deserializing) : base(deserializing) { } 45 46 private AlbaStochasticLambdaInterchangeMultiMoveGenerator(AlbaStochasticLambdaInterchangeMultiMoveGenerator original, Cloner cloner) : base(original, cloner) { } 46 47 public AlbaStochasticLambdaInterchangeMultiMoveGenerator() 47 48 : base() { 48 49 49 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 50 Parameters.Add(new ValueLookupParameter<IntValue>("SampleSize", "The number of moves to generate.")); 50 51 } 51 52 public override IDeepCloneable Clone(Cloner cloner) { 53 return new AlbaStochasticLambdaInterchangeMultiMoveGenerator(this, cloner); 54 } 52 55 protected override AlbaLambdaInterchangeMove[] GenerateMoves(AlbaEncoding individual, int lambda) { 53 56 int sampleSize = SampleSizeParameter.ActualValue.Value; -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/AlbaStochasticLambdaInterchangeSingleMoveGenerator.cs
r4352 r4690 28 28 using System.Collections.Generic; 29 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 30 using HeuristicLab.Common; 30 31 31 32 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 41 42 42 43 #endregion 43 44 44 45 public ILookupParameter<IRandom> RandomParameter { 45 46 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 46 47 } 47 48 48 49 [StorableConstructor] 49 50 private AlbaStochasticLambdaInterchangeSingleMoveGenerator(bool deserializing) : base(deserializing) { } 50 51 private AlbaStochasticLambdaInterchangeSingleMoveGenerator(AlbaStochasticLambdaInterchangeSingleMoveGenerator original, Cloner cloner) 52 : base(original, cloner) { 53 } 51 54 public AlbaStochasticLambdaInterchangeSingleMoveGenerator() 52 55 : base() { 53 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 56 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator.")); 57 } 58 59 public override IDeepCloneable Clone(Cloner cloner) { 60 return new AlbaStochasticLambdaInterchangeSingleMoveGenerator(this, cloner); 54 61 } 55 62 … … 81 88 82 89 AlbaLambdaInterchangeMove move = Apply(individual, Cities, lambda, RandomParameter.ActualValue); 83 if (move != null)90 if (move != null) 84 91 moves.Add(move); 85 92 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveEvaluator.cs
r4352 r4690 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting { … … 37 38 [StorableConstructor] 38 39 private AlbaTranslocationMoveEvaluator(bool deserializing) : base(deserializing) { } 39 40 private AlbaTranslocationMoveEvaluator(AlbaTranslocationMoveEvaluator original, Cloner cloner) : base(original, cloner) { } 40 41 public AlbaTranslocationMoveEvaluator() 41 42 : base() { 42 43 Parameters.Add(new LookupParameter<TranslocationMove>("TranslocationMove", "The move to evaluate.")); 44 } 45 46 public override IDeepCloneable Clone(Cloner cloner) { 47 return new AlbaTranslocationMoveEvaluator(this, cloner); 43 48 } 44 49 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveGenerator.cs
r4352 r4690 27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 70 71 [StorableConstructor] 71 72 private AlbaTranslocationMoveGenerator(bool deserializing) : base(deserializing) { } 72 73 private AlbaTranslocationMoveGenerator(AlbaTranslocationMoveGenerator original, Cloner cloner) : base(original, cloner) { } 73 74 public AlbaTranslocationMoveGenerator() 74 75 : base() { … … 78 79 79 80 ((IMultiMoveGenerator)TranslocationMoveGeneratorParameter.Value).SampleSizeParameter.ActualName = SampleSizeParameter.Name; 81 } 82 83 public override IDeepCloneable Clone(Cloner cloner) { 84 return new AlbaTranslocationMoveGenerator(this, cloner); 80 85 } 81 86 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveHardTabuCriterion.cs
r4352 r4690 25 25 using HeuristicLab.Optimization; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 58 59 [StorableConstructor] 59 60 private AlbaTranslocationMoveHardTabuCriterion(bool deserializing) : base(deserializing) { } 60 61 private AlbaTranslocationMoveHardTabuCriterion(AlbaTranslocationMoveHardTabuCriterion original, Cloner cloner) 62 : base(original, cloner) { 63 } 61 64 public AlbaTranslocationMoveHardTabuCriterion() 62 65 : base() { 63 66 tabuChecker = new TranslocationMoveHardTabuCriterion(); 64 67 } 68 public override IDeepCloneable Clone(Cloner cloner) { 69 return new AlbaTranslocationMoveHardTabuCriterion(this, cloner); 70 } 65 71 } 66 72 } -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveMaker.cs
r4352 r4690 25 25 using HeuristicLab.Optimization; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 50 51 [StorableConstructor] 51 52 private AlbaTranslocationMoveMaker(bool deserializing) : base(deserializing) { } 52 53 private AlbaTranslocationMoveMaker(AlbaTranslocationMoveMaker original, Cloner cloner) 54 : base(original, cloner) { 55 } 53 56 public AlbaTranslocationMoveMaker() 54 57 : base() { 55 58 moveMaker = new TranslocationMoveMaker(); 56 59 } 57 60 public override IDeepCloneable Clone(Cloner cloner) { 61 return new AlbaTranslocationMoveMaker(this, cloner); 62 } 58 63 public override IOperation Apply() { 59 64 IOperation next = base.Apply(); -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveSoftTabuCriterion.cs
r4352 r4690 25 25 using HeuristicLab.Optimization; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 58 59 [StorableConstructor] 59 60 private AlbaTranslocationMoveSoftTabuCriterion(bool deserializing) : base(deserializing) { } 60 61 private AlbaTranslocationMoveSoftTabuCriterion(AlbaTranslocationMoveSoftTabuCriterion original, Cloner cloner) 62 : base(original, cloner) { 63 } 61 64 public AlbaTranslocationMoveSoftTabuCriterion() 62 65 : base() { 63 66 tabuChecker = new TranslocationMoveSoftTabuCriterion(); 64 67 } 68 public override IDeepCloneable Clone(Cloner cloner) { 69 return new AlbaTranslocationMoveSoftTabuCriterion(this, cloner); 70 } 65 71 } 66 72 } -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/ThreeOpt/AlbaTranslocationMoveTabuMaker.cs
r4352 r4690 25 25 using HeuristicLab.Optimization; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba { … … 58 59 [StorableConstructor] 59 60 private AlbaTranslocationMoveTabuMaker(bool deserializing) : base(deserializing) { } 60 61 private AlbaTranslocationMoveTabuMaker(AlbaTranslocationMoveTabuMaker original, Cloner cloner) 62 : base(original, cloner) { 63 } 61 64 public AlbaTranslocationMoveTabuMaker() 62 65 : base() { 63 66 moveTabuMaker = new TranslocationMoveTabuMaker(); 64 67 } 68 public override IDeepCloneable Clone(Cloner cloner) { 69 return new AlbaTranslocationMoveTabuMaker(this, cloner); 70 } 65 71 } 66 72 }
Note: See TracChangeset
for help on using the changeset viewer.