Changeset 4690 for branches/CloningRefactoring
- Timestamp:
- 10/29/10 20:30:20 (14 years ago)
- Location:
- branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3
- Files:
-
- 42 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Analyzers/BestAverageWorstVRPToursAnalyzer.cs
r4416 r4690 150 150 public BestAverageWorstVRPToursAnalyzer() 151 151 : base() { 152 #region Create parameters 152 #region Create parameters 153 153 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Overload", "The overloads of the VRP solutions which should be analyzed.")); 154 154 Parameters.Add(new ValueLookupParameter<DoubleValue>("BestOverload", "The best overload value.")); … … 157 157 Parameters.Add(new ValueLookupParameter<DoubleValue>("CurrentWorstOverload", "The current worst overload value of all solutions.")); 158 158 Parameters.Add(new ValueLookupParameter<DataTable>("Overloads", "The data table to store the current best, current average, current worst, best and best known overload value.")); 159 159 160 160 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Tardiness", "The tardiness of the VRP solutions which should be analyzed.")); 161 161 Parameters.Add(new ValueLookupParameter<DoubleValue>("BestTardiness", "The best tardiness value.")); … … 311 311 [StorableConstructor] 312 312 private BestAverageWorstVRPToursAnalyzer(bool deserializing) : base() { } 313 private BestAverageWorstVRPToursAnalyzer(BestAverageWorstVRPToursAnalyzer original, Cloner cloner) 314 : base(original, cloner) { 315 Initialize(); 316 } 317 public override IDeepCloneable Clone(Cloner cloner) { 318 return new BestAverageWorstVRPToursAnalyzer(this, cloner); 319 } 313 320 314 321 [StorableHook(HookType.AfterDeserialization)] 322 private void AfterDeserialization() { 323 Initialize(); 324 } 315 325 private void Initialize() { 316 326 OverloadParameter.DepthChanged += new EventHandler(OverloadParameter_DepthChanged); … … 321 331 } 322 332 323 public override IDeepCloneable Clone(Cloner cloner) {324 BestAverageWorstVRPToursAnalyzer clone = (BestAverageWorstVRPToursAnalyzer)base.Clone(cloner);325 clone.Initialize();326 return clone;327 }328 333 329 334 void OverloadParameter_DepthChanged(object sender, EventArgs e) { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Analyzers/BestAverageWorstVRPToursCalculator.cs
r4352 r4690 25 25 using HeuristicLab.Parameters; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Common; 27 28 28 29 namespace HeuristicLab.Problems.VehicleRouting { … … 95 96 } 96 97 98 [StorableConstructor] 99 private BestAverageWorstVRPToursCalculator(bool deserializing) : base(deserializing) { } 100 private BestAverageWorstVRPToursCalculator(BestAverageWorstVRPToursCalculator original, Cloner cloner) 101 : base(original, cloner) { 102 } 97 103 public BestAverageWorstVRPToursCalculator() 98 104 : base() { … … 123 129 } 124 130 131 public override IDeepCloneable Clone(Cloner cloner) { 132 return new BestAverageWorstVRPToursCalculator(this, cloner); 133 } 134 125 135 private void UpdateOverloads() { 126 136 ItemArray<DoubleValue> overloads = OverloadParameter.ActualValue; -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Analyzers/BestVRPSolutionAnalyzer.cs
r4513 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 { … … 83 84 [StorableConstructor] 84 85 private BestVRPSolutionAnalyzer(bool deserializing) : base(deserializing) { } 85 86 private BestVRPSolutionAnalyzer(BestVRPSolutionAnalyzer original, Cloner cloner) 87 : base(original, cloner) { 88 } 86 89 public BestVRPSolutionAnalyzer() 87 90 : base() { … … 102 105 Parameters.Add(new LookupParameter<VRPSolution>("BestSolution", "The best VRP solution.")); 103 106 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored.")); 107 } 108 109 public override IDeepCloneable Clone(Cloner cloner) { 110 return new BestVRPSolutionAnalyzer(this, cloner); 104 111 } 105 112 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Analyzers/BestVRPToursMemorizer.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 { … … 63 64 } 64 65 66 [StorableConstructor] 67 protected BestVRPToursMemorizer(bool deserializing) : base(deserializing) { } 68 protected BestVRPToursMemorizer(BestVRPToursMemorizer original, Cloner cloner) 69 : base(original, cloner) { 70 } 65 71 public BestVRPToursMemorizer() 66 72 : base() { … … 77 83 Parameters.Add(new ValueLookupParameter<DoubleValue>("BestVehiclesUtilized", "The best vehicles utilized found so far.")); 78 84 85 } 86 87 public override IDeepCloneable Clone(Cloner cloner) { 88 return new BestVRPToursMemorizer(this, cloner); 79 89 } 80 90 -
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 } -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Evaluators/VRPEvaluator.cs
r4352 r4690 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 using HeuristicLab.Problems.VehicleRouting.Encodings; 28 using HeuristicLab.Common; 28 29 29 30 namespace HeuristicLab.Problems.VehicleRouting { … … 82 83 } 83 84 85 [StorableConstructor] 86 private VRPEvaluator(bool deserializing) : base(deserializing) { } 87 private VRPEvaluator(VRPEvaluator original, Cloner cloner) 88 : base(original, cloner) { 89 } 84 90 public VRPEvaluator() 85 91 : base() { … … 98 104 } 99 105 106 public override IDeepCloneable Clone(Cloner cloner) { 107 return new VRPEvaluator(this, cloner); 108 } 109 100 110 private double CalculateFleetUsage() { 101 111 IVRPEncoding vrpSolution = VRPToursParameter.ActualValue; -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/MoveEvaluators/VRPMoveEvaluator.cs
r4179 r4690 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 using HeuristicLab.Problems.VehicleRouting.Encodings; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting { … … 39 40 get { return (ILookupParameter<IVRPEncoding>)Parameters["VRPTours"]; } 40 41 } 41 42 42 43 public ILookupParameter<DoubleValue> FleetUsageFactor { 43 44 get { return (ILookupParameter<DoubleValue>)Parameters["EvalFleetUsageFactor"]; } … … 80 81 [StorableConstructor] 81 82 protected VRPMoveEvaluator(bool deserializing) : base(deserializing) { } 82 83 protected VRPMoveEvaluator(VRPMoveEvaluator original, Cloner cloner) : base(original, cloner) { } 83 84 protected VRPMoveEvaluator() 84 85 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/VRPOperator.cs
r4352 r4690 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 using System; 29 using HeuristicLab.Common; 29 30 30 31 namespace HeuristicLab.Problems.VehicleRouting { … … 110 111 [StorableConstructor] 111 112 protected VRPOperator(bool deserializing) : base(deserializing) { } 112 113 protected VRPOperator(VRPOperator original, Cloner cloner) : base(original, cloner) { } 113 114 public VRPOperator() 114 115 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/VRPSolution.cs
r4185 r4690 195 195 public VRPSolution() : base() { } 196 196 197 public VRPSolution(DoubleMatrix coordinates): base() { 197 public VRPSolution(DoubleMatrix coordinates) 198 : base() { 198 199 this.coordinates = coordinates; 199 200 } 200 201 201 public VRPSolution(DoubleMatrix coordinates, IVRPEncoding solution, DoubleValue quality, 202 DoubleValue distance, DoubleValue overload, DoubleValue tardiness, DoubleValue travelTime, 202 public VRPSolution(DoubleMatrix coordinates, IVRPEncoding solution, DoubleValue quality, 203 DoubleValue distance, DoubleValue overload, DoubleValue tardiness, DoubleValue travelTime, 203 204 DoubleValue vehicleUtilization, DoubleMatrix distanceMatrix, BoolValue useDistanceMatrix, 204 205 DoubleArray readyTime, DoubleArray dueTime, DoubleArray serviceTime) … … 222 223 private VRPSolution(bool deserializing) : base(deserializing) { } 223 224 225 protected VRPSolution(VRPSolution original, Cloner cloner) 226 : base(original, cloner) { 227 coordinates = cloner.Clone(original.coordinates); 228 solution = cloner.Clone(original.solution); 229 quality = cloner.Clone(original.quality); 230 distance = cloner.Clone(original.distance); 231 overload = cloner.Clone(original.overload); 232 tardiness = cloner.Clone(original.tardiness); 233 travelTime = cloner.Clone(original.travelTime); 234 vehicleUtilization = cloner.Clone(original.vehicleUtilization); 235 distanceMatrix = cloner.Clone(original.distanceMatrix); 236 useDistanceMatrix = cloner.Clone(original.useDistanceMatrix); 237 readyTime = cloner.Clone(original.readyTime); 238 dueTime = cloner.Clone(original.dueTime); 239 serviceTime = cloner.Clone(original.serviceTime); 240 Initialize(); 241 } 242 224 243 [StorableHook(HookType.AfterDeserialization)] 244 private void AfterDeserialization() { 245 Initialize(); 246 } 225 247 private void Initialize() { 226 248 if (coordinates != null) RegisterCoordinatesEvents(); … … 235 257 236 258 public override IDeepCloneable Clone(Cloner cloner) { 237 VRPSolution clone = new VRPSolution(); 238 cloner.RegisterClonedObject(this, clone); 239 clone.coordinates = (DoubleMatrix)cloner.Clone(coordinates); 240 clone.solution = (IVRPEncoding)cloner.Clone(solution); 241 clone.quality = (DoubleValue)cloner.Clone(quality); 242 clone.distance = (DoubleValue)cloner.Clone(distance); 243 clone.overload = (DoubleValue)cloner.Clone(overload); 244 clone.tardiness = (DoubleValue)cloner.Clone(tardiness); 245 clone.travelTime = (DoubleValue)cloner.Clone(travelTime); 246 clone.vehicleUtilization = (DoubleValue)cloner.Clone(vehicleUtilization); 247 clone.distanceMatrix = (DoubleMatrix)cloner.Clone(distanceMatrix); 248 clone.useDistanceMatrix = (BoolValue)cloner.Clone(useDistanceMatrix); 249 clone.readyTime = (DoubleArray)cloner.Clone(readyTime); 250 clone.dueTime = (DoubleArray)cloner.Clone(dueTime); 251 clone.serviceTime = (DoubleArray)cloner.Clone(serviceTime); 252 clone.Initialize(); 253 return clone; 259 return new VRPSolution(this, cloner); 254 260 } 255 261 -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs
r4626 r4690 197 197 [StorableConstructor] 198 198 private VehicleRoutingProblem(bool deserializing) : base(deserializing) { } 199 199 private VehicleRoutingProblem(VehicleRoutingProblem original, Cloner cloner) 200 : base(original, cloner) { 201 operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList(); 202 DistanceMatrixParameter.Value = DistanceMatrixParameter.Value; 203 AttachEventHandlers(); 204 } 200 205 public VehicleRoutingProblem() 201 206 : base() { … … 237 242 238 243 public override IDeepCloneable Clone(Cloner cloner) { 239 VehicleRoutingProblem clone = (VehicleRoutingProblem)base.Clone(cloner); 240 clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList(); 241 clone.DistanceMatrixParameter.Value = DistanceMatrixParameter.Value; 242 clone.AttachEventHandlers(); 243 return clone; 244 return new VehicleRoutingProblem(this, cloner); 244 245 } 245 246 … … 454 455 455 456 SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged); 456 457 457 458 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged); 458 459 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); … … 563 564 private void ParameterizeOperators() { 564 565 foreach (IVRPOperator op in Operators.OfType<IVRPOperator>()) { 565 if (op.CoordinatesParameter != null) op.CoordinatesParameter.ActualName = CoordinatesParameter.Name;566 if (op.DistanceMatrixParameter != null) op.DistanceMatrixParameter.ActualName = DistanceMatrixParameter.Name;567 if (op.UseDistanceMatrixParameter != null) op.UseDistanceMatrixParameter.ActualName = UseDistanceMatrixParameter.Name;568 if (op.VehiclesParameter != null) op.VehiclesParameter.ActualName = VehiclesParameter.Name;569 if (op.CapacityParameter != null) op.CapacityParameter.ActualName = CapacityParameter.Name;570 if (op.DemandParameter != null) op.DemandParameter.ActualName = DemandParameter.Name;571 if (op.ReadyTimeParameter != null) op.ReadyTimeParameter.ActualName = ReadyTimeParameter.Name;572 if (op.DueTimeParameter != null) op.DueTimeParameter.ActualName = DueTimeParameter.Name;573 if (op.ServiceTimeParameter != null) op.ServiceTimeParameter.ActualName = ServiceTimeParameter.Name;574 } 575 566 if (op.CoordinatesParameter != null) op.CoordinatesParameter.ActualName = CoordinatesParameter.Name; 567 if (op.DistanceMatrixParameter != null) op.DistanceMatrixParameter.ActualName = DistanceMatrixParameter.Name; 568 if (op.UseDistanceMatrixParameter != null) op.UseDistanceMatrixParameter.ActualName = UseDistanceMatrixParameter.Name; 569 if (op.VehiclesParameter != null) op.VehiclesParameter.ActualName = VehiclesParameter.Name; 570 if (op.CapacityParameter != null) op.CapacityParameter.ActualName = CapacityParameter.Name; 571 if (op.DemandParameter != null) op.DemandParameter.ActualName = DemandParameter.Name; 572 if (op.ReadyTimeParameter != null) op.ReadyTimeParameter.ActualName = ReadyTimeParameter.Name; 573 if (op.DueTimeParameter != null) op.DueTimeParameter.ActualName = DueTimeParameter.Name; 574 if (op.ServiceTimeParameter != null) op.ServiceTimeParameter.ActualName = ServiceTimeParameter.Name; 575 } 576 576 577 foreach (IVRPMoveOperator op in Operators.OfType<IVRPMoveOperator>()) { 577 578 op.VRPToursParameter.ActualName = SolutionCreator.VRPToursParameter.ActualName; … … 641 642 if (parser.Vehicles != -1) 642 643 Vehicles.Value = parser.Vehicles; 643 else 644 else 644 645 Vehicles.Value = problemSize - 1; 645 646 Capacity.Value = parser.Capacity;
Note: See TracChangeset
for help on using the changeset viewer.