- Timestamp:
- 06/10/17 23:19:11 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Problems.Instances.QAPLIB/3.3/OneSizeInstanceProvider.cs
r14691 r15031 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 4 using System.Text.RegularExpressions; 6 5 7 6 namespace HeuristicLab.Problems.Instances.QAPLIB { … … 9 8 public override IEnumerable<IDataDescriptor> GetDataDescriptors() { 10 9 var drezner = new DreznerQAPInstanceProvider(); 11 foreach (var desc in drezner.GetDataDescriptors()) 12 yield return new OneSizeDataDescriptor(desc.Name + "-25", desc.Description, drezner, desc); 10 foreach (var desc in drezner.GetDataDescriptors()) { 11 var dim = int.Parse(Regex.Match(desc.Name, "dre(?<g>\\d+)").Groups["g"].Value); 12 if (dim < 25) continue; 13 yield return new OneSizeDataDescriptor(desc.Name + (dim == 25 ? "" : "-25"), desc.Description, drezner, desc); 14 } 15 // Microarray instances are all greater than 25 dimensions 13 16 var microarray = new MicroarrayQAPInstanceProvider(); 14 foreach (var desc in microarray.GetDataDescriptors()) 17 foreach (var desc in microarray.GetDataDescriptors()) { 15 18 yield return new OneSizeDataDescriptor(desc.Name + "-25", desc.Description, microarray, desc); 19 } 16 20 var qaplib = new QAPLIBInstanceProvider(); 17 foreach (var desc in qaplib.GetDataDescriptors()) 18 yield return new OneSizeDataDescriptor(desc.Name + "-25", desc.Description, qaplib, desc); 21 foreach (var desc in qaplib.GetDataDescriptors()) { 22 var instance = qaplib.LoadData(desc); 23 if (instance.Dimension < 25) continue; 24 yield return new OneSizeDataDescriptor(desc.Name + (instance.Dimension == 25 ? "" : "-25"), desc.Description, qaplib, desc); 25 } 26 // Taillard's instances are basically from the same distribution 27 // to avoid over-representation in the set only the tai27e are taken and reduced to 25 dimension 19 28 var taillard = new TaillardQAPInstanceProvider(); 20 foreach (var desc in taillard.GetDataDescriptors()) 29 foreach (var desc in taillard.GetDataDescriptors()) { 30 if (!desc.Name.StartsWith("tai27e")) continue; 21 31 yield return new OneSizeDataDescriptor(desc.Name + "-25", desc.Description, taillard, desc); 32 } 22 33 } 23 34 … … 59 70 data.Dimension = 25; 60 71 data.Name += "-25"; 61 data.Description += " (reduced or enlargedto 25 dimensions)";72 data.Description += " (reduced to 25 dimensions)"; 62 73 63 74 return data; … … 68 79 public override Uri WebLink { get { return null; } } 69 80 public override string ReferencePublication { get { return string.Empty; } } 70 71 // permutation must be strictly different in every position 81 72 82 private static void Shuffle(int[] p, Random random) { 73 83 for (var i = p.Length - 1; i > 0; i--) { 74 // Swap element "i" with a random earlier element (excluding itself)75 84 var swapIndex = random.Next(i + 1); 76 85 var h = p[swapIndex];
Note: See TracChangeset
for help on using the changeset viewer.