Changeset 11277
- Timestamp:
- 08/12/14 14:36:35 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs
r11275 r11277 40 40 public class OrienteeringProblem 41 41 : SingleObjectiveHeuristicOptimizationProblem<IOrienteeringEvaluator, IIntegerVectorCreator>, 42 IStorableContent, IProblemInstanceConsumer< CVRPData>, IProblemInstanceConsumer<OPData> {42 IStorableContent, IProblemInstanceConsumer<OPData>, IProblemInstanceConsumer<TSPData>, IProblemInstanceConsumer<CVRPData> { 43 43 44 44 public string Filename { get; set; } … … 334 334 } 335 335 336 public void Load( CVRPData data) {337 if (data.Coordinates == null )338 throw new InvalidDataException("The given instance specifies no coordinates !");339 if (data.Coordinates .GetLength(1) != 2)336 public void Load(OPData data) { 337 if (data.Coordinates == null && data.Distances == null) 338 throw new InvalidDataException("The given instance specifies no coordinates or distance matrix!"); 339 if (data.Coordinates != null && data.Coordinates.GetLength(1) != 2) 340 340 throw new InvalidDataException("The coordinates of the given instance are not in the right format, there need to be one row for each customer and two columns for the x and y coordinates."); 341 341 … … 347 347 Description = data.Description; 348 348 349 Coordinates = new DoubleMatrix(data.Coordinates); 349 Coordinates = data.Coordinates != null ? new DoubleMatrix(data.Coordinates) : null; 350 if (data.Distances != null) 351 DistanceMatrix = new DistanceMatrix(data.Distances); 352 else 353 DistanceMatrix = new DistanceMatrix(data.GetDistanceMatrix()); 354 355 StartingPoint = new IntValue(data.StartingPoint); 356 TerminusPoint = new IntValue(data.TerminusPoint); 357 358 MaximumDistance = new DoubleValue(data.MaximumDistance); 359 Scores = new DoubleArray(data.Scores); 360 } 361 362 public void Load(TSPData data) { 363 if (data.Coordinates == null && data.Distances == null) 364 throw new InvalidDataException("The given instance specifies no coordinates or distance matrix!"); 365 if (data.Coordinates != null && data.Coordinates.GetLength(1) != 2) 366 throw new InvalidDataException("The coordinates of the given instance are not in the right format, there need to be one row for each customer and two columns for the x and y coordinates."); 367 368 // Clear old solutions 369 BestKnownQuality = null; 370 BestKnownSolution = null; 371 372 Name = data.Name; 373 Description = data.Description; 374 375 Coordinates = data.Coordinates != null ? new DoubleMatrix(data.Coordinates) : null; 376 if (data.Distances != null) 377 DistanceMatrix = new DistanceMatrix(data.Distances); 378 else 379 DistanceMatrix = new DistanceMatrix(data.GetDistanceMatrix()); 380 381 StartingPoint = new IntValue(0); // First city is interpreted as start point 382 TerminusPoint = new IntValue(data.Dimension - 1); // Last city is interpreted als end point 383 384 MaximumDistance = new DoubleValue(DistanceMatrix[0, data.Dimension - 1] * 10.0); // distance from start to end first to last city is interpreted as maximum distance 385 Scores = new DoubleArray(Enumerable.Repeat(1.0, data.Dimension).ToArray()); // all scores are 1 386 } 387 388 public void Load(CVRPData data) { 389 if (data.Coordinates == null && data.Distances == null) 390 throw new InvalidDataException("The given instance specifies no coordinates or distance matrix!"); 391 if (data.Coordinates != null && data.Coordinates.GetLength(1) != 2) 392 throw new InvalidDataException("The coordinates of the given instance are not in the right format, there need to be one row for each customer and two columns for the x and y coordinates."); 393 394 // Clear old solutions 395 BestKnownQuality = null; 396 BestKnownSolution = null; 397 398 Name = data.Name; 399 Description = data.Description; 400 401 Coordinates = data.Coordinates != null ? new DoubleMatrix(data.Coordinates) : null; 350 402 DistanceMatrix = data.Distances != null 351 403 ? new DistanceMatrix(data.Distances) … … 360 412 OnReset(); 361 413 } 362 363 public void Load(OPData data) {364 if (data.Coordinates == null)365 throw new InvalidDataException("The given instance specifies no coordinates!");366 if (data.Coordinates.GetLength(1) != 2)367 throw new InvalidDataException("The coordinates of the given instance are not in the right format, there need to be one row for each customer and two columns for the x and y coordinates.");368 369 // Clear old solutions370 BestKnownQuality = null;371 BestKnownSolution = null;372 373 Name = data.Name;374 Description = data.Description;375 376 Coordinates = new DoubleMatrix(data.Coordinates);377 if (data.Distances != null)378 DistanceMatrix = new DistanceMatrix(data.Distances);379 else380 data.GetDistanceMatrix();381 382 StartingPoint = new IntValue(data.StartingPoint);383 TerminusPoint = new IntValue(data.TerminusPoint);384 385 MaximumDistance = new DoubleValue(data.MaximumDistance);386 Scores = new DoubleArray(data.Scores);387 }388 414 } 389 415 }
Note: See TracChangeset
for help on using the changeset viewer.