Changeset 7538 for branches/GeneralizedQAP/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs
- Timestamp:
- 03/01/12 15:15:22 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs
r7523 r7538 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using System.Linq; 25 26 using System.Reflection; … … 27 28 28 29 namespace HeuristicLab.Problems.Instances.CordeauGQAP { 29 public class CordeauGQAPInstanceProvider : ProblemInstanceProvider< IGQAPInstance> {30 public class CordeauGQAPInstanceProvider : ProblemInstanceProvider<GQAPInstance> { 30 31 public override string Name { 31 32 get { return "Cordeau et al. GQAP instances"; } … … 56 57 } 57 58 58 public override IGQAPInstance GetInstance(IInstanceDescriptor id) {59 public override GQAPInstance LoadInstance(IInstanceDescriptor id) { 59 60 var descriptor = (CordeauGQAPInstanceDescriptor)id; 60 var instance = new CordeauGQAPInstance();61 61 using (var stream = Assembly.GetExecutingAssembly() 62 62 .GetManifestResourceStream(descriptor.InstanceIdentifier)) { 63 63 var parser = new CordeauGQAPParser(); 64 64 parser.Parse(stream); 65 if (parser.Error != null) throw parser.Error; 66 instance.Equipments = parser.Equipments; 67 instance.Locations = parser.Locations; 68 instance.Demands = parser.Demands; 69 instance.Capacities = parser.Capacities; 70 instance.Weights = parser.Weights; 71 instance.Distances = parser.Distances; 72 instance.InstallationCosts = parser.InstallationCosts; 73 instance.TransportationCosts = parser.TransportationCosts; 65 var instance = Load(parser); 74 66 75 67 instance.Name = id.Name; 76 68 instance.Description = id.Description; 69 70 return instance; 77 71 } 72 } 73 74 public override GQAPInstance LoadInstance(string path) { 75 var parser = new CordeauGQAPParser(); 76 parser.Parse(path); 77 var instance = Load(parser); 78 79 instance.Name = Path.GetFileName(path); 80 instance.Description = "Loaded from file \"" + path + "\" on " + DateTime.Now.ToString(); 81 82 return instance; 83 } 84 85 public override void SaveInstance(GQAPInstance instance, string path) { 86 throw new NotSupportedException(); 87 } 88 89 private GQAPInstance Load(CordeauGQAPParser parser) { 90 var instance = new GQAPInstance(); 91 instance.Equipments = parser.Equipments; 92 instance.Locations = parser.Locations; 93 instance.Demands = parser.Demands; 94 instance.Capacities = parser.Capacities; 95 instance.Weights = parser.Weights; 96 instance.Distances = parser.Distances; 97 instance.InstallationCosts = parser.InstallationCosts; 98 instance.TransportationCosts = parser.TransportationCosts; 78 99 return instance; 79 100 }
Note: See TracChangeset
for help on using the changeset viewer.