Changeset 17717 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu
- Timestamp:
- 08/05/20 04:37:37 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuMergeCrossover1.cs
r17698 r17717 20 20 #endregion 21 21 22 using HEAL.Attic; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 25 using HeuristicLab.Data; 25 using HEAL.Attic; 26 using HeuristicLab.Problems.VehicleRouting.Variants; 26 using HeuristicLab.Problems.VehicleRouting.Interfaces; 27 27 28 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/Crossovers/ZhuMergeCrossover2.cs
r17698 r17717 21 21 22 22 using System.Collections.Generic; 23 using HEAL.Attic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; 26 using HEAL.Attic; 27 using HeuristicLab.Problems.VehicleRouting.Variants; 27 using HeuristicLab.Problems.VehicleRouting.Interfaces; 28 28 29 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/IZhuOperator.cs
r17226 r17717 20 20 #endregion 21 21 22 using HeuristicLab.Problems.VehicleRouting.Variants;23 22 using HEAL.Attic; 23 using HeuristicLab.Problems.VehicleRouting.Interfaces; 24 24 25 25 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Zhu { 26 26 [StorableType("CD11FA3C-3B50-4710-AAFC-32C9C61B3321")] 27 public interface IZhuOperator : 28 ISingleDepotOperator, IHomogenousCapacitatedOperator, ITimeWindowedOperator { 27 public interface IZhuOperator : IGeneralVRPOperator { 29 28 } 30 29 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Zhu/ZhuEncodedSolution.cs
r17714 r17717 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; … … 114 115 public static ZhuEncodedSolution ConvertFrom(IVRPEncodedSolution encoding, IVRPProblemInstance problemInstance) { 115 116 List<Tour> tours = encoding.GetTours(); 116 List<int> route = new List<int>(); 117 var count = tours.Sum(x => x.Stops.Count); 118 var route = new int[count]; 117 119 120 var i = 0; 118 121 foreach (Tour tour in tours) { 119 122 foreach (int city in tour.Stops) 120 route .Add(city - 1);123 route[i++] = city - 1; 121 124 } 122 125 123 126 return new ZhuEncodedSolution( 124 new Permutation(PermutationTypes.RelativeUndirected, route .ToArray()), problemInstance);127 new Permutation(PermutationTypes.RelativeUndirected, route), problemInstance); 125 128 } 126 129 127 130 public static ZhuEncodedSolution ConvertFrom(List<int> routeParam, IVRPProblemInstance problemInstance) { 128 List<int> route = new List<int>(routeParam); 129 130 while (route.Remove(0)) { //remove all delimiters (0) 131 } 132 133 for (int i = 0; i < route.Count; i++) 134 route[i]--; 131 var route = routeParam.Where(x => x != 0).Select(x => x - 1).ToArray(); 135 132 136 133 return new ZhuEncodedSolution( 137 new Permutation(PermutationTypes.RelativeUndirected, route .ToArray()), problemInstance);134 new Permutation(PermutationTypes.RelativeUndirected, route), problemInstance); 138 135 } 139 136 }
Note: See TracChangeset
for help on using the changeset viewer.