Changeset 7538 for branches/GeneralizedQAP/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/ElloumiCTAPInstanceProvider.cs
- Timestamp:
- 03/01/12 15:15:22 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/ElloumiCTAPInstanceProvider.cs
r7482 r7538 28 28 29 29 namespace HeuristicLab.Problems.Instances.ElloumiCTAP { 30 public class ElloumiCTAPInstanceProvider : ProblemInstanceProvider< ICTAPInstance> {30 public class ElloumiCTAPInstanceProvider : ProblemInstanceProvider<CTAPInstance> { 31 31 public override string Name { 32 32 get { return "Elloumi's CTAP instances"; } … … 62 62 } 63 63 64 public override ICTAPInstance GetInstance(IInstanceDescriptor id) {64 public override CTAPInstance LoadInstance(IInstanceDescriptor id) { 65 65 var descriptor = (ElloumiCTAPInstanceDescriptor)id; 66 var instance = new ElloumiCTAPInstance();67 66 using (var stream = Assembly.GetExecutingAssembly() 68 67 .GetManifestResourceStream(descriptor.InstanceIdentifier)) { 69 ElloumiCTAPParser datParser = new ElloumiCTAPParser(); 70 datParser.Parse(stream); 71 if (datParser.Error != null) throw datParser.Error; 72 instance.Processors = datParser.Processors; 73 instance.Tasks = datParser.Tasks; 74 instance.ExecutionCosts = datParser.ExecutionCosts; 75 instance.CommunicationCosts = datParser.CommunicationCosts; 76 instance.MemoryRequirements = datParser.MemoryRequirements; 77 instance.MemoryCapacities = datParser.MemoryCapacities; 68 var parser = new ElloumiCTAPParser(); 69 parser.Parse(stream); 70 var instance = Load(parser); 78 71 79 72 instance.Name = id.Name; … … 91 84 } 92 85 } 86 return instance; 93 87 } 88 } 89 90 public override CTAPInstance LoadInstance(string path) { 91 var parser = new ElloumiCTAPParser(); 92 parser.Parse(path); 93 var instance = Load(parser); 94 instance.Name = Path.GetFileName(path); 95 instance.Description = "Loaded from file \"" + path + "\" on " + DateTime.Now.ToString(); 96 return instance; 97 } 98 99 public override void SaveInstance(CTAPInstance instance, string path) { 100 throw new NotSupportedException(); 101 } 102 103 private CTAPInstance Load(ElloumiCTAPParser parser) { 104 var instance = new CTAPInstance(); 105 instance.Processors = parser.Processors; 106 instance.Tasks = parser.Tasks; 107 instance.ExecutionCosts = parser.ExecutionCosts; 108 instance.CommunicationCosts = parser.CommunicationCosts; 109 instance.MemoryRequirements = parser.MemoryRequirements; 110 instance.MemoryCapacities = parser.MemoryCapacities; 94 111 return instance; 95 112 }
Note: See TracChangeset
for help on using the changeset viewer.