Changeset 8649 for trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/CVRPTWInterpreter.cs
- Timestamp:
- 09/14/12 10:03:04 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/CVRPTWInterpreter.cs
r8053 r8649 24 24 using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin; 25 25 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 26 using HeuristicLab.Problems.VehicleRouting.Interfaces; 27 using System; 26 28 27 29 namespace HeuristicLab.Problems.VehicleRouting.Interpreters { 28 public class CVRPTWInterpreter : IVRPDataInterpreter<CVRPTWData> { 29 public VRPInstanceDescription Interpret(IVRPData data) { 30 CVRPTWData cvrpData = data as CVRPTWData; 30 public class CVRPTWInterpreter: CVRPInterpreter, IVRPDataInterpreter<CVRPTWData> { 31 public override Type GetDataType() { 32 return typeof(CVRPTWData); 33 } 34 35 protected override IVRPProblemInstance CreateProblemInstance() { 36 return new CVRPTWProblemInstance(); 37 } 31 38 32 VRPInstanceDescription result = new VRPInstanceDescription(); 33 result.Name = cvrpData.Name; 34 result.Description = cvrpData.Description; 39 protected override void Interpret(IVRPData data, IVRPProblemInstance problemInstance) { 40 base.Interpret(data, problemInstance); 35 41 36 CVRPTWProblemInstance problem = new CVRPTWProblemInstance(); 37 if (cvrpData.Coordinates != null) 38 problem.Coordinates = new DoubleMatrix(cvrpData.Coordinates); 39 if (cvrpData.MaximumVehicles != null) 40 problem.Vehicles.Value = (int)cvrpData.MaximumVehicles; 41 else 42 problem.Vehicles.Value = cvrpData.Dimension - 1; 43 problem.Capacity.Value = cvrpData.Capacity; 44 problem.Demand = new DoubleArray(cvrpData.Demands); 45 if (cvrpData.DistanceMeasure != DistanceMeasure.Euclidean) { 46 problem.UseDistanceMatrix.Value = true; 47 problem.DistanceMatrix = new DoubleMatrix(cvrpData.GetDistanceMatrix()); 48 } 49 problem.ReadyTime = new DoubleArray(cvrpData.ReadyTimes); 50 problem.ServiceTime = new DoubleArray(cvrpData.ServiceTimes); 51 problem.DueTime = new DoubleArray(cvrpData.DueTimes); 52 result.ProblemInstance = problem; 42 CVRPTWData cvrptwData = data as CVRPTWData; 43 CVRPTWProblemInstance problem = problemInstance as CVRPTWProblemInstance; 53 44 54 result.BestKnownQuality = cvrpData.BestKnownQuality; 55 if (cvrpData.BestKnownTour != null) { 56 PotvinEncoding solution = new PotvinEncoding(problem); 57 58 for (int i = 0; i < cvrpData.BestKnownTour.GetLength(0); i++) { 59 Tour tour = new Tour(); 60 solution.Tours.Add(tour); 61 62 foreach (int stop in cvrpData.BestKnownTour[i]) { 63 tour.Stops.Add(stop + 1); 64 } 65 } 66 67 result.BestKnownSolution = solution; 68 } 69 70 return result; 45 problem.ReadyTime = new DoubleArray(cvrptwData.ReadyTimes); 46 problem.ServiceTime = new DoubleArray(cvrptwData.ServiceTimes); 47 problem.DueTime = new DoubleArray(cvrptwData.DueTimes); 71 48 } 72 49 }
Note: See TracChangeset
for help on using the changeset viewer.