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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using System.Reflection;
|
---|
26 | using System.Text.RegularExpressions;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Problems.Instances.CordeauGQAP {
|
---|
29 | public class CordeauGQAPInstanceProvider : ProblemInstanceProvider<IGQAPInstance> {
|
---|
30 | public override string Name {
|
---|
31 | get { return "Cordeau et al. GQAP instances"; }
|
---|
32 | }
|
---|
33 |
|
---|
34 | public override string Description {
|
---|
35 | get { return "GQAP instances published by Cordeau, Gaudioso, Laporte, and Moccia."; }
|
---|
36 | }
|
---|
37 |
|
---|
38 | public override Uri WebLink {
|
---|
39 | get { return null; }
|
---|
40 | }
|
---|
41 |
|
---|
42 | public override string ReferencePublication {
|
---|
43 | get {
|
---|
44 | return @"Cordeau, J.-F., Gaudioso, M., Laporte, G., Moccia, L. 2006.
|
---|
45 | A memetic heuristic for the generalized quadratic assignment problem.
|
---|
46 | INFORMS Journal on Computing, 18, pp. 433–443.";
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | public override IEnumerable<IInstanceDescriptor> GetInstanceDescriptors() {
|
---|
51 | return Assembly.GetExecutingAssembly()
|
---|
52 | .GetManifestResourceNames()
|
---|
53 | .Where(x => x.EndsWith(".txt"))
|
---|
54 | .OrderBy(x => x)
|
---|
55 | .Select(x => new CordeauGQAPInstanceDescriptor(GetPrettyName(x), GetDescription(), x));
|
---|
56 | }
|
---|
57 |
|
---|
58 | public override IGQAPInstance GetInstance(IInstanceDescriptor id) {
|
---|
59 | var descriptor = (CordeauGQAPInstanceDescriptor)id;
|
---|
60 | var instance = new CordeauGQAPInstance();
|
---|
61 | using (var stream = Assembly.GetExecutingAssembly()
|
---|
62 | .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
|
---|
63 | var parser = new CordeauGQAPParser();
|
---|
64 | parser.Parse(stream);
|
---|
65 | if (parser.Error != null) throw parser.Error;
|
---|
66 | instance.Equipments = parser.Equipments;
|
---|
67 | instance.Locations = parser.Locations;
|
---|
68 | instance.Demands = parser.Demands;
|
---|
69 | instance.Capacities = parser.Capacities;
|
---|
70 | instance.Weights = parser.Weights;
|
---|
71 | instance.Distances = parser.Distances;
|
---|
72 | instance.InstallationCosts = parser.InstallationCosts;
|
---|
73 | instance.TransportationCosts = parser.TransportationCosts;
|
---|
74 |
|
---|
75 | instance.Name = id.Name;
|
---|
76 | instance.Description = id.Description;
|
---|
77 | }
|
---|
78 | return instance;
|
---|
79 | }
|
---|
80 |
|
---|
81 | private string GetPrettyName(string instanceIdentifier) {
|
---|
82 | return Regex.Match(instanceIdentifier, GetType().Namespace + @"\.Data\.(.*)\.txt").Groups[1].Captures[0].Value;
|
---|
83 | }
|
---|
84 |
|
---|
85 | private string GetDescription() {
|
---|
86 | return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + ".";
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|