Changeset 17698 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu
- Timestamp:
- 07/24/20 00:58:42 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu
- Files:
-
- 1 added
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuCrossover.cs
r17226 r17698 48 48 } 49 49 50 protected abstract ZhuEncod ing Crossover(IRandom random, ZhuEncoding parent1, ZhuEncodingparent2);50 protected abstract ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2); 51 51 52 52 public override IOperation InstrumentedApply() { 53 ItemArray<IVRPEncod ing> parents = new ItemArray<IVRPEncoding>(ParentsParameter.ActualValue.Length);53 ItemArray<IVRPEncodedSolution> parents = new ItemArray<IVRPEncodedSolution>(ParentsParameter.ActualValue.Length); 54 54 for (int i = 0; i < ParentsParameter.ActualValue.Length; i++) { 55 IVRPEncod ingsolution = ParentsParameter.ActualValue[i];55 IVRPEncodedSolution solution = ParentsParameter.ActualValue[i]; 56 56 57 if (!(solution is ZhuEncod ing)) {58 parents[i] = ZhuEncod ing.ConvertFrom(solution, ProblemInstance);57 if (!(solution is ZhuEncodedSolution)) { 58 parents[i] = ZhuEncodedSolution.ConvertFrom(solution, ProblemInstance); 59 59 } else { 60 60 parents[i] = solution; … … 64 64 65 65 ChildParameter.ActualValue = 66 Crossover(RandomParameter.ActualValue, parents[0] as ZhuEncod ing, parents[1] as ZhuEncoding);66 Crossover(RandomParameter.ActualValue, parents[0] as ZhuEncodedSolution, parents[1] as ZhuEncodedSolution); 67 67 68 68 return base.InstrumentedApply(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuHeuristicCrossover1.cs
r17226 r17698 43 43 } 44 44 45 private void Swap(ZhuEncod ingindividual, int city1, int city2) {45 private void Swap(ZhuEncodedSolution individual, int city1, int city2) { 46 46 int index1 = individual.IndexOf(city1); 47 47 int index2 = individual.IndexOf(city2); … … 52 52 } 53 53 54 protected override ZhuEncod ing Crossover(IRandom random, ZhuEncoding parent1, ZhuEncodingparent2) {55 parent1 = parent1.Clone() as ZhuEncod ing;56 parent2 = parent2.Clone() as ZhuEncod ing;54 protected override ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2) { 55 parent1 = parent1.Clone() as ZhuEncodedSolution; 56 parent2 = parent2.Clone() as ZhuEncodedSolution; 57 57 58 ZhuEncod ing child = parent2.Clone() as ZhuEncoding;58 ZhuEncodedSolution child = parent2.Clone() as ZhuEncodedSolution; 59 59 60 60 if (parent1.Length != parent2.Length) -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuHeuristicCrossover2.cs
r17226 r17698 44 44 } 45 45 46 protected override ZhuEncod ing Crossover(IRandom random, ZhuEncoding parent1, ZhuEncodingparent2) {46 protected override ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2) { 47 47 List<int> p1 = new List<int>(parent1); 48 48 List<int> p2 = new List<int>(parent2); 49 49 50 ZhuEncod ing child = parent2.Clone() as ZhuEncoding;50 ZhuEncodedSolution child = parent2.Clone() as ZhuEncodedSolution; 51 51 52 52 if (parent1.Length != parent2.Length) -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuMergeCrossover1.cs
r17226 r17698 45 45 } 46 46 47 private void Swap(ZhuEncod ingindividual, int city1, int city2) {47 private void Swap(ZhuEncodedSolution individual, int city1, int city2) { 48 48 int index1 = individual.IndexOf(city1); 49 49 int index2 = individual.IndexOf(city2); … … 54 54 } 55 55 56 protected override ZhuEncod ing Crossover(IRandom random, ZhuEncoding parent1, ZhuEncodingparent2) {57 parent1 = parent1.Clone() as ZhuEncod ing;58 parent2 = parent2.Clone() as ZhuEncod ing;56 protected override ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2) { 57 parent1 = parent1.Clone() as ZhuEncodedSolution; 58 parent2 = parent2.Clone() as ZhuEncodedSolution; 59 59 60 ZhuEncod ing child = parent2.Clone() as ZhuEncoding;60 ZhuEncodedSolution child = parent2.Clone() as ZhuEncodedSolution; 61 61 62 62 if (parent1.Length != parent2.Length) -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuMergeCrossover2.cs
r17226 r17698 46 46 } 47 47 48 protected override ZhuEncod ing Crossover(IRandom random, ZhuEncoding parent1, ZhuEncodingparent2) {48 protected override ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2) { 49 49 List<int> p1 = new List<int>(parent1); 50 50 List<int> p2 = new List<int>(parent2); 51 51 52 ZhuEncod ing child = parent2.Clone() as ZhuEncoding;52 ZhuEncodedSolution child = parent2.Clone() as ZhuEncodedSolution; 53 53 54 54 if (parent1.Length != parent2.Length) -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuPermutationCrossover.cs
r17226 r17698 50 50 } 51 51 52 protected override ZhuEncod ing Crossover(IRandom random, ZhuEncoding parent1, ZhuEncodingparent2) {52 protected override ZhuEncodedSolution Crossover(IRandom random, ZhuEncodedSolution parent1, ZhuEncodedSolution parent2) { 53 53 //note - the inner crossover is called here and the result is converted to a prins representation 54 54 //some refactoring should be done here in the future - the crossover operation should be called directly 55 55 if (parent1.Length != parent2.Length) 56 return parent1.Clone() as ZhuEncod ing;56 return parent1.Clone() as ZhuEncodedSolution; 57 57 58 58 InnerCrossoverParameter.ActualValue.ParentsParameter.ActualName = ParentsParameter.ActualName; … … 66 66 ExecutionContext.Scope.Variables.Remove(childName); 67 67 68 return new ZhuEncod ing(permutation, ProblemInstance);68 return new ZhuEncodedSolution(permutation, ProblemInstance); 69 69 } else 70 70 return null; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Manipulators/ZhuManipulator.cs
r17226 r17698 48 48 } 49 49 50 protected abstract void Manipulate(IRandom random, ZhuEncod ingindividual);50 protected abstract void Manipulate(IRandom random, ZhuEncodedSolution individual); 51 51 52 52 public override IOperation InstrumentedApply() { 53 IVRPEncod ingsolution = VRPToursParameter.ActualValue;54 if (!(solution is ZhuEncod ing)) {55 VRPToursParameter.ActualValue = ZhuEncod ing.ConvertFrom(solution, ProblemInstance);53 IVRPEncodedSolution solution = VRPToursParameter.ActualValue; 54 if (!(solution is ZhuEncodedSolution)) { 55 VRPToursParameter.ActualValue = ZhuEncodedSolution.ConvertFrom(solution, ProblemInstance); 56 56 } 57 57 58 Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as ZhuEncod ing);58 Manipulate(RandomParameter.ActualValue, VRPToursParameter.ActualValue as ZhuEncodedSolution); 59 59 60 60 return base.InstrumentedApply(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Manipulators/ZhuPermutationManipulator.cs
r17226 r17698 50 50 } 51 51 52 protected override void Manipulate(IRandom random, ZhuEncod ingindividual) {52 protected override void Manipulate(IRandom random, ZhuEncodedSolution individual) { 53 53 InnerManipulatorParameter.ActualValue.PermutationParameter.ActualName = VRPToursParameter.ActualName; 54 54
Note: See TracChangeset
for help on using the changeset viewer.