- Timestamp:
- 05/16/12 16:28:49 (13 years ago)
- Location:
- branches/HeuristicLab.TimeSeries
- Files:
-
- 102 deleted
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries
- Property svn:mergeinfo changed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/ElloumiCTAPInstanceProvider.cs
r7548 r7842 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 } -
branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.Instances.ElloumiCTAP/3.3/HeuristicLab.Problems.Instances.ElloumiCTAP-3.3.csproj
r7600 r7842 102 102 </PropertyGroup> 103 103 <ItemGroup> 104 <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL"> 105 <Private>False</Private> 106 </Reference> 104 107 <Reference Include="System" /> 105 108 <Reference Include="System.Core" /> … … 108 111 <ItemGroup> 109 112 <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" /> 113 <EmbeddedResource Include="Data\ElloumiCTAP.dat.zip" /> 114 <EmbeddedResource Include="Data\ElloumiCTAP.sol.zip" /> 192 115 <None Include="Plugin.cs.frame" /> 193 116 <Compile Include="ElloumiCTAPDataDescriptor.cs" /> … … 205 128 <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project> 206 129 <Name>HeuristicLab.Common-3.3</Name> 130 <Private>False</Private> 207 131 </ProjectReference> 208 132 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj"> 209 133 <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project> 210 134 <Name>HeuristicLab.PluginInfrastructure-3.3</Name> 135 <Private>False</Private> 211 136 </ProjectReference> 212 137 <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj"> … … 215 140 <Private>False</Private> 216 141 </ProjectReference> 217 </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 142 </ItemGroup> 240 143 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Note: See TracChangeset
for help on using the changeset viewer.