- Timestamp:
- 05/22/12 17:37:33 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r7861 r7871 36 36 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 37 37 using HeuristicLab.Problems.VehicleRouting.Variants; 38 using HeuristicLab.Problems.Instances; 39 using System.Reflection; 40 using HeuristicLab.Problems.VehicleRouting.Interpreters; 38 41 39 42 namespace HeuristicLab.Problems.VehicleRouting { … … 41 44 [Creatable("Problems")] 42 45 [StorableClass] 43 public sealed class VehicleRoutingProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {46 public sealed class VehicleRoutingProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IProblemInstanceConsumer<IVRPData> { 44 47 public string Filename { get; set; } 45 48 … … 466 469 } 467 470 } 471 472 public void Load(IVRPData data) { 473 Type interpreterType = typeof(IVRPDataInterpreter<>).MakeGenericType(data.GetType()); 474 var interpreters = ApplicationManager.Manager.GetInstances(interpreterType); 475 if (interpreters.Count() > 0) { 476 IVRPDataInterpreter interpreter = interpreters.First() as IVRPDataInterpreter; 477 VRPInstanceDescription instance = interpreter.Interpret(data); 478 479 Name = instance.Name; 480 Description = instance.Description; 481 ProblemInstance = instance.ProblemInstance; 482 483 OnReset(); 484 485 if (instance.BestKnownQuality != null) { 486 BestKnownQuality = new DoubleValue((double)instance.BestKnownQuality); 487 } 488 489 if (instance.BestKnownSolution != null) { 490 VRPSolution solution = new VRPSolution(ProblemInstance, instance.BestKnownSolution, new DoubleValue(0)); 491 BestKnownSolutionParameter.Value = solution; 492 } 493 } else { 494 throw new Exception("Cannot find an interpreter for " + data.GetType()); 495 } 496 } 468 497 } 469 498 }
Note: See TracChangeset
for help on using the changeset viewer.