Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.QuadraticAssignment-3.3/QAPLIBInstancesTest.cs @ 7558

Last change on this file since 7558 was 7558, checked in by abeham, 12 years ago

#1782: trunk integration of problem instance development

  • Adapted TSP and QAP to use the new feature
  • Moved the TSPLIB importer dialog from the TSP plugin to the TSPLIB instances plugin (created a view for that provider)
  • Created it as a default view for IHeuristicOptimizationProblem in order not to interfere with other problems do not yet work with this
File size: 6.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
22using System;
23using System.Collections.Generic;
24using System.IO;
25using System.Linq;
26using System.Text;
27using HeuristicLab.Problems.Instances.QAPLIB;
28using Microsoft.VisualStudio.TestTools.UnitTesting;
29
30namespace HeuristicLab.Problems.QuadraticAssignment.Tests_33 {
31  [TestClass]
32  public class QAPLIBInstancesTest {
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
172
173    [TestMethod]
174    public void TestQAPLIBInstances() {
175      var provider = new QAPLIBInstanceProvider();
176      var qap = new QuadraticAssignmentProblem();
177      var failedInstances = new StringBuilder();
178      string tempPath = Path.GetTempPath();
179
180      var instances = provider.GetDataDescriptors();
181      Assert.IsTrue(instances.Any(), "No instances could be found.");
182
183      foreach (var instance in instances) {
184        try {
185          qap.Load(provider.LoadData(instance));
186        } catch (Exception ex) {
187          failedInstances.AppendLine(instance + ": " + ex.Message);
188        }
189      }
190      Assert.IsTrue(failedInstances.Length == 0, "Following instances failed: " + Environment.NewLine + failedInstances.ToString());
191    }
192
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());
210    }
211  }
212}
Note: See TracBrowser for help on using the repository browser.