Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GeneralizedQAP/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs @ 7505

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

#1614

  • added instances of Cordeau et al. as given by L. Moccia
  • added operators for tabu search
File size: 3.4 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.Linq;
25using System.Reflection;
26using System.Text.RegularExpressions;
27
28namespace 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.
45A memetic heuristic for the generalized quadratic assignment problem.
46INFORMS 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 datParser = new CordeauGQAPParser();
64        datParser.Parse(stream);
65        if (datParser.Error != null) throw datParser.Error;
66        instance.Equipments = datParser.Equipments;
67        instance.Locations = datParser.Locations;
68        instance.Weights = datParser.Weights;
69        instance.Distances = datParser.Distances;
70        instance.InstallationCosts = datParser.InstallationCosts;
71        instance.TransportationCosts = datParser.TransportationCosts;
72
73        instance.Name = id.Name;
74        instance.Description = id.Description;
75      }
76      return instance;
77    }
78
79    private string GetPrettyName(string instanceIdentifier) {
80      return Regex.Match(instanceIdentifier, GetType().Namespace + @"\.Data\.(.*)\.txt").Groups[1].Captures[0].Value;
81    }
82
83    private string GetDescription() {
84      return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + ".";
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.