- Timestamp:
- 05/23/12 17:32:07 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r7871 r7881 33 33 using HeuristicLab.PluginInfrastructure; 34 34 using HeuristicLab.Problems.VehicleRouting.Interfaces; 35 using HeuristicLab.Problems.VehicleRouting.Parsers;36 35 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 37 36 using HeuristicLab.Problems.VehicleRouting.Variants; … … 194 193 if (ProblemInstance != null) { 195 194 EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator; 195 IVRPCreator defaultCreator = null; 196 196 foreach (IVRPCreator creator in operators.Where(o => o is IVRPCreator)) { 197 197 solutionCreatorParameter.ValidValues.Add(creator); 198 } 198 if (creator is Encodings.Alba.RandomCreator) 199 defaultCreator = creator; 200 } 201 if (defaultCreator != null) 202 solutionCreatorParameter.Value = defaultCreator; 203 199 204 ProblemInstance.EvaluationChanged += new EventHandler(ProblemInstance_EvaluationChanged); 200 205 } … … 275 280 } 276 281 #endregion 277 278 public void ImportFromCordeau(string cordeauFileName) {279 CordeauParser parser = new CordeauParser(cordeauFileName);280 parser.Parse();281 282 this.Name = parser.ProblemName;283 MDCVRPTWProblemInstance problem = new MDCVRPTWProblemInstance();284 285 problem.Coordinates = new DoubleMatrix(parser.Coordinates);286 problem.Vehicles.Value = parser.Vehicles;287 problem.Capacity = new DoubleArray(parser.Capacity);288 problem.Demand = new DoubleArray(parser.Demands);289 problem.Depots.Value = parser.Depots;290 problem.VehicleDepotAssignment = new IntArray(parser.Vehicles);291 problem.ReadyTime = new DoubleArray(parser.Readytimes);292 problem.ServiceTime = new DoubleArray(parser.Servicetimes);293 problem.DueTime = new DoubleArray(parser.Duetimes);294 295 int depot = 0;296 int i = 0;297 while(i < parser.Vehicles) {298 problem.VehicleDepotAssignment[i] = depot;299 300 i++;301 if (i % (parser.Vehicles / parser.Depots) == 0)302 depot++;303 }304 305 this.ProblemInstance = problem;306 307 OnReset();308 }309 310 public void ImportFromLiLim(string liLimFileName) {311 LiLimParser parser = new LiLimParser(liLimFileName);312 parser.Parse();313 314 this.Name = parser.ProblemName;315 CVRPPDTWProblemInstance problem = new CVRPPDTWProblemInstance();316 317 problem.Coordinates = new DoubleMatrix(parser.Coordinates);318 problem.Vehicles.Value = parser.Vehicles;319 problem.Capacity.Value = parser.Capacity;320 problem.Demand = new DoubleArray(parser.Demands);321 problem.ReadyTime = new DoubleArray(parser.Readytimes);322 problem.DueTime = new DoubleArray(parser.Duetimes);323 problem.ServiceTime = new DoubleArray(parser.Servicetimes);324 problem.PickupDeliveryLocation = new IntArray(parser.PickupDeliveryLocations);325 326 this.ProblemInstance = problem;327 328 OnReset();329 }330 331 public void ImportFromSolomon(string solomonFileName) {332 SolomonParser parser = new SolomonParser(solomonFileName);333 parser.Parse();334 335 this.Name = parser.ProblemName;336 CVRPTWProblemInstance problem = new CVRPTWProblemInstance();337 338 problem.Coordinates = new DoubleMatrix(parser.Coordinates);339 problem.Vehicles.Value = parser.Vehicles;340 problem.Capacity.Value = parser.Capacity;341 problem.Demand = new DoubleArray(parser.Demands);342 problem.ReadyTime = new DoubleArray(parser.Readytimes);343 problem.DueTime = new DoubleArray(parser.Duetimes);344 problem.ServiceTime = new DoubleArray(parser.Servicetimes);345 346 this.ProblemInstance = problem;347 348 OnReset();349 }350 351 public void ImportFromTSPLib(string tspFileName) {352 TSPLIBParser parser = new TSPLIBParser(tspFileName);353 parser.Parse();354 355 this.Name = parser.Name;356 int problemSize = parser.Demands.Length;357 358 if (parser.Depot != 1) {359 ErrorHandling.ShowErrorDialog(new Exception("Invalid depot specification"));360 return;361 }362 363 if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D) {364 ErrorHandling.ShowErrorDialog(new Exception("Invalid weight type"));365 return;366 }367 368 CVRPTWProblemInstance problem = new CVRPTWProblemInstance();369 problem.Coordinates = new DoubleMatrix(parser.Vertices);370 if (parser.Vehicles != -1)371 problem.Vehicles.Value = parser.Vehicles;372 else373 problem.Vehicles.Value = problemSize - 1;374 problem.Capacity.Value = parser.Capacity;375 problem.Demand = new DoubleArray(parser.Demands);376 problem.ReadyTime = new DoubleArray(problemSize);377 problem.DueTime = new DoubleArray(problemSize);378 problem.ServiceTime = new DoubleArray(problemSize);379 380 for (int i = 0; i < problemSize; i++) {381 problem.ReadyTime[i] = 0;382 problem.DueTime[i] = int.MaxValue;383 problem.ServiceTime[i] = 0;384 }385 386 if (parser.Distance != -1) {387 problem.DueTime[0] = parser.Distance;388 }389 390 this.ProblemInstance = problem;391 392 OnReset();393 }394 395 public void ImportFromORLib(string orFileName) {396 ORLIBParser parser = new ORLIBParser(orFileName);397 parser.Parse();398 399 this.Name = parser.Name;400 int problemSize = parser.Demands.Length;401 402 CVRPProblemInstance problem = new CVRPProblemInstance();403 404 problem.Coordinates = new DoubleMatrix(parser.Vertices);405 problem.Vehicles.Value = problemSize - 1;406 problem.Capacity.Value = parser.Capacity;407 problem.Demand = new DoubleArray(parser.Demands);408 409 this.ProblemInstance = problem;410 411 OnReset();412 }413 282 414 283 private void InitializeRandomVRPInstance() { … … 482 351 483 352 OnReset(); 353 BestKnownQuality = null; 354 BestKnownSolution = null; 484 355 485 356 if (instance.BestKnownQuality != null) { … … 489 360 if (instance.BestKnownSolution != null) { 490 361 VRPSolution solution = new VRPSolution(ProblemInstance, instance.BestKnownSolution, new DoubleValue(0)); 491 BestKnownSolution Parameter.Value= solution;362 BestKnownSolution = solution; 492 363 } 493 364 } else {
Note: See TracChangeset
for help on using the changeset viewer.