- Timestamp:
- 10/29/10 20:21:04 (14 years ago)
- Location:
- branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/DefaultRepresentationCreator.cs
r4183 r4687 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 22 24 using HeuristicLab.Core; 23 using HeuristicLab.Data;24 using HeuristicLab.Operators;25 using HeuristicLab.Parameters;26 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using System.Collections.Generic;28 using HeuristicLab.Problems.VehicleRouting.Encodings;29 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;30 26 using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin; 31 27 … … 38 34 [StorableConstructor] 39 35 protected DefaultRepresentationCreator(bool deserializing) : base(deserializing) { } 36 protected DefaultRepresentationCreator(DefaultRepresentationCreator original, Cloner cloner) : base(original, cloner) { } 40 37 41 38 public DefaultRepresentationCreator() : base() { } … … 46 43 47 44 return base.Apply(); 48 } 45 } 49 46 } 50 47 } -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/MultiVRPSolutionCreator.cs
r4352 r4687 23 23 using System.Linq; 24 24 using HeuristicLab.Collections; 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 26 28 using HeuristicLab.Operators; 27 29 using HeuristicLab.Optimization; … … 29 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 32 using HeuristicLab.PluginInfrastructure; 31 using HeuristicLab.Data;32 33 33 34 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 79 80 [StorableConstructor] 80 81 private MultiVRPSolutionCreator(bool deserializing) : base(deserializing) { } 82 protected MultiVRPSolutionCreator(MultiVRPSolutionCreator original, Cloner cloner) : base(original, cloner) { } 83 public override IDeepCloneable Clone(Cloner cloner) { 84 return new MultiVRPSolutionCreator(this, cloner); 85 } 86 81 87 public MultiVRPSolutionCreator() 82 88 : base() { 83 89 Parameters.Add(new LookupParameter<IVRPEncoding>("VRPTours", "The new VRP tours.")); 84 90 85 86 87 88 89 90 91 92 93 94 91 Parameters.Add(new ValueLookupParameter<IntValue>("Cities", "The city count.")); 92 Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The coordinates of the cities.")); 93 Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities.")); 94 Parameters.Add(new LookupParameter<BoolValue>("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false.")); 95 Parameters.Add(new LookupParameter<IntValue>("Vehicles", "The number of vehicles.")); 96 Parameters.Add(new LookupParameter<DoubleValue>("Capacity", "The capacity of each vehicle.")); 97 Parameters.Add(new LookupParameter<DoubleArray>("Demand", "The demand of each customer.")); 98 Parameters.Add(new LookupParameter<DoubleArray>("ReadyTime", "The ready time of each customer.")); 99 Parameters.Add(new LookupParameter<DoubleArray>("DueTime", "The due time of each customer.")); 100 Parameters.Add(new LookupParameter<DoubleArray>("ServiceTime", "The service time of each customer.")); 95 101 96 97 98 102 foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(IVRPCreator)).OrderBy(op => op.Name)) { 103 if (!typeof(MultiOperator<IVRPCreator>).IsAssignableFrom(type)) 104 Operators.Add((IVRPCreator)Activator.CreateInstance(type), true); 99 105 } 100 106 } -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/PushForwardInsertionCreator.cs
r4352 r4687 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.PermutationEncoding;27 27 using HeuristicLab.Optimization; 28 28 using HeuristicLab.Parameters; … … 60 60 [StorableConstructor] 61 61 private PushForwardCreator(bool deserializing) : base(deserializing) { } 62 protected PushForwardCreator(PushForwardCreator original, Cloner cloner) : base(original, cloner) { } 63 public override IDeepCloneable Clone(Cloner cloner) { 64 return new PushForwardCreator(this, cloner); 65 } 62 66 63 67 public PushForwardCreator() -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/RandomCreator.cs
r4183 r4687 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data;26 using HeuristicLab.Encodings.PermutationEncoding;27 25 using HeuristicLab.Optimization; 28 26 using HeuristicLab.Parameters; … … 41 39 [StorableConstructor] 42 40 private RandomCreator(bool deserializing) : base(deserializing) { } 41 private RandomCreator(RandomCreator original, Cloner cloner) : base(original, cloner) { } 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new RandomCreator(this, cloner); 44 } 43 45 44 46 public RandomCreator() -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Crossovers/MultiVRPSolutionCrossover.cs
r4352 r4687 23 23 using System.Linq; 24 24 using HeuristicLab.Collections; 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 26 28 using HeuristicLab.Operators; 27 29 using HeuristicLab.Optimization; … … 29 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 32 using HeuristicLab.PluginInfrastructure; 31 using HeuristicLab.Data;32 33 33 34 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 83 84 [StorableConstructor] 84 85 private MultiVRPSolutionCrossover(bool deserializing) : base(deserializing) { } 86 protected MultiVRPSolutionCrossover(MultiVRPSolutionCrossover original, Cloner cloner) : base(original, cloner) { } 87 public override IDeepCloneable Clone(Cloner cloner) { 88 return new MultiVRPSolutionCrossover(this, cloner); 89 } 85 90 public MultiVRPSolutionCrossover() 86 91 : base() { 87 92 Parameters.Add(new ScopeTreeLookupParameter<IVRPEncoding>("Parents", "The parent permutations which should be crossed.")); 88 93 ParentsParameter.ActualName = "VRPTours"; 89 94 Parameters.Add(new LookupParameter<IVRPEncoding>("Child", "The child permutation resulting from the crossover.")); -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Crossovers/RandomParentCloneCrossover.cs
r4352 r4687 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Common; 26 23 using HeuristicLab.Core; 27 24 using HeuristicLab.Optimization; … … 39 36 [StorableConstructor] 40 37 private RandomParentCloneCrossover(bool deserializing) : base(deserializing) { } 38 protected RandomParentCloneCrossover(RandomParentCloneCrossover original, Cloner cloner) : base(original, cloner) { } 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new RandomParentCloneCrossover(this, cloner); 41 } 41 42 42 43 public RandomParentCloneCrossover() … … 54 55 Parameters.Remove("ServiceTime"); 55 56 } 56 57 57 58 public override IOperation Apply() { 58 59 if (RandomParameter.ActualValue.Next() < 0.5) -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Manipulators/MultiVRPSolutionManipulator.cs
r4352 r4687 23 23 using System.Linq; 24 24 using HeuristicLab.Collections; 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 26 28 using HeuristicLab.Operators; 27 29 using HeuristicLab.Optimization; … … 29 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 32 using HeuristicLab.PluginInfrastructure; 31 using HeuristicLab.Data;32 33 33 34 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 79 80 [StorableConstructor] 80 81 private MultiVRPSolutionManipulator(bool deserializing) : base(deserializing) { } 82 protected MultiVRPSolutionManipulator(MultiVRPSolutionManipulator original, Cloner cloner) : base(original, cloner) { } 83 public override IDeepCloneable Clone(Cloner cloner) { 84 return new MultiVRPSolutionManipulator(this, cloner); 85 } 81 86 public MultiVRPSolutionManipulator() 82 87 : base() { … … 97 102 if (!typeof(MultiOperator<IVRPManipulator>).IsAssignableFrom(type)) { 98 103 IVRPManipulator op = (IVRPManipulator)Activator.CreateInstance(type); 99 bool operatorChecked = true; 100 if (op is HeuristicLab.Problems.VehicleRouting.Encodings.Potvin.PotvinLocalSearchManipulator ||104 bool operatorChecked = true; 105 if (op is HeuristicLab.Problems.VehicleRouting.Encodings.Potvin.PotvinLocalSearchManipulator || 101 106 op is HeuristicLab.Problems.VehicleRouting.Encodings.Prins.PrinsLSManipulator) 102 107 operatorChecked = false; -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveEvaluator.cs
r4352 r4687 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding;24 24 using HeuristicLab.Parameters; 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 36 36 [StorableConstructor] 37 37 private MultiVRPMoveEvaluator(bool deserializing) : base(deserializing) { } 38 private MultiVRPMoveEvaluator(MultiVRPMoveEvaluator original, Cloner cloner) : base(original, cloner) { } 39 public override IDeepCloneable Clone(Cloner cloner) { 40 return new MultiVRPMoveEvaluator(this, cloner); 41 } 38 42 39 43 public MultiVRPMoveEvaluator() 40 44 : base() { 41 45 Parameters.Add(new LookupParameter<IVRPMove>("VRPMove", "The generated moves.")); 42 46 } 43 47 … … 53 57 CapacityParameter.ActualValue, 54 58 CoordinatesParameter.ActualValue, 55 FleetUsageFactor.ActualValue, 56 TimeFactor.ActualValue, 57 DistanceFactor.ActualValue, 58 OverloadPenalty.ActualValue, 59 FleetUsageFactor.ActualValue, 60 TimeFactor.ActualValue, 61 DistanceFactor.ActualValue, 62 OverloadPenalty.ActualValue, 59 63 TardinessPenalty.ActualValue, 60 64 DistanceMatrixParameter, -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveGenerator.cs
r4352 r4687 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using HeuristicLab.Collections; 26 using HeuristicLab.Common; 25 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 26 29 using HeuristicLab.Operators; 27 30 using HeuristicLab.Optimization; … … 29 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 33 using HeuristicLab.PluginInfrastructure; 31 using HeuristicLab.Data;32 using System.Collections.Generic;33 34 34 35 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { 35 36 [Item("MultiVRPMoveGenerator", "Randomly selects and applies its move generators.")] 36 37 [StorableClass] 37 public class MultiVRPMoveGenerator : CheckedMultiOperator<IMultiVRPMoveGenerator>, IMultiVRPMoveOperator, 38 public class MultiVRPMoveGenerator : CheckedMultiOperator<IMultiVRPMoveGenerator>, IMultiVRPMoveOperator, 38 39 IStochasticOperator, IMultiMoveGenerator { 39 40 public override bool CanChangeName { … … 98 99 [StorableConstructor] 99 100 private MultiVRPMoveGenerator(bool deserializing) : base(deserializing) { } 101 private MultiVRPMoveGenerator(MultiVRPMoveGenerator original, Cloner cloner) : base(original, cloner) { } 102 public override IDeepCloneable Clone(Cloner cloner) { 103 return new MultiVRPMoveGenerator(this, cloner); 104 } 100 105 public MultiVRPMoveGenerator() 101 106 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveMaker.cs
r4416 r4687 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Data; 24 using HeuristicLab.Operators;25 25 using HeuristicLab.Optimization; 26 26 using HeuristicLab.Parameters; 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using System.Collections.Generic;29 28 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { 31 30 [Item("MultiVRPMoveMaker", "Peforms multiple moves on a given VRP encoding and updates the quality.")] 32 31 [StorableClass] … … 82 81 [StorableConstructor] 83 82 private LambdaInterchangeMoveMaker(bool deserializing) : base(deserializing) { } 83 protected LambdaInterchangeMoveMaker(LambdaInterchangeMoveMaker original, Cloner cloner) : base(original, cloner) { } 84 public override IDeepCloneable Clone(Cloner cloner) { 85 return new LambdaInterchangeMoveMaker(this, cloner); 86 } 84 87 85 88 public LambdaInterchangeMoveMaker() … … 112 115 DoubleValue moveQuality = MoveQualityParameter.ActualValue; 113 116 DoubleValue quality = QualityParameter.ActualValue; 114 117 115 118 //perform move 116 119 VRPToursParameter.ActualValue = move.MakeMove(); -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/PermutationEncoding.cs
r4352 r4687 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; … … 25 27 using HeuristicLab.Encodings.PermutationEncoding; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using System.Collections.Generic;28 using HeuristicLab.Problems.VehicleRouting.Encodings.General;29 using System;30 29 31 30 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 48 47 : base() { 49 48 } 49 protected PermutationEncoding(PermutationEncoding original, Cloner cloner) 50 : base(original, cloner) { 51 } 52 50 53 51 54 public int IndexOf(int city) { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/TourEncoding.cs
r4352 r4687 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using System.Drawing; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.PermutationEncoding;26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using System.Drawing;28 using System.Collections.Generic;29 28 30 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.General { … … 35 34 get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; } 36 35 } 37 36 38 37 #region IVRPEncoding Members 39 38 public virtual List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix = null, int maxVehicles = int.MaxValue) { … … 51 50 52 51 public int Cities { 53 get 54 { 52 get { 55 53 int cities = 0; 56 54 … … 75 73 : base() { 76 74 } 75 protected TourEncoding(TourEncoding original, Cloner cloner) 76 : base(original, cloner) { 77 } 77 78 78 79 public static void ConvertFrom(IVRPEncoding encoding, TourEncoding solution, ILookupParameter<DoubleMatrix> distanceMatrix) { … … 82 83 public static void ConvertFrom(List<int> route, TourEncoding solution) { 83 84 solution.Tours = new ItemList<Tour>(); 84 85 85 86 Tour tour = new Tour(); 86 87 for (int i = 0; i < route.Count; i++) { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuCrossover.cs
r4352 r4687 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab. Encodings.PermutationEncoding;24 using HeuristicLab.Optimization; 24 25 using HeuristicLab.Parameters; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 using HeuristicLab.Optimization;28 27 29 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { … … 34 33 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 35 34 } 36 35 37 36 [StorableConstructor] 38 37 protected ZhuCrossover(bool deserializing) : base(deserializing) { } 38 protected ZhuCrossover(ZhuCrossover original, Cloner cloner) 39 : base(original, cloner) { 40 } 39 41 40 42 public ZhuCrossover() … … 52 54 if (!(solution is ZhuEncoding)) { 53 55 parents[i] = ZhuEncoding.ConvertFrom(solution, 54 Cities, 56 Cities, 55 57 DueTimeParameter.ActualValue, 56 58 ServiceTimeParameter.ActualValue, -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuHeuristicCrossover1.cs
r4352 r4687 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding;24 using HeuristicLab.Parameters;25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 25 28 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { 29 27 [Item("ZhuHeuristicCrossover1", "The Zhu Heuristic Crossover (Version 1). It is implemented as described in Zhu, K.Q. (2000). A New Genetic Algorithm For VRPTW. Proceedings of the International Conference on Artificial Intelligence.")] 30 28 [StorableClass] 31 public sealed class ZhuHeuristicCrossover1 : ZhuCrossover { 29 public sealed class ZhuHeuristicCrossover1 : ZhuCrossover { 32 30 [StorableConstructor] 33 31 private ZhuHeuristicCrossover1(bool deserializing) : base(deserializing) { } 34 32 private ZhuHeuristicCrossover1(ZhuHeuristicCrossover1 original, Cloner cloner) 33 : base(original, cloner) { 34 } 35 public override IDeepCloneable Clone(Cloner cloner) { 36 return new ZhuHeuristicCrossover1(this, cloner); 37 } 35 38 public ZhuHeuristicCrossover1() 36 39 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuHeuristicCrossover2.cs
r4352 r4687 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 22 24 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding;24 using HeuristicLab.Parameters;25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 using System.Collections.Generic;28 26 29 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { 30 28 [Item("ZhuHeuristicCrossover2", "The Zhu Heuristic Crossover (Version 2). It is implemented as described in Zhu, K.Q. (2000). A New Genetic Algorithm For VRPTW. Proceedings of the International Conference on Artificial Intelligence.")] 31 29 [StorableClass] 32 public sealed class ZhuHeuristicCrossover2 : ZhuCrossover { 30 public sealed class ZhuHeuristicCrossover2 : ZhuCrossover { 33 31 [StorableConstructor] 34 32 private ZhuHeuristicCrossover2(bool deserializing) : base(deserializing) { } 35 33 private ZhuHeuristicCrossover2(ZhuHeuristicCrossover2 original, Cloner cloner) 34 : base(original, cloner) { 35 } 36 public override IDeepCloneable Clone(Cloner cloner) { 37 return new ZhuHeuristicCrossover2(this, cloner); 38 } 36 39 public ZhuHeuristicCrossover2() 37 40 : base() { … … 49 52 if (predecessor < 0) 50 53 predecessor = predecessor + child.Length; 51 54 52 55 int parent1Index = i; 53 56 int parent2Index = i; … … 56 59 if (i == breakPoint) { 57 60 child[i] = p1[parent1Index]; 58 61 59 62 p1.Remove(child[i]); 60 63 if (parent1Index >= p1.Count) -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuMergeCrossover1.cs
r4352 r4687 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding;24 using HeuristicLab.Parameters;25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 25 28 26 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { 29 27 [Item("ZhuMergeCrossover1", "The Zhu Merge Crossover (Version 1). It is implemented as described in Zhu, K.Q. (2000). A New Genetic Algorithm For VRPTW. Proceedings of the International Conference on Artificial Intelligence.")] 30 28 [StorableClass] 31 public sealed class ZhuMergeCrossover1 : ZhuCrossover { 29 public sealed class ZhuMergeCrossover1 : ZhuCrossover { 32 30 [StorableConstructor] 33 31 private ZhuMergeCrossover1(bool deserializing) : base(deserializing) { } 34 32 private ZhuMergeCrossover1(ZhuMergeCrossover1 original, Cloner cloner) 33 : base(original, cloner) { 34 } 35 public override IDeepCloneable Clone(Cloner cloner) { 36 return new ZhuMergeCrossover1(this, cloner); 37 } 35 38 public ZhuMergeCrossover1() 36 39 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuMergeCrossover2.cs
r4352 r4687 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using HeuristicLab.Common; 22 24 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.PermutationEncoding;24 using HeuristicLab.Parameters;25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 using System.Collections.Generic;28 26 29 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { 30 28 [Item("ZhuMergeCrossover2", "The Zhu Merge Crossover (Version 2). It is implemented as described in Zhu, K.Q. (2000). A New Genetic Algorithm For VRPTW. Proceedings of the International Conference on Artificial Intelligence.")] 31 29 [StorableClass] 32 public sealed class ZhuMergeCrossover2 : ZhuCrossover { 30 public sealed class ZhuMergeCrossover2 : ZhuCrossover { 33 31 [StorableConstructor] 34 32 private ZhuMergeCrossover2(bool deserializing) : base(deserializing) { } 35 33 private ZhuMergeCrossover2(ZhuMergeCrossover2 original, Cloner cloner) 34 : base(original, cloner) { 35 } 36 public override IDeepCloneable Clone(Cloner cloner) { 37 return new ZhuMergeCrossover2(this, cloner); 38 } 36 39 public ZhuMergeCrossover2() 37 40 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Crossovers/ZhuPermutationCrossover.cs
r4352 r4687 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Encodings.PermutationEncoding; 24 25 using HeuristicLab.Parameters; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 27 28 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { 29 29 [Item("ZhuPermutationCrossover", "An operator which crosses two VRP representations using a standard permutation operator. It is implemented as described in Zhu, K.Q. (2000). A New Genetic Algorithm For VRPTW. Proceedings of the International Conference on Artificial Intelligence.")] 30 30 [StorableClass] 31 public sealed class PrinsPermutationCrossover : ZhuCrossover { 31 public sealed class PrinsPermutationCrossover : ZhuCrossover { 32 32 public IValueLookupParameter<IPermutationCrossover> InnerCrossoverParameter { 33 33 get { return (IValueLookupParameter<IPermutationCrossover>)Parameters["InnerCrossover"]; } … … 36 36 [StorableConstructor] 37 37 private PrinsPermutationCrossover(bool deserializing) : base(deserializing) { } 38 38 private PrinsPermutationCrossover(PrinsPermutationCrossover original, Cloner cloner) 39 : base(original, cloner) { 40 } 41 public override IDeepCloneable Clone(Cloner cloner) { 42 return new PrinsPermutationCrossover(this, cloner); 43 } 39 44 public PrinsPermutationCrossover() 40 45 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Manipulators/ZhuManipulator.cs
r4352 r4687 20 20 #endregion 21 21 22 using HeuristicLab.Common; 22 23 using HeuristicLab.Core; 23 using HeuristicLab. Encodings.PermutationEncoding;24 using HeuristicLab.Optimization; 24 25 using HeuristicLab.Parameters; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Data;27 using HeuristicLab.Optimization;28 27 29 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { … … 34 33 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 35 34 } 36 37 35 [StorableConstructor] 38 36 protected ZhuManipulator(bool deserializing) : base(deserializing) { } 37 protected ZhuManipulator(ZhuManipulator original, Cloner cloner) 38 : base(original, cloner) { 39 } 40 39 41 40 42 public ZhuManipulator() … … 49 51 if (!(solution is ZhuEncoding)) { 50 52 VRPToursParameter.ActualValue = ZhuEncoding.ConvertFrom(solution, 51 Cities, 53 Cities, 52 54 DueTimeParameter.ActualValue, 53 55 ServiceTimeParameter.ActualValue, -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/Manipulators/ZhuPermutationManipulator.cs
r4352 r4687 36 36 [StorableConstructor] 37 37 private ZhuPermutationManipulator(bool deserializing) : base(deserializing) { } 38 38 private ZhuPermutationManipulator(ZhuPermutationManipulator original, Cloner cloner) 39 : base(original, cloner) { 40 } 41 public override IDeepCloneable Clone(Cloner cloner) { 42 return new ZhuPermutationManipulator(this, cloner); 43 } 39 44 public ZhuPermutationManipulator() 40 45 : base() { -
branches/CloningRefactoring/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Zhu/ZhuEncoding.cs
r4352 r4687 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; … … 25 27 using HeuristicLab.Encodings.PermutationEncoding; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using System.Collections.Generic;28 29 using HeuristicLab.Problems.VehicleRouting.Encodings.General; 29 using System;30 30 31 31 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { … … 44 44 [Storable] 45 45 DoubleArray dueTimeArray; 46 46 47 47 [Storable] 48 48 DoubleArray serviceTimeArray; … … 50 50 [Storable] 51 51 DoubleArray readyTimeArray; 52 52 53 53 [Storable] 54 54 DoubleArray demandArray; … … 75 75 distanceMatrix, 76 76 useDistanceMatrix)) { 77 78 79 77 newTour.Cities.Remove(city); 78 if (newTour.Cities.Count > 0) 79 result.Add(newTour); 80 80 81 82 81 newTour = new Tour(); 82 newTour.Cities.Add(city); 83 83 } 84 84 } … … 124 124 #endregion 125 125 126 public override IDeepCloneable Clone(HeuristicLab.Common.Cloner cloner) {127 ZhuEncoding clone = new ZhuEncoding(128 new Permutation(this.PermutationType, this.array), cities,129 dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,130 coordinates, useDistanceMatrix);131 132 cloner.RegisterClonedObject(this, clone);133 clone.readOnly = readOnly;134 return clone;135 }136 137 public ZhuEncoding(Permutation permutation, int cities,138 DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,139 DoubleMatrix coordinates, BoolValue useDistanceMatrix)140 : base(permutation) {141 this.cities = cities;142 this.dueTimeArray = dueTimeArray;143 this.serviceTimeArray = serviceTimeArray;144 this.readyTimeArray = readyTimeArray;145 this.demandArray = demandArray;146 this.capacity = capacity;147 this.coordinates = coordinates;148 this.useDistanceMatrix = useDistanceMatrix;149 }150 151 126 [StorableConstructor] 152 127 private ZhuEncoding(bool serializing) 153 128 : base(serializing) { 129 } 130 131 protected ZhuEncoding(ZhuEncoding original, Cloner cloner) 132 : base(original, cloner) { 133 this.cities = original.cities; 134 this.dueTimeArray = original.dueTimeArray; 135 this.serviceTimeArray = original.serviceTimeArray; 136 this.readyTimeArray = original.readyTimeArray; 137 this.demandArray = original.demandArray; 138 this.capacity = original.capacity; 139 this.coordinates = original.coordinates; 140 this.useDistanceMatrix = original.useDistanceMatrix; 141 } 142 public override IDeepCloneable Clone(Cloner cloner) { 143 return new ZhuEncoding(this, cloner); 154 144 } 155 145 … … 171 161 } 172 162 173 public static ZhuEncoding ConvertFrom(List<int> routeParam, int cities, 163 public static ZhuEncoding ConvertFrom(List<int> routeParam, int cities, 174 164 DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity, 175 165 DoubleMatrix coordinates, BoolValue useDistanceMatrix) { … … 183 173 184 174 return new ZhuEncoding( 185 new Permutation(PermutationTypes.RelativeUndirected, route.ToArray()), cities, 175 new Permutation(PermutationTypes.RelativeUndirected, route.ToArray()), cities, 186 176 dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity, 187 177 coordinates, useDistanceMatrix);
Note: See TracChangeset
for help on using the changeset viewer.