[5932] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[12009] | 3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[5932] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
[5949] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
[5648] | 25 | using System.Text;
|
---|
[7558] | 26 | using HeuristicLab.Problems.Instances.QAPLIB;
|
---|
[5648] | 27 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 28 |
|
---|
[9885] | 29 | namespace HeuristicLab.Problems.QuadraticAssignment.Tests {
|
---|
[5648] | 30 | [TestClass]
|
---|
| 31 | public class QAPLIBInstancesTest {
|
---|
[7558] | 32 | #region instances
|
---|
| 33 | private static Dictionary<string, double> qaplibInstances = new Dictionary<string, double>() {
|
---|
| 34 | { "bur26a", 5426670 },
|
---|
| 35 | { "bur26b", 3817852 },
|
---|
| 36 | { "bur26c", 5426795 },
|
---|
| 37 | { "bur26d", 3821225 },
|
---|
| 38 | { "bur26e", 5386879 },
|
---|
| 39 | { "bur26f", 3782044 },
|
---|
| 40 | { "bur26g", 10117172 },
|
---|
| 41 | { "bur26h", 7098658 },
|
---|
| 42 | { "chr12a", 9552 },
|
---|
| 43 | { "chr12b", 9742 },
|
---|
| 44 | { "chr12c", 11156 },
|
---|
| 45 | { "chr15a", 9896 },
|
---|
| 46 | { "chr15b", 7990 },
|
---|
| 47 | { "chr15c", 9504 },
|
---|
| 48 | { "chr18a", 11098 },
|
---|
| 49 | { "chr18b", 1534 },
|
---|
| 50 | { "chr20a", 2192 },
|
---|
| 51 | { "chr20b", 2298 },
|
---|
| 52 | { "chr20c", 14142 },
|
---|
| 53 | { "chr22a", 6156 },
|
---|
| 54 | { "chr22b", 6194 },
|
---|
| 55 | { "chr25a", 3796 },
|
---|
| 56 | { "els19", 17212548 },
|
---|
| 57 | { "esc16a", 68 },
|
---|
| 58 | { "esc16b", 292 },
|
---|
| 59 | { "esc16c", 160 },
|
---|
| 60 | { "esc16d", 16 },
|
---|
| 61 | { "esc16e", 28 },
|
---|
| 62 | { "esc16f", 0 },
|
---|
| 63 | { "esc16g", 26 },
|
---|
| 64 | { "esc16h", 996 },
|
---|
| 65 | { "esc16i", 14 },
|
---|
| 66 | { "esc16j", 8 },
|
---|
| 67 | { "esc32a", 130 },
|
---|
| 68 | { "esc32b", 168 },
|
---|
| 69 | { "esc32c", 642 },
|
---|
| 70 | { "esc32d", 200 },
|
---|
| 71 | { "esc32e", 2 },
|
---|
| 72 | { "esc32f", 2 },
|
---|
| 73 | { "esc32g", 6 },
|
---|
| 74 | { "esc32h", 438 },
|
---|
| 75 | { "esc64", 116 },
|
---|
| 76 | { "esc128", 64 },
|
---|
| 77 | { "had12", 1652 },
|
---|
| 78 | { "had14", 2724 },
|
---|
| 79 | { "had16", 3720 },
|
---|
| 80 | { "had18", 5358 },
|
---|
| 81 | { "had20", 6922 },
|
---|
| 82 | { "kra30a", 88900 },
|
---|
| 83 | { "kra30b", 91420 },
|
---|
| 84 | { "kra32", 88700 },
|
---|
| 85 | { "lipa20a", 3683 },
|
---|
| 86 | { "lipa20b", 27076 },
|
---|
| 87 | { "lipa30a", 13178 },
|
---|
| 88 | { "lipa30b", 151426 },
|
---|
| 89 | { "lipa40a", 31538 },
|
---|
| 90 | { "lipa40b", 476581 },
|
---|
| 91 | { "lipa50a", 62093 },
|
---|
| 92 | { "lipa50b", 1210244 },
|
---|
| 93 | { "lipa60a", 107218 },
|
---|
| 94 | { "lipa60b", 2520135 },
|
---|
| 95 | { "lipa70a", 169755 },
|
---|
| 96 | { "lipa70b", 4603200 },
|
---|
| 97 | { "lipa80a", 253195 },
|
---|
| 98 | { "lipa80b", 7763962 },
|
---|
| 99 | { "lipa90a", 360630 },
|
---|
| 100 | { "lipa90b", 12490441 },
|
---|
| 101 | { "nug12", 578 },
|
---|
| 102 | { "nug14", 1014 },
|
---|
| 103 | { "nug15", 1150 },
|
---|
| 104 | { "nug16a", 1610 },
|
---|
| 105 | { "nug16b", 1240 },
|
---|
| 106 | { "nug17", 1732 },
|
---|
| 107 | { "nug18", 1930 },
|
---|
| 108 | { "nug20", 2570 },
|
---|
| 109 | { "nug21", 2438 },
|
---|
| 110 | { "nug22", 3596 },
|
---|
| 111 | { "nug24", 3488 },
|
---|
| 112 | { "nug25", 3744 },
|
---|
| 113 | { "nug27", 5234 },
|
---|
| 114 | { "nug28", 5166 },
|
---|
| 115 | { "nug30", 6124 },
|
---|
| 116 | { "rou12", 235528 },
|
---|
| 117 | { "rou15", 354210 },
|
---|
| 118 | { "rou20", 725522 },
|
---|
| 119 | { "scr12", 31410 },
|
---|
| 120 | { "scr15", 51140 },
|
---|
| 121 | { "scr20", 110030 },
|
---|
| 122 | { "sko42", 15812 },
|
---|
| 123 | { "sko49", 23386 },
|
---|
| 124 | { "sko56", 34458 },
|
---|
| 125 | { "sko64", 48498 },
|
---|
| 126 | { "sko72", 66256 },
|
---|
| 127 | { "sko81", 90998 },
|
---|
| 128 | { "sko90", 115534 },
|
---|
| 129 | { "sko100a", 152002 },
|
---|
| 130 | { "sko100b", 153890 },
|
---|
| 131 | { "sko100c", 147862 },
|
---|
| 132 | { "sko100d", 149576 },
|
---|
| 133 | { "sko100e", 149150 },
|
---|
| 134 | { "sko100f", 149036 },
|
---|
| 135 | { "ste36a", 9526 },
|
---|
| 136 | { "ste36b", 15852 },
|
---|
| 137 | { "ste36c", 8239110 },
|
---|
| 138 | { "tai12a", 224416 },
|
---|
| 139 | { "tai12b", 39464925 },
|
---|
| 140 | { "tai15a", 388214 },
|
---|
| 141 | { "tai15b", 51765268 },
|
---|
| 142 | { "tai17a", 491812 },
|
---|
| 143 | { "tai20a", 703482 },
|
---|
| 144 | { "tai20b", 122455319 },
|
---|
| 145 | { "tai25a", 1167256 },
|
---|
| 146 | { "tai25b", 344355646 },
|
---|
| 147 | { "tai30a", 1818146 },
|
---|
| 148 | { "tai30b", 637117113 },
|
---|
| 149 | { "tai35a", 2422002 },
|
---|
| 150 | { "tai35b", 283315445 },
|
---|
| 151 | { "tai40a", 3139370 },
|
---|
| 152 | { "tai40b", 637250948 },
|
---|
| 153 | { "tai50a", 4938796 },
|
---|
| 154 | { "tai50b", 458821517 },
|
---|
| 155 | { "tai60a", 7208572 },
|
---|
| 156 | { "tai60b", 608215054 },
|
---|
| 157 | { "tai64c", 1855928 },
|
---|
| 158 | { "tai80a", 13557864 },
|
---|
| 159 | { "tai80b", 818415043 },
|
---|
| 160 | { "tai100a", 21052466 },
|
---|
| 161 | { "tai100b", 1185996137 },
|
---|
| 162 | { "tai150b", 498896643 },
|
---|
| 163 | { "tai256c", 44759294 },
|
---|
| 164 | { "tho30", 149936 },
|
---|
| 165 | { "tho40", 240516 },
|
---|
| 166 | { "tho150", 8133398 },
|
---|
| 167 | { "wil50", 48816 },
|
---|
| 168 | { "wil100", 273038 }
|
---|
| 169 | };
|
---|
[8092] | 170 | private static Dictionary<string, double> lowerBounds = new Dictionary<string, double>() {
|
---|
| 171 | { "bur26a", 5315200 },
|
---|
| 172 | { "bur26f", 3706888 },
|
---|
| 173 | { "chr25a", 2765 },
|
---|
| 174 | { "els19", 11971949 },
|
---|
| 175 | { "esc32a", 35 },
|
---|
| 176 | { "esc32e", 0 },
|
---|
| 177 | { "had20", 6166 },
|
---|
| 178 | { "kra32", 67390 },
|
---|
| 179 | { "lipa50a", 62020 },
|
---|
| 180 | { "lipa50b", 1210244 },
|
---|
| 181 | { "nug30", 4539 },
|
---|
| 182 | { "scr20", 86766 },
|
---|
| 183 | { "sko42", 11311 },
|
---|
| 184 | { "tai35a", 1951207 },
|
---|
| 185 | { "tai35b", 30866283 },
|
---|
| 186 | { "tai100a", 15824355 }
|
---|
| 187 | };
|
---|
[7558] | 188 | #endregion
|
---|
[5814] | 189 |
|
---|
[5949] | 190 | [TestMethod]
|
---|
[9885] | 191 | [TestCategory("Problems.Assignment")]
|
---|
| 192 | [TestProperty("Time", "long")]
|
---|
[6891] | 193 | public void TestQAPLIBInstances() {
|
---|
[7558] | 194 | var provider = new QAPLIBInstanceProvider();
|
---|
[6891] | 195 | var qap = new QuadraticAssignmentProblem();
|
---|
| 196 | var failedInstances = new StringBuilder();
|
---|
| 197 |
|
---|
[7558] | 198 | var instances = provider.GetDataDescriptors();
|
---|
| 199 | Assert.IsTrue(instances.Any(), "No instances could be found.");
|
---|
[6891] | 200 |
|
---|
[7558] | 201 | foreach (var instance in instances) {
|
---|
[5814] | 202 | try {
|
---|
[7558] | 203 | qap.Load(provider.LoadData(instance));
|
---|
[6891] | 204 | } catch (Exception ex) {
|
---|
| 205 | failedInstances.AppendLine(instance + ": " + ex.Message);
|
---|
[6844] | 206 | }
|
---|
[5814] | 207 | }
|
---|
[6891] | 208 | Assert.IsTrue(failedInstances.Length == 0, "Following instances failed: " + Environment.NewLine + failedInstances.ToString());
|
---|
[5814] | 209 | }
|
---|
[6891] | 210 |
|
---|
[7558] | 211 | [TestMethod]
|
---|
[9885] | 212 | [TestCategory("Problems.Assignment")]
|
---|
| 213 | [TestProperty("Time", "long")]
|
---|
[7558] | 214 | public void TestQAPLIBSolutions() {
|
---|
| 215 | var provider = new QAPLIBInstanceProvider();
|
---|
| 216 | var qap = new QuadraticAssignmentProblem();
|
---|
| 217 | var failedInstances = new StringBuilder();
|
---|
| 218 |
|
---|
| 219 | var instances = provider.GetDataDescriptors();
|
---|
| 220 | Assert.IsTrue(instances.Any(), "No instances could be found.");
|
---|
| 221 |
|
---|
| 222 | foreach (var instance in instances) {
|
---|
| 223 | qap.Load(provider.LoadData(instance));
|
---|
| 224 | if (qaplibInstances.ContainsKey(instance.Name)
|
---|
| 225 | && qap.BestKnownQuality != null && qap.BestKnownQuality.Value != qaplibInstances[instance.Name])
|
---|
| 226 | failedInstances.AppendLine(instance.Name + ": " + qap.BestKnownQuality.Value.ToString() + " vs " + qaplibInstances[instance.Name]);
|
---|
| 227 | }
|
---|
[8092] | 228 | Assert.IsTrue(failedInstances.Length == 0, "Following instances/solutions have suspicious best quality: " + Environment.NewLine + failedInstances.ToString());
|
---|
[6891] | 229 | }
|
---|
[8092] | 230 |
|
---|
| 231 | [TestMethod]
|
---|
[9885] | 232 | [TestCategory("Problems.Assignment")]
|
---|
| 233 | [TestProperty("Time", "short")]
|
---|
[8092] | 234 | public void TestQAPLIBLowerBounds() {
|
---|
| 235 | var provider = new QAPLIBInstanceProvider();
|
---|
| 236 | var qap = new QuadraticAssignmentProblem();
|
---|
| 237 | var failedInstances = new StringBuilder();
|
---|
| 238 |
|
---|
| 239 | var instances = provider.GetDataDescriptors();
|
---|
| 240 | Assert.IsTrue(instances.Any(), "No instances could be found.");
|
---|
| 241 |
|
---|
| 242 | foreach (var instance in instances) {
|
---|
| 243 | if (lowerBounds.ContainsKey(instance.Name)) {
|
---|
| 244 | qap.Load(provider.LoadData(instance));
|
---|
| 245 | if (qap.LowerBound.Value != lowerBounds[instance.Name])
|
---|
| 246 | failedInstances.AppendLine(instance.Name + ": The Gilmore-Lawler lower bound is not valid.");
|
---|
| 247 | }
|
---|
| 248 | }
|
---|
| 249 | Assert.IsTrue(failedInstances.Length == 0, "Following instances failed for the GLB calculation: " + Environment.NewLine + failedInstances.ToString());
|
---|
| 250 | }
|
---|
[5648] | 251 | }
|
---|
| 252 | }
|
---|