Changeset 7669 for branches/HeuristicLab.Hive.Azure/HeuristicLab.Tests/HeuristicLab.Problems.QuadraticAssignment-3.3/QAPLIBInstancesTest.cs
- Timestamp:
- 03/28/12 15:47:26 (13 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure
- Property svn:ignore
-
old new 3 3 *.resharper 4 4 *.suo 5 *.user 5 6 *.vsp 6 7 Doxygen 8 FxCopResults.txt 7 9 Google.ProtocolBuffers-0.9.1.dll 8 10 HeuristicLab 3.3.5.1.ReSharper.user
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Tests
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Tests merged: 7294,7353,7397,7442,7450,7467,7508,7519,7532,7542,7558,7560,7650,7657,7662
- Property svn:mergeinfo changed
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Tests/HeuristicLab.Problems.QuadraticAssignment-3.3/QAPLIBInstancesTest.cs
r7270 r7669 24 24 using System.IO; 25 25 using System.Linq; 26 using System.Reflection;27 26 using System.Text; 27 using HeuristicLab.Problems.Instances.QAPLIB; 28 28 using Microsoft.VisualStudio.TestTools.UnitTesting; 29 29 … … 31 31 [TestClass] 32 32 public class QAPLIBInstancesTest { 33 private static string InstancePrefix = "HeuristicLab.Tests.HeuristicLab.Problems.QuadraticAssignment_3._3.QAPLIB."; 34 35 private IEnumerable<string> EmbeddedInstances { 36 get { 37 return Assembly.GetExecutingAssembly() 38 .GetManifestResourceNames() 39 .Where(x => x.EndsWith(".dat")) 40 .OrderBy(x => x) 41 .Select(x => x.Replace(".dat", String.Empty)) 42 .Select(x => x.Replace(InstancePrefix, String.Empty)); 43 } 44 } 33 #region instances 34 private static Dictionary<string, double> qaplibInstances = new Dictionary<string, double>() { 35 { "bur26a", 5426670 }, 36 { "bur26b", 3817852 }, 37 { "bur26c", 5426795 }, 38 { "bur26d", 3821225 }, 39 { "bur26e", 5386879 }, 40 { "bur26f", 3782044 }, 41 { "bur26g", 10117172 }, 42 { "bur26h", 7098658 }, 43 { "chr12a", 9552 }, 44 { "chr12b", 9742 }, 45 { "chr12c", 11156 }, 46 { "chr15a", 9896 }, 47 { "chr15b", 7990 }, 48 { "chr15c", 9504 }, 49 { "chr18a", 11098 }, 50 { "chr18b", 1534 }, 51 { "chr20a", 2192 }, 52 { "chr20b", 2298 }, 53 { "chr20c", 14142 }, 54 { "chr22a", 6156 }, 55 { "chr22b", 6194 }, 56 { "chr25a", 3796 }, 57 { "els19", 17212548 }, 58 { "esc16a", 68 }, 59 { "esc16b", 292 }, 60 { "esc16c", 160 }, 61 { "esc16d", 16 }, 62 { "esc16e", 28 }, 63 { "esc16f", 0 }, 64 { "esc16g", 26 }, 65 { "esc16h", 996 }, 66 { "esc16i", 14 }, 67 { "esc16j", 8 }, 68 { "esc32a", 130 }, 69 { "esc32b", 168 }, 70 { "esc32c", 642 }, 71 { "esc32d", 200 }, 72 { "esc32e", 2 }, 73 { "esc32f", 2 }, 74 { "esc32g", 6 }, 75 { "esc32h", 438 }, 76 { "esc64", 116 }, 77 { "esc128", 64 }, 78 { "had12", 1652 }, 79 { "had14", 2724 }, 80 { "had16", 3720 }, 81 { "had18", 5358 }, 82 { "had20", 6922 }, 83 { "kra30a", 88900 }, 84 { "kra30b", 91420 }, 85 { "kra32", 88700 }, 86 { "lipa20a", 3683 }, 87 { "lipa20b", 27076 }, 88 { "lipa30a", 13178 }, 89 { "lipa30b", 151426 }, 90 { "lipa40a", 31538 }, 91 { "lipa40b", 476581 }, 92 { "lipa50a", 62093 }, 93 { "lipa50b", 1210244 }, 94 { "lipa60a", 107218 }, 95 { "lipa60b", 2520135 }, 96 { "lipa70a", 169755 }, 97 { "lipa70b", 4603200 }, 98 { "lipa80a", 253195 }, 99 { "lipa80b", 7763962 }, 100 { "lipa90a", 360630 }, 101 { "lipa90b", 12490441 }, 102 { "nug12", 578 }, 103 { "nug14", 1014 }, 104 { "nug15", 1150 }, 105 { "nug16a", 1610 }, 106 { "nug16b", 1240 }, 107 { "nug17", 1732 }, 108 { "nug18", 1930 }, 109 { "nug20", 2570 }, 110 { "nug21", 2438 }, 111 { "nug22", 3596 }, 112 { "nug24", 3488 }, 113 { "nug25", 3744 }, 114 { "nug27", 5234 }, 115 { "nug28", 5166 }, 116 { "nug30", 6124 }, 117 { "rou12", 235528 }, 118 { "rou15", 354210 }, 119 { "rou20", 725522 }, 120 { "scr12", 31410 }, 121 { "scr15", 51140 }, 122 { "scr20", 110030 }, 123 { "sko42", 15812 }, 124 { "sko49", 23386 }, 125 { "sko56", 34458 }, 126 { "sko64", 48498 }, 127 { "sko72", 66256 }, 128 { "sko81", 90998 }, 129 { "sko90", 115534 }, 130 { "sko100a", 152002 }, 131 { "sko100b", 153890 }, 132 { "sko100c", 147862 }, 133 { "sko100d", 149576 }, 134 { "sko100e", 149150 }, 135 { "sko100f", 149036 }, 136 { "ste36a", 9526 }, 137 { "ste36b", 15852 }, 138 { "ste36c", 8239110 }, 139 { "tai12a", 224416 }, 140 { "tai12b", 39464925 }, 141 { "tai15a", 388214 }, 142 { "tai15b", 51765268 }, 143 { "tai17a", 491812 }, 144 { "tai20a", 703482 }, 145 { "tai20b", 122455319 }, 146 { "tai25a", 1167256 }, 147 { "tai25b", 344355646 }, 148 { "tai30a", 1818146 }, 149 { "tai30b", 637117113 }, 150 { "tai35a", 2422002 }, 151 { "tai35b", 283315445 }, 152 { "tai40a", 3139370 }, 153 { "tai40b", 637250948 }, 154 { "tai50a", 4938796 }, 155 { "tai50b", 458821517 }, 156 { "tai60a", 7208572 }, 157 { "tai60b", 608215054 }, 158 { "tai64c", 1855928 }, 159 { "tai80a", 13557864 }, 160 { "tai80b", 818415043 }, 161 { "tai100a", 21052466 }, 162 { "tai100b", 1185996137 }, 163 { "tai150b", 498896643 }, 164 { "tai256c", 44759294 }, 165 { "tho30", 149936 }, 166 { "tho40", 240516 }, 167 { "tho150", 8133398 }, 168 { "wil50", 48816 }, 169 { "wil100", 273038 } 170 }; 171 #endregion 45 172 46 173 [TestMethod] 47 174 public void TestQAPLIBInstances() { 175 var provider = new QAPLIBInstanceProvider(); 48 176 var qap = new QuadraticAssignmentProblem(); 49 177 var failedInstances = new StringBuilder(); 50 178 string tempPath = Path.GetTempPath(); 51 179 52 Assert.IsTrue(EmbeddedInstances.Any(), "No instances could be found."); 53 54 foreach (string instance in EmbeddedInstances) { 55 WriteEmbeddedResourceToFile(InstancePrefix + instance + ".dat", File.Create(Path.Combine(tempPath, "instance.dat"))); 56 57 bool solutionExists = Assembly.GetExecutingAssembly().GetManifestResourceNames().Any(x => x == InstancePrefix + instance + ".sln"); 58 if (solutionExists) 59 WriteEmbeddedResourceToFile(InstancePrefix + instance + ".sln", File.Create(Path.Combine(tempPath, "instance.sln"))); 60 180 var instances = provider.GetDataDescriptors(); 181 Assert.IsTrue(instances.Any(), "No instances could be found."); 182 183 foreach (var instance in instances) { 61 184 try { 62 qap.Load InstanceFromFile(Path.Combine(tempPath, "instance.dat"));185 qap.Load(provider.LoadData(instance)); 63 186 } catch (Exception ex) { 64 187 failedInstances.AppendLine(instance + ": " + ex.Message); 65 solutionExists = false; // not necessary to test solution as well66 }67 68 if (solutionExists) {69 try {70 qap.LoadInstanceFromFile(Path.Combine(tempPath, "instance.dat"), Path.Combine(tempPath, "instance.sln"));71 if (qap.BestKnownSolution == null)72 failedInstances.AppendLine(instance + " (sln): Given solution and reported quality cannot be reproduced.");73 } catch (Exception ex) {74 failedInstances.AppendLine(instance + " (+sln):" + ex.Message);75 }76 188 } 77 189 } … … 79 191 } 80 192 81 private void WriteEmbeddedResourceToFile(string resource, FileStream file) { 82 try { 83 using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)) { 84 int token; 85 while ((token = stream.ReadByte()) >= 0) { 86 file.WriteByte((byte)token); 87 } 88 } 89 } finally { file.Close(); } 193 [TestMethod] 194 public void TestQAPLIBSolutions() { 195 var provider = new QAPLIBInstanceProvider(); 196 var qap = new QuadraticAssignmentProblem(); 197 var failedInstances = new StringBuilder(); 198 string tempPath = Path.GetTempPath(); 199 200 var instances = provider.GetDataDescriptors(); 201 Assert.IsTrue(instances.Any(), "No instances could be found."); 202 203 foreach (var instance in instances) { 204 qap.Load(provider.LoadData(instance)); 205 if (qaplibInstances.ContainsKey(instance.Name) 206 && qap.BestKnownQuality != null && qap.BestKnownQuality.Value != qaplibInstances[instance.Name]) 207 failedInstances.AppendLine(instance.Name + ": " + qap.BestKnownQuality.Value.ToString() + " vs " + qaplibInstances[instance.Name]); 208 } 209 Assert.IsTrue(failedInstances.Length == 0, "Following instances/solutions have suspicious quality: " + Environment.NewLine + failedInstances.ToString()); 90 210 } 91 211 }
Note: See TracChangeset
for help on using the changeset viewer.