Changeset 7638
- Timestamp:
- 03/20/12 11:06:32 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 5 added
- 381 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs
r7548 r7638 26 26 using System.Reflection; 27 27 using System.Text.RegularExpressions; 28 using ICSharpCode.SharpZipLib.Zip; 28 29 29 30 namespace HeuristicLab.Problems.Instances.CordeauGQAP { … … 49 50 } 50 51 52 private const string FileName = "CordeauGQAP"; 53 51 54 public override IEnumerable<IDataDescriptor> GetDataDescriptors() { 52 return Assembly.GetExecutingAssembly() 53 .GetManifestResourceNames() 54 .Where(x => x.EndsWith(".txt")) 55 .OrderBy(x => x) 56 .Select(x => new CordeauGQAPDataDescriptor(GetPrettyName(x), GetDescription(), x)); 55 var instanceArchiveName = GetResourceName(FileName + @"\.zip"); 56 if (String.IsNullOrEmpty(instanceArchiveName)) yield break; 57 58 using (var instanceStream = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 59 foreach (var entry in GetZipContents(instanceStream).OrderBy(x => x)) { 60 yield return new CordeauGQAPDataDescriptor(Path.GetFileNameWithoutExtension(entry), GetDescription(), entry); 61 } 62 } 57 63 } 58 64 59 65 public override GQAPData LoadData(IDataDescriptor id) { 60 66 var descriptor = (CordeauGQAPDataDescriptor)id; 61 using (var stream = Assembly.GetExecutingAssembly() 62 .GetManifestResourceStream(descriptor.InstanceIdentifier)) { 63 var parser = new CordeauGQAPParser(); 64 parser.Parse(stream); 65 var instance = Load(parser); 67 var instanceArchiveName = GetResourceName(FileName + @"\.zip"); 68 using (var instancesZipFile = new ZipFile(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 69 var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier); 70 using (var stream = instancesZipFile.GetInputStream(entry)) { 71 var parser = new CordeauGQAPParser(); 72 parser.Parse(stream); 73 var instance = Load(parser); 66 74 67 instance.Name = id.Name;68 instance.Description = id.Description;75 instance.Name = id.Name; 76 instance.Description = id.Description; 69 77 70 return instance; 78 return instance; 79 } 71 80 } 72 81 } … … 100 109 } 101 110 102 private string GetPrettyName(string instanceIdentifier) {103 return Regex.Match(instanceIdentifier, GetType().Namespace + @"\.Data\.(.*)\.txt").Groups[1].Captures[0].Value;104 }105 106 111 private string GetDescription() { 107 112 return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + "."; 108 113 } 114 115 protected virtual string GetResourceName(string fileName) { 116 return Assembly.GetExecutingAssembly().GetManifestResourceNames() 117 .Where(x => Regex.Match(x, @".*\.Data\." + fileName).Success).SingleOrDefault(); 118 } 119 120 protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) { 121 ZipEntry entry; 122 while ((entry = zipFile.GetNextEntry()) != null) { 123 yield return entry.Name; 124 } 125 } 109 126 } 110 127 } -
trunk/sources/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/HeuristicLab.Problems.Instances.CordeauGQAP-3.3.csproj
r7600 r7638 102 102 </PropertyGroup> 103 103 <ItemGroup> 104 <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL" /> 104 105 <Reference Include="System" /> 105 106 <Reference Include="System.Core" /> … … 107 108 </ItemGroup> 108 109 <ItemGroup> 110 <None Include="Data\CordeauGQAP.zip" /> 109 111 <None Include="Plugin.cs.frame" /> 110 112 <Compile Include="CordeauGQAPParser.cs" /> … … 132 134 </ProjectReference> 133 135 </ItemGroup> 134 <ItemGroup>135 <EmbeddedResource Include="Data\20-15-35.txt" />136 <EmbeddedResource Include="Data\20-15-55.txt" />137 <EmbeddedResource Include="Data\20-15-75.txt" />138 <EmbeddedResource Include="Data\30-06-95.txt" />139 <EmbeddedResource Include="Data\30-07-75.txt" />140 <EmbeddedResource Include="Data\30-08-55.txt" />141 <EmbeddedResource Include="Data\30-10-65.txt" />142 <EmbeddedResource Include="Data\30-20-35.txt" />143 <EmbeddedResource Include="Data\30-20-55.txt" />144 <EmbeddedResource Include="Data\30-20-75.txt" />145 <EmbeddedResource Include="Data\30-20-95.txt" />146 <EmbeddedResource Include="Data\35-15-35.txt" />147 <EmbeddedResource Include="Data\35-15-55.txt" />148 <EmbeddedResource Include="Data\35-15-75.txt" />149 <EmbeddedResource Include="Data\35-15-95.txt" />150 <EmbeddedResource Include="Data\40-07-75.txt" />151 <EmbeddedResource Include="Data\40-09-95.txt" />152 <EmbeddedResource Include="Data\40-10-65.txt" />153 <EmbeddedResource Include="Data\50-10-65.txt" />154 <EmbeddedResource Include="Data\50-10-75.txt" />155 <EmbeddedResource Include="Data\50-10-95.txt" />156 </ItemGroup>157 136 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 158 137 <PropertyGroup> -
trunk/sources/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/ElloumiCTAPInstanceProvider.cs
r7548 r7638 26 26 using System.Reflection; 27 27 using System.Text.RegularExpressions; 28 using ICSharpCode.SharpZipLib.Zip; 28 29 29 30 namespace HeuristicLab.Problems.Instances.ElloumiCTAP { … … 49 50 } 50 51 52 private const string FileName = "ElloumiCTAP"; 53 51 54 public override IEnumerable<IDataDescriptor> GetDataDescriptors() { 52 var solutions = Assembly.GetExecutingAssembly() 53 .GetManifestResourceNames() 54 .Where(x => x.EndsWith(".sol")) 55 .ToDictionary(x => Path.GetFileNameWithoutExtension(x) + ".dat", x => x); 55 Dictionary<string, string> solutions = new Dictionary<string, string>(); 56 var solutionsArchiveName = GetResourceName(FileName + @"\.sol\.zip"); 57 if (!String.IsNullOrEmpty(solutionsArchiveName)) { 58 using (var solutionsZipFile = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) { 59 foreach (var entry in GetZipContents(solutionsZipFile)) 60 solutions.Add(Path.GetFileNameWithoutExtension(entry) + ".dat", entry); 61 } 62 } 63 var instanceArchiveName = GetResourceName(FileName + @"\.dat\.zip"); 64 if (String.IsNullOrEmpty(instanceArchiveName)) yield break; 56 65 57 return Assembly.GetExecutingAssembly()58 .GetManifestResourceNames()59 .Where(x => x.EndsWith(".dat"))60 .OrderBy(x => x)61 .Select(x => new ElloumiCTAPDataDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty));66 using (var instanceStream = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 67 foreach (var entry in GetZipContents(instanceStream).OrderBy(x => x)) { 68 yield return new ElloumiCTAPDataDescriptor(Path.GetFileNameWithoutExtension(entry), GetDescription(), entry, solutions.ContainsKey(entry) ? solutions[entry] : String.Empty); 69 } 70 } 62 71 } 63 72 64 73 public override CTAPData LoadData(IDataDescriptor id) { 65 74 var descriptor = (ElloumiCTAPDataDescriptor)id; 66 using (var stream = Assembly.GetExecutingAssembly() 67 .GetManifestResourceStream(descriptor.InstanceIdentifier)) { 68 var parser = new ElloumiCTAPParser(); 69 parser.Parse(stream); 70 var instance = Load(parser); 75 var instanceArchiveName = GetResourceName(FileName + @"\.dat\.zip"); 76 using (var instancesZipFile = new ZipFile(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 77 var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier); 78 using (var stream = instancesZipFile.GetInputStream(entry)) { 79 var parser = new ElloumiCTAPParser(); 80 parser.Parse(stream); 81 var instance = Load(parser); 71 82 72 instance.Name = id.Name;73 instance.Description = id.Description;83 instance.Name = id.Name; 84 instance.Description = id.Description; 74 85 75 if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) { 76 using (Stream solStream = Assembly.GetExecutingAssembly() 77 .GetManifestResourceStream(descriptor.SolutionIdentifier)) { 78 ElloumiCTAPSolutionParser slnParser = new ElloumiCTAPSolutionParser(); 79 slnParser.Parse(solStream, instance.MemoryRequirements.Length); 80 if (slnParser.Error != null) throw slnParser.Error; 86 if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) { 87 var solutionsArchiveName = GetResourceName(FileName + @"\.sol\.zip"); 88 using (var solutionsZipFile = new ZipFile(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) { 89 entry = solutionsZipFile.GetEntry(descriptor.SolutionIdentifier); 90 using (var solStream = solutionsZipFile.GetInputStream(entry)) { 91 ElloumiCTAPSolutionParser slnParser = new ElloumiCTAPSolutionParser(); 92 slnParser.Parse(solStream, instance.MemoryRequirements.Length); 93 if (slnParser.Error != null) throw slnParser.Error; 81 94 82 instance.BestKnownAssignment = slnParser.Assignment; 83 instance.BestKnownQuality = slnParser.Quality; 95 instance.BestKnownAssignment = slnParser.Assignment; 96 instance.BestKnownQuality = slnParser.Quality; 97 } 98 } 84 99 } 100 return instance; 85 101 } 86 return instance;87 102 } 88 103 } … … 119 134 return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + "."; 120 135 } 136 137 protected virtual string GetResourceName(string fileName) { 138 return Assembly.GetExecutingAssembly().GetManifestResourceNames() 139 .Where(x => Regex.Match(x, @".*\.Data\." + fileName).Success).SingleOrDefault(); 140 } 141 142 protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) { 143 ZipEntry entry; 144 while ((entry = zipFile.GetNextEntry()) != null) { 145 yield return entry.Name; 146 } 147 } 121 148 } 122 149 } -
trunk/sources/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/HeuristicLab.Problems.Instances.ElloumiCTAP-3.3.csproj
r7600 r7638 102 102 </PropertyGroup> 103 103 <ItemGroup> 104 <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL" /> 104 105 <Reference Include="System" /> 105 106 <Reference Include="System.Core" /> … … 108 109 <ItemGroup> 109 110 <Compile Include="ElloumiCTAPSolutionParser.cs" /> 110 <EmbeddedResource Include="Data\tass1003Aa.dat" /> 111 <EmbeddedResource Include="Data\tass1003Ab.dat" /> 112 <EmbeddedResource Include="Data\tass1003Ac.dat" /> 113 <EmbeddedResource Include="Data\tass1003Ad.dat" /> 114 <EmbeddedResource Include="Data\tass1003Ae.dat" /> 115 <EmbeddedResource Include="Data\tass1003Ba.dat" /> 116 <EmbeddedResource Include="Data\tass1003Bb.dat" /> 117 <EmbeddedResource Include="Data\tass1003Bc.dat" /> 118 <EmbeddedResource Include="Data\tass1003Bd.dat" /> 119 <EmbeddedResource Include="Data\tass1003Be.dat" /> 120 <EmbeddedResource Include="Data\tass1003Ca.dat" /> 121 <EmbeddedResource Include="Data\tass1003Cb.dat" /> 122 <EmbeddedResource Include="Data\tass1003Cc.dat" /> 123 <EmbeddedResource Include="Data\tass1003Cd.dat" /> 124 <EmbeddedResource Include="Data\tass1003Ce.dat" /> 125 <EmbeddedResource Include="Data\tass1003Da.dat" /> 126 <EmbeddedResource Include="Data\tass1003Db.dat" /> 127 <EmbeddedResource Include="Data\tass1003Dc.dat" /> 128 <EmbeddedResource Include="Data\tass1003Dd.dat" /> 129 <EmbeddedResource Include="Data\tass1003De.dat" /> 130 <EmbeddedResource Include="Data\tass2005Aa.dat" /> 131 <EmbeddedResource Include="Data\tass2005Ab.dat" /> 132 <EmbeddedResource Include="Data\tass2005Ac.dat" /> 133 <EmbeddedResource Include="Data\tass2005Ad.dat" /> 134 <EmbeddedResource Include="Data\tass2005Ae.dat" /> 135 <EmbeddedResource Include="Data\tass2005Ba.dat" /> 136 <EmbeddedResource Include="Data\tass2005Bb.dat" /> 137 <EmbeddedResource Include="Data\tass2005Bc.dat" /> 138 <EmbeddedResource Include="Data\tass2005Bd.dat" /> 139 <EmbeddedResource Include="Data\tass2005Be.dat" /> 140 <EmbeddedResource Include="Data\tass2005Ca.dat" /> 141 <EmbeddedResource Include="Data\tass2005Cb.dat" /> 142 <EmbeddedResource Include="Data\tass2005Cc.dat" /> 143 <EmbeddedResource Include="Data\tass2005Cd.dat" /> 144 <EmbeddedResource Include="Data\tass2005Ce.dat" /> 145 <EmbeddedResource Include="Data\tass2005Da.dat" /> 146 <EmbeddedResource Include="Data\tass2005Db.dat" /> 147 <EmbeddedResource Include="Data\tass2005Dc.dat" /> 148 <EmbeddedResource Include="Data\tass2005Dd.dat" /> 149 <EmbeddedResource Include="Data\tass2005De.dat" /> 150 <EmbeddedResource Include="Data\tass2408Aa.dat" /> 151 <EmbeddedResource Include="Data\tass2408Ca.dat" /> 152 <EmbeddedResource Include="Data\tassc1003Aa.dat" /> 153 <EmbeddedResource Include="Data\tassc1003Ab.dat" /> 154 <EmbeddedResource Include="Data\tassc1003Ac.dat" /> 155 <EmbeddedResource Include="Data\tassc1003Ad.dat" /> 156 <EmbeddedResource Include="Data\tassc1003Ae.dat" /> 157 <EmbeddedResource Include="Data\tassc1003Ba.dat" /> 158 <EmbeddedResource Include="Data\tassc1003Bb.dat" /> 159 <EmbeddedResource Include="Data\tassc1003Bc.dat" /> 160 <EmbeddedResource Include="Data\tassc1003Bd.dat" /> 161 <EmbeddedResource Include="Data\tassc1003Be.dat" /> 162 <EmbeddedResource Include="Data\tassc1003Ca.dat" /> 163 <EmbeddedResource Include="Data\tassc1003Cb.dat" /> 164 <EmbeddedResource Include="Data\tassc1003Cc.dat" /> 165 <EmbeddedResource Include="Data\tassc1003Cd.dat" /> 166 <EmbeddedResource Include="Data\tassc1003Ce.dat" /> 167 <EmbeddedResource Include="Data\tassc1003Da.dat" /> 168 <EmbeddedResource Include="Data\tassc1003Db.dat" /> 169 <EmbeddedResource Include="Data\tassc1003Dc.dat" /> 170 <EmbeddedResource Include="Data\tassc1003Dd.dat" /> 171 <EmbeddedResource Include="Data\tassc1003De.dat" /> 172 <EmbeddedResource Include="Data\tassc2005Aa.dat" /> 173 <EmbeddedResource Include="Data\tassc2005Ab.dat" /> 174 <EmbeddedResource Include="Data\tassc2005Ac.dat" /> 175 <EmbeddedResource Include="Data\tassc2005Ad.dat" /> 176 <EmbeddedResource Include="Data\tassc2005Ae.dat" /> 177 <EmbeddedResource Include="Data\tassc2005Ba.dat" /> 178 <EmbeddedResource Include="Data\tassc2005Bb.dat" /> 179 <EmbeddedResource Include="Data\tassc2005Bc.dat" /> 180 <EmbeddedResource Include="Data\tassc2005Bd.dat" /> 181 <EmbeddedResource Include="Data\tassc2005Be.dat" /> 182 <EmbeddedResource Include="Data\tassc2005Ca.dat" /> 183 <EmbeddedResource Include="Data\tassc2005Cb.dat" /> 184 <EmbeddedResource Include="Data\tassc2005Cc.dat" /> 185 <EmbeddedResource Include="Data\tassc2005Cd.dat" /> 186 <EmbeddedResource Include="Data\tassc2005Ce.dat" /> 187 <EmbeddedResource Include="Data\tassc2005Da.dat" /> 188 <EmbeddedResource Include="Data\tassc2005Db.dat" /> 189 <EmbeddedResource Include="Data\tassc2005Dc.dat" /> 190 <EmbeddedResource Include="Data\tassc2005Dd.dat" /> 191 <EmbeddedResource Include="Data\tassc2005De.dat" /> 111 <None Include="Data\ElloumiCTAP.dat.zip" /> 112 <None Include="Data\ElloumiCTAP.sol.zip" /> 192 113 <None Include="Plugin.cs.frame" /> 193 114 <Compile Include="ElloumiCTAPDataDescriptor.cs" /> … … 216 137 </ProjectReference> 217 138 </ItemGroup> 218 <ItemGroup>219 <EmbeddedResource Include="Data\tassc1003Aa.sol" />220 <EmbeddedResource Include="Data\tassc1003Ab.sol" />221 <EmbeddedResource Include="Data\tassc1003Ac.sol" />222 <EmbeddedResource Include="Data\tassc1003Ad.sol" />223 <EmbeddedResource Include="Data\tassc1003Ae.sol" />224 <EmbeddedResource Include="Data\tassc1003Ba.sol" />225 <EmbeddedResource Include="Data\tassc1003Bb.sol" />226 <EmbeddedResource Include="Data\tassc1003Bc.sol" />227 <EmbeddedResource Include="Data\tassc1003Bd.sol" />228 <EmbeddedResource Include="Data\tassc1003Be.sol" />229 <EmbeddedResource Include="Data\tassc1003Ca.sol" />230 <EmbeddedResource Include="Data\tassc1003Cb.sol" />231 <EmbeddedResource Include="Data\tassc1003Cc.sol" />232 <EmbeddedResource Include="Data\tassc1003Cd.sol" />233 <EmbeddedResource Include="Data\tassc1003Ce.sol" />234 <EmbeddedResource Include="Data\tassc1003Da.sol" />235 <EmbeddedResource Include="Data\tassc1003Db.sol" />236 <EmbeddedResource Include="Data\tassc1003Dc.sol" />237 <EmbeddedResource Include="Data\tassc1003Dd.sol" />238 <EmbeddedResource Include="Data\tassc1003De.sol" />239 </ItemGroup>240 139 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 241 140 <PropertyGroup> -
trunk/sources/HeuristicLab.Problems.Instances.QAPLIB/3.3/HeuristicLab.Problems.Instances.QAPLIB-3.3.csproj
r7600 r7638 102 102 </PropertyGroup> 103 103 <ItemGroup> 104 <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL" /> 104 105 <Reference Include="System" /> 105 106 <Reference Include="System.Core" /> … … 111 112 <Compile Include="QAPLIBSolutionParser.cs" /> 112 113 <Compile Include="QAPLIBInstanceProvider.cs" /> 113 <EmbeddedResource Include="Data\bur26a.dat" /> 114 <EmbeddedResource Include="Data\bur26b.dat" /> 115 <EmbeddedResource Include="Data\bur26c.dat" /> 116 <EmbeddedResource Include="Data\bur26d.dat" /> 117 <EmbeddedResource Include="Data\bur26e.dat" /> 118 <EmbeddedResource Include="Data\bur26f.dat" /> 119 <EmbeddedResource Include="Data\bur26g.dat" /> 120 <EmbeddedResource Include="Data\bur26h.dat" /> 121 <EmbeddedResource Include="Data\chr12a.dat" /> 122 <EmbeddedResource Include="Data\chr12b.dat" /> 123 <EmbeddedResource Include="Data\chr12c.dat" /> 124 <EmbeddedResource Include="Data\chr15a.dat" /> 125 <EmbeddedResource Include="Data\chr15b.dat" /> 126 <EmbeddedResource Include="Data\chr15c.dat" /> 127 <EmbeddedResource Include="Data\chr18a.dat" /> 128 <EmbeddedResource Include="Data\chr18b.dat" /> 129 <EmbeddedResource Include="Data\chr20a.dat" /> 130 <EmbeddedResource Include="Data\chr20b.dat" /> 131 <EmbeddedResource Include="Data\chr20c.dat" /> 132 <EmbeddedResource Include="Data\chr22a.dat" /> 133 <EmbeddedResource Include="Data\chr22b.dat" /> 134 <EmbeddedResource Include="Data\chr25a.dat" /> 135 <EmbeddedResource Include="Data\els19.dat" /> 136 <EmbeddedResource Include="Data\esc128.dat" /> 137 <EmbeddedResource Include="Data\esc16a.dat" /> 138 <EmbeddedResource Include="Data\esc16b.dat" /> 139 <EmbeddedResource Include="Data\esc16c.dat" /> 140 <EmbeddedResource Include="Data\esc16d.dat" /> 141 <EmbeddedResource Include="Data\esc16e.dat" /> 142 <EmbeddedResource Include="Data\esc16f.dat" /> 143 <EmbeddedResource Include="Data\esc16g.dat" /> 144 <EmbeddedResource Include="Data\esc16h.dat" /> 145 <EmbeddedResource Include="Data\esc16i.dat" /> 146 <EmbeddedResource Include="Data\esc16j.dat" /> 147 <EmbeddedResource Include="Data\esc32a.dat" /> 148 <EmbeddedResource Include="Data\esc32b.dat" /> 149 <EmbeddedResource Include="Data\esc32c.dat" /> 150 <EmbeddedResource Include="Data\esc32d.dat" /> 151 <EmbeddedResource Include="Data\esc32e.dat" /> 152 <EmbeddedResource Include="Data\esc32f.dat" /> 153 <EmbeddedResource Include="Data\esc32g.dat" /> 154 <EmbeddedResource Include="Data\esc32h.dat" /> 155 <EmbeddedResource Include="Data\esc64a.dat" /> 156 <EmbeddedResource Include="Data\had12.dat" /> 157 <EmbeddedResource Include="Data\had14.dat" /> 158 <EmbeddedResource Include="Data\had16.dat" /> 159 <EmbeddedResource Include="Data\had18.dat" /> 160 <EmbeddedResource Include="Data\had20.dat" /> 161 <EmbeddedResource Include="Data\kra30a.dat" /> 162 <EmbeddedResource Include="Data\kra30b.dat" /> 163 <EmbeddedResource Include="Data\kra32.dat" /> 164 <EmbeddedResource Include="Data\lipa20a.dat" /> 165 <EmbeddedResource Include="Data\lipa20b.dat" /> 166 <EmbeddedResource Include="Data\lipa30a.dat" /> 167 <EmbeddedResource Include="Data\lipa30b.dat" /> 168 <EmbeddedResource Include="Data\lipa40a.dat" /> 169 <EmbeddedResource Include="Data\lipa40b.dat" /> 170 <EmbeddedResource Include="Data\lipa50a.dat" /> 171 <EmbeddedResource Include="Data\lipa50b.dat" /> 172 <EmbeddedResource Include="Data\lipa60a.dat" /> 173 <EmbeddedResource Include="Data\lipa60b.dat" /> 174 <EmbeddedResource Include="Data\lipa70a.dat" /> 175 <EmbeddedResource Include="Data\lipa70b.dat" /> 176 <EmbeddedResource Include="Data\lipa80a.dat" /> 177 <EmbeddedResource Include="Data\lipa80b.dat" /> 178 <EmbeddedResource Include="Data\lipa90a.dat" /> 179 <EmbeddedResource Include="Data\lipa90b.dat" /> 180 <EmbeddedResource Include="Data\nug12.dat" /> 181 <EmbeddedResource Include="Data\nug14.dat" /> 182 <EmbeddedResource Include="Data\nug15.dat" /> 183 <EmbeddedResource Include="Data\nug16a.dat" /> 184 <EmbeddedResource Include="Data\nug16b.dat" /> 185 <EmbeddedResource Include="Data\nug17.dat" /> 186 <EmbeddedResource Include="Data\nug18.dat" /> 187 <EmbeddedResource Include="Data\nug20.dat" /> 188 <EmbeddedResource Include="Data\nug21.dat" /> 189 <EmbeddedResource Include="Data\nug22.dat" /> 190 <EmbeddedResource Include="Data\nug24.dat" /> 191 <EmbeddedResource Include="Data\nug25.dat" /> 192 <EmbeddedResource Include="Data\nug27.dat" /> 193 <EmbeddedResource Include="Data\nug28.dat" /> 194 <EmbeddedResource Include="Data\nug30.dat" /> 195 <EmbeddedResource Include="Data\rou12.dat" /> 196 <EmbeddedResource Include="Data\rou15.dat" /> 197 <EmbeddedResource Include="Data\rou20.dat" /> 198 <EmbeddedResource Include="Data\scr12.dat" /> 199 <EmbeddedResource Include="Data\scr15.dat" /> 200 <EmbeddedResource Include="Data\scr20.dat" /> 201 <EmbeddedResource Include="Data\sko100a.dat" /> 202 <EmbeddedResource Include="Data\sko100b.dat" /> 203 <EmbeddedResource Include="Data\sko100c.dat" /> 204 <EmbeddedResource Include="Data\sko100d.dat" /> 205 <EmbeddedResource Include="Data\sko100e.dat" /> 206 <EmbeddedResource Include="Data\sko100f.dat" /> 207 <EmbeddedResource Include="Data\sko42.dat" /> 208 <EmbeddedResource Include="Data\sko49.dat" /> 209 <EmbeddedResource Include="Data\sko56.dat" /> 210 <EmbeddedResource Include="Data\sko64.dat" /> 211 <EmbeddedResource Include="Data\sko72.dat" /> 212 <EmbeddedResource Include="Data\sko81.dat" /> 213 <EmbeddedResource Include="Data\sko90.dat" /> 214 <EmbeddedResource Include="Data\ste36a.dat" /> 215 <EmbeddedResource Include="Data\ste36b.dat" /> 216 <EmbeddedResource Include="Data\ste36c.dat" /> 217 <EmbeddedResource Include="Data\tai100a.dat" /> 218 <EmbeddedResource Include="Data\tai100b.dat" /> 219 <EmbeddedResource Include="Data\tai10a.dat" /> 220 <EmbeddedResource Include="Data\tai10b.dat" /> 221 <EmbeddedResource Include="Data\tai12a.dat" /> 222 <EmbeddedResource Include="Data\tai12b.dat" /> 223 <EmbeddedResource Include="Data\tai150b.dat" /> 224 <EmbeddedResource Include="Data\tai15a.dat" /> 225 <EmbeddedResource Include="Data\tai15b.dat" /> 226 <EmbeddedResource Include="Data\tai17a.dat" /> 227 <EmbeddedResource Include="Data\tai20a.dat" /> 228 <EmbeddedResource Include="Data\tai20b.dat" /> 229 <EmbeddedResource Include="Data\tai256c.dat" /> 230 <EmbeddedResource Include="Data\tai25a.dat" /> 231 <EmbeddedResource Include="Data\tai25b.dat" /> 232 <EmbeddedResource Include="Data\tai30a.dat" /> 233 <EmbeddedResource Include="Data\tai30b.dat" /> 234 <EmbeddedResource Include="Data\tai35a.dat" /> 235 <EmbeddedResource Include="Data\tai35b.dat" /> 236 <EmbeddedResource Include="Data\tai40a.dat" /> 237 <EmbeddedResource Include="Data\tai40b.dat" /> 238 <EmbeddedResource Include="Data\tai50a.dat" /> 239 <EmbeddedResource Include="Data\tai50b.dat" /> 240 <EmbeddedResource Include="Data\tai60a.dat" /> 241 <EmbeddedResource Include="Data\tai60b.dat" /> 242 <EmbeddedResource Include="Data\tai64c.dat" /> 243 <EmbeddedResource Include="Data\tai80a.dat" /> 244 <EmbeddedResource Include="Data\tai80b.dat" /> 245 <EmbeddedResource Include="Data\tho150.dat" /> 246 <EmbeddedResource Include="Data\tho30.dat" /> 247 <EmbeddedResource Include="Data\tho40.dat" /> 248 <EmbeddedResource Include="Data\wil100.dat" /> 249 <EmbeddedResource Include="Data\wil50.dat" /> 114 <EmbeddedResource Include="Data\qap.dat.zip" /> 115 <EmbeddedResource Include="Data\qap.sln.zip" /> 250 116 <None Include="Plugin.cs.frame" /> 251 117 <Compile Include="Plugin.cs" /> … … 255 121 <ItemGroup> 256 122 <None Include="HeuristicLab.snk" /> 257 </ItemGroup>258 <ItemGroup>259 <EmbeddedResource Include="Data\bur26a.sln" />260 <EmbeddedResource Include="Data\bur26b.sln" />261 <EmbeddedResource Include="Data\bur26c.sln" />262 <EmbeddedResource Include="Data\bur26d.sln" />263 <EmbeddedResource Include="Data\bur26e.sln" />264 <EmbeddedResource Include="Data\bur26f.sln" />265 <EmbeddedResource Include="Data\bur26g.sln" />266 <EmbeddedResource Include="Data\bur26h.sln" />267 <EmbeddedResource Include="Data\chr12a.sln" />268 <EmbeddedResource Include="Data\chr12b.sln" />269 <EmbeddedResource Include="Data\chr12c.sln" />270 <EmbeddedResource Include="Data\chr15a.sln" />271 <EmbeddedResource Include="Data\chr15b.sln" />272 <EmbeddedResource Include="Data\chr15c.sln" />273 <EmbeddedResource Include="Data\chr18a.sln" />274 <EmbeddedResource Include="Data\chr18b.sln" />275 <EmbeddedResource Include="Data\chr20a.sln" />276 <EmbeddedResource Include="Data\chr20b.sln" />277 <EmbeddedResource Include="Data\chr20c.sln" />278 <EmbeddedResource Include="Data\chr22a.sln" />279 <EmbeddedResource Include="Data\chr22b.sln" />280 <EmbeddedResource Include="Data\chr25a.sln" />281 <EmbeddedResource Include="Data\els19.sln" />282 <EmbeddedResource Include="Data\esc128.sln" />283 <EmbeddedResource Include="Data\esc16a.sln" />284 <EmbeddedResource Include="Data\esc16b.sln" />285 <EmbeddedResource Include="Data\esc16c.sln" />286 <EmbeddedResource Include="Data\esc16d.sln" />287 <EmbeddedResource Include="Data\esc16e.sln" />288 <EmbeddedResource Include="Data\esc16f.sln" />289 <EmbeddedResource Include="Data\esc16g.sln" />290 <EmbeddedResource Include="Data\esc16h.sln" />291 <EmbeddedResource Include="Data\esc16i.sln" />292 <EmbeddedResource Include="Data\esc16j.sln" />293 <EmbeddedResource Include="Data\esc32a.sln" />294 <EmbeddedResource Include="Data\esc32e.sln" />295 <EmbeddedResource Include="Data\esc32f.sln" />296 <EmbeddedResource Include="Data\esc32g.sln" />297 <EmbeddedResource Include="Data\had12.sln" />298 <EmbeddedResource Include="Data\had14.sln" />299 <EmbeddedResource Include="Data\had16.sln" />300 <EmbeddedResource Include="Data\had18.sln" />301 <EmbeddedResource Include="Data\had20.sln" />302 <EmbeddedResource Include="Data\kra30a.sln" />303 <EmbeddedResource Include="Data\kra30b.sln" />304 <EmbeddedResource Include="Data\kra32.sln" />305 <EmbeddedResource Include="Data\lipa20a.sln" />306 <EmbeddedResource Include="Data\lipa20b.sln" />307 <EmbeddedResource Include="Data\lipa30a.sln" />308 <EmbeddedResource Include="Data\lipa30b.sln" />309 <EmbeddedResource Include="Data\lipa40a.sln" />310 <EmbeddedResource Include="Data\lipa40b.sln" />311 <EmbeddedResource Include="Data\lipa50a.sln" />312 <EmbeddedResource Include="Data\lipa50b.sln" />313 <EmbeddedResource Include="Data\lipa60a.sln" />314 <EmbeddedResource Include="Data\lipa60b.sln" />315 <EmbeddedResource Include="Data\lipa70a.sln" />316 <EmbeddedResource Include="Data\lipa70b.sln" />317 <EmbeddedResource Include="Data\lipa80a.sln" />318 <EmbeddedResource Include="Data\lipa80b.sln" />319 <EmbeddedResource Include="Data\lipa90a.sln" />320 <EmbeddedResource Include="Data\lipa90b.sln" />321 <EmbeddedResource Include="Data\nug12.sln" />322 <EmbeddedResource Include="Data\nug14.sln" />323 <EmbeddedResource Include="Data\nug15.sln" />324 <EmbeddedResource Include="Data\nug16a.sln" />325 <EmbeddedResource Include="Data\nug16b.sln" />326 <EmbeddedResource Include="Data\nug17.sln" />327 <EmbeddedResource Include="Data\nug18.sln" />328 <EmbeddedResource Include="Data\nug20.sln" />329 <EmbeddedResource Include="Data\nug21.sln" />330 <EmbeddedResource Include="Data\nug22.sln" />331 <EmbeddedResource Include="Data\nug24.sln" />332 <EmbeddedResource Include="Data\nug25.sln" />333 <EmbeddedResource Include="Data\nug27.sln" />334 <EmbeddedResource Include="Data\nug28.sln" />335 <EmbeddedResource Include="Data\nug30.sln" />336 <EmbeddedResource Include="Data\rou12.sln" />337 <EmbeddedResource Include="Data\rou15.sln" />338 <EmbeddedResource Include="Data\rou20.sln" />339 <EmbeddedResource Include="Data\scr12.sln" />340 <EmbeddedResource Include="Data\scr15.sln" />341 <EmbeddedResource Include="Data\scr20.sln" />342 <EmbeddedResource Include="Data\sko100a.sln" />343 <EmbeddedResource Include="Data\sko100b.sln" />344 <EmbeddedResource Include="Data\sko100c.sln" />345 <EmbeddedResource Include="Data\sko100d.sln" />346 <EmbeddedResource Include="Data\sko100e.sln" />347 <EmbeddedResource Include="Data\sko100f.sln" />348 <EmbeddedResource Include="Data\sko49.sln" />349 <EmbeddedResource Include="Data\sko81.sln" />350 <EmbeddedResource Include="Data\sko90.sln" />351 <EmbeddedResource Include="Data\ste36a.sln" />352 <EmbeddedResource Include="Data\ste36b.sln" />353 <EmbeddedResource Include="Data\ste36c.sln" />354 <EmbeddedResource Include="Data\tai100a.sln" />355 <EmbeddedResource Include="Data\tai100b.sln" />356 <EmbeddedResource Include="Data\tai12a.sln" />357 <EmbeddedResource Include="Data\tai12b.sln" />358 <EmbeddedResource Include="Data\tai150b.sln" />359 <EmbeddedResource Include="Data\tai15a.sln" />360 <EmbeddedResource Include="Data\tai15b.sln" />361 <EmbeddedResource Include="Data\tai17a.sln" />362 <EmbeddedResource Include="Data\tai20a.sln" />363 <EmbeddedResource Include="Data\tai20b.sln" />364 <EmbeddedResource Include="Data\tai256c.sln" />365 <EmbeddedResource Include="Data\tai25a.sln" />366 <EmbeddedResource Include="Data\tai25b.sln" />367 <EmbeddedResource Include="Data\tai30b.sln" />368 <EmbeddedResource Include="Data\tai35b.sln" />369 <EmbeddedResource Include="Data\tai40b.sln" />370 <EmbeddedResource Include="Data\tai50a.sln" />371 <EmbeddedResource Include="Data\tai50b.sln" />372 <EmbeddedResource Include="Data\tai60a.sln" />373 <EmbeddedResource Include="Data\tai60b.sln" />374 <EmbeddedResource Include="Data\tai64c.sln" />375 <EmbeddedResource Include="Data\tai80a.sln" />376 <EmbeddedResource Include="Data\tai80b.sln" />377 <EmbeddedResource Include="Data\tho150.sln" />378 <EmbeddedResource Include="Data\tho30.sln" />379 <EmbeddedResource Include="Data\wil100.sln" />380 123 </ItemGroup> 381 124 <ItemGroup> -
trunk/sources/HeuristicLab.Problems.Instances.QAPLIB/3.3/QAPLIBInstanceProvider.cs
r7558 r7638 26 26 using System.Reflection; 27 27 using System.Text.RegularExpressions; 28 using ICSharpCode.SharpZipLib.Zip; 28 29 29 30 namespace HeuristicLab.Problems.Instances.QAPLIB { … … 159 160 } 160 161 162 private const string FileName = "qap"; 163 161 164 public override IEnumerable<IDataDescriptor> GetDataDescriptors() { 162 var solutions = Assembly.GetExecutingAssembly() 163 .GetManifestResourceNames() 164 .Where(x => x.EndsWith(".sln")) 165 .ToDictionary(x => Path.GetFileNameWithoutExtension(x) + ".dat", x => x); 166 167 return Assembly.GetExecutingAssembly() 168 .GetManifestResourceNames() 169 .Where(x => x.EndsWith(".dat")) 170 .OrderBy(x => x) 171 .Select(x => new QAPLIBDataDescriptor(GetPrettyName(x), GetDescription(), x, solutions.ContainsKey(x) ? solutions[x] : String.Empty)); 165 Dictionary<string, string> solutions = new Dictionary<string, string>(); 166 var solutionsArchiveName = GetResourceName(FileName + @"\.sln\.zip"); 167 if (!String.IsNullOrEmpty(solutionsArchiveName)) { 168 using (var solutionsZipFile = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) { 169 foreach (var entry in GetZipContents(solutionsZipFile)) 170 solutions.Add(Path.GetFileNameWithoutExtension(entry) + ".dat", entry); 171 } 172 } 173 var instanceArchiveName = GetResourceName(FileName + @"\.dat\.zip"); 174 if (String.IsNullOrEmpty(instanceArchiveName)) yield break; 175 176 using (var instanceStream = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 177 foreach (var entry in GetZipContents(instanceStream).OrderBy(x => x)) { 178 yield return new QAPLIBDataDescriptor(Path.GetFileNameWithoutExtension(entry), GetDescription(), entry, solutions.ContainsKey(entry) ? solutions[entry] : String.Empty); 179 } 180 } 172 181 } 173 182 174 183 public override QAPData LoadData(IDataDescriptor id) { 175 184 var descriptor = (QAPLIBDataDescriptor)id; 176 using (var stream = Assembly.GetExecutingAssembly() 177 .GetManifestResourceStream(descriptor.InstanceIdentifier)) { 178 var parser = new QAPLIBParser(); 179 parser.Parse(stream); 180 var instance = Load(parser); 181 instance.Name = id.Name; 182 instance.Description = id.Description; 183 184 if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) { 185 using (Stream solStream = Assembly.GetExecutingAssembly() 186 .GetManifestResourceStream(descriptor.SolutionIdentifier)) { 187 var slnParser = new QAPLIBSolutionParser(); 188 slnParser.Parse(solStream, true); 189 if (slnParser.Error != null) throw slnParser.Error; 190 191 int[] assignment = slnParser.Assignment; 192 if (reversedSolutions.Contains(instance.Name)) { 193 assignment = (int[])slnParser.Assignment.Clone(); 194 for (int i = 0; i < assignment.Length; i++) 195 assignment[slnParser.Assignment[i]] = i; 185 var instanceArchiveName = GetResourceName(FileName + @"\.dat\.zip"); 186 using (var instancesZipFile = new ZipFile(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 187 var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier); 188 189 using (var stream = instancesZipFile.GetInputStream(entry)) { 190 var parser = new QAPLIBParser(); 191 parser.Parse(stream); 192 var instance = Load(parser); 193 instance.Name = id.Name; 194 instance.Description = id.Description; 195 196 if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) { 197 var solutionsArchiveName = GetResourceName(FileName + @"\.sln\.zip"); 198 using (var solutionsZipFile = new ZipFile(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) { 199 entry = solutionsZipFile.GetEntry(descriptor.SolutionIdentifier); 200 using (var solStream = solutionsZipFile.GetInputStream(entry)) { 201 var slnParser = new QAPLIBSolutionParser(); 202 slnParser.Parse(solStream, true); 203 if (slnParser.Error != null) throw slnParser.Error; 204 205 int[] assignment = slnParser.Assignment; 206 if (reversedSolutions.Contains(instance.Name)) { 207 assignment = (int[])slnParser.Assignment.Clone(); 208 for (int i = 0; i < assignment.Length; i++) 209 assignment[slnParser.Assignment[i]] = i; 210 } 211 instance.BestKnownAssignment = assignment; 212 instance.BestKnownQuality = slnParser.Quality; 213 } 196 214 } 197 instance.BestKnownAssignment = assignment;198 instance.BestKnownQuality = slnParser.Quality;199 215 } 216 return instance; 200 217 } 201 return instance;202 218 } 203 219 } … … 224 240 } 225 241 226 private string GetPrettyName(string instanceIdentifier) {227 return Regex.Match(instanceIdentifier, GetType().Namespace + @"\.Data\.(.*)\.dat").Groups[1].Captures[0].Value;228 }229 230 242 private string GetDescription() { 231 243 return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + "."; 232 244 } 245 246 protected virtual string GetResourceName(string fileName) { 247 return Assembly.GetExecutingAssembly().GetManifestResourceNames() 248 .Where(x => Regex.Match(x, @".*\.Data\." + fileName).Success).SingleOrDefault(); 249 } 250 251 protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) { 252 ZipEntry entry; 253 while ((entry = zipFile.GetNextEntry()) != null) { 254 yield return entry.Name; 255 } 256 } 233 257 } 234 258 } -
trunk/sources/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBInstanceProvider.cs
r7622 r7638 61 61 62 62 using (var instanceStream = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) { 63 foreach (var entry in GetZipContents(instanceStream) ) {63 foreach (var entry in GetZipContents(instanceStream).OrderBy(x => x)) { 64 64 yield return new TSPLIBDataDescriptor(Path.GetFileNameWithoutExtension(entry), GetInstanceDescription(), entry, solutions.ContainsKey(entry) ? solutions[entry] : String.Empty); 65 65 }
Note: See TracChangeset
for help on using the changeset viewer.