Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PTSP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBHomogeneousPTSPInstanceProvider.cs @ 13470

Last change on this file since 13470 was 13470, checked in by abeham, 9 years ago

#2221:

  • implemented review comments
    • hid rng as private class, implemented djb2 hash function (hash function implementation may also change)
    • added missing probabilities
    • base class for instance providers
    • prebuild event events
    • build platforms
    • unit test will be removed on trunk integration
    • corrected assembly file version
    • distance calculator parameter was not hidden, can be changed by user, updates distance matrix
    • fixed performance problems (ouch!) also for estimated ptsp (inlined GetDistance method)
  • added moves (full evaluation) for analytical tsp
  • added local improvement operators for analytical ptsp
  • added recalculation of distance matrix when parameters change
  • still lots of other changes
File size: 2.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Collections.Generic;
23using System.Globalization;
24using System.Linq;
25
26namespace HeuristicLab.Problems.Instances.TSPLIB {
27  public class TSPLIBHomogeneousPTSPInstanceProvider : TSPLIBPTSPInstanceProvider {
28    private static readonly double[] Probabilities = new[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 };
29
30    public override string Name {
31      get { return "TSPLIB (homogeneous symmetric PTSP)"; }
32    }
33
34    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
35      var tspDescriptors = base.GetDataDescriptors().OfType<TSPLIBDataDescriptor>();
36      foreach (var desc in tspDescriptors) {
37        foreach (var p in Probabilities) {
38          yield return new TSPLIBHomogeneousPTSPDataDescriptor(
39            desc.Name + "-" + p.ToString(CultureInfo.InvariantCulture.NumberFormat),
40            desc.Description,
41            desc.InstanceIdentifier,
42            p == 1.0 ? desc.SolutionIdentifier : null,
43            p);
44        }
45      }
46    }
47
48    protected override double[] GetProbabilities(IDataDescriptor descriptor, PTSPData instance) {
49      var ptspDesc = descriptor as TSPLIBHomogeneousPTSPDataDescriptor;
50      return ptspDesc != null ? Enumerable.Range(0, instance.Dimension).Select(_ => ptspDesc.Probability).ToArray()
51                              : Enumerable.Range(0, instance.Dimension).Select(_ => 0.5).ToArray();
52    }
53  }
54}
Note: See TracBrowser for help on using the repository browser.