Changeset 8909


Ignore:
Timestamp:
11/13/12 16:00:58 (9 years ago)
Author:
abeham
Message:

#1841: Added further QAP instances from Z. Drezner, E. Taillard, and S. Rahmann

Location:
trunk/sources
Files:
9 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.QAPLIB/3.3/HeuristicLab.Problems.Instances.QAPLIB-3.3.csproj

    r8624 r8909  
    103103  <ItemGroup>
    104104    <Reference Include="ICSharpCode.SharpZipLib">
    105     <HintPath>..\..\HeuristicLab.PluginInfrastructure\3.3\ICSharpCode.SharpZipLib.dll</HintPath>
    106     <Private>False</Private>
    107   </Reference>
     105      <HintPath>..\..\HeuristicLab.PluginInfrastructure\3.3\ICSharpCode.SharpZipLib.dll</HintPath>
     106      <Private>False</Private>
     107    </Reference>
    108108    <Reference Include="System" />
    109109    <Reference Include="System.Core" />
     
    111111  </ItemGroup>
    112112  <ItemGroup>
     113    <Compile Include="TaillardQAPInstanceProvider.cs" />
     114    <Compile Include="DreznerQAPInstanceProvider.cs" />
     115    <Compile Include="MicroarrayQAPInstanceProvider.cs" />
    113116    <Compile Include="QAPLIBParser.cs" />
    114117    <Compile Include="QAPLIBDataDescriptor.cs" />
     
    117120    <EmbeddedResource Include="Data\qap.dat.zip" />
    118121    <EmbeddedResource Include="Data\qap.sln.zip" />
     122    <EmbeddedResource Include="Data\microarray.dat.zip" />
     123    <EmbeddedResource Include="Data\microarray.sln.zip" />
     124    <EmbeddedResource Include="Data\drezner.dat.zip" />
     125    <EmbeddedResource Include="Data\drezner.sln.zip" />
     126    <EmbeddedResource Include="Data\taillard.dat.zip" />
     127    <EmbeddedResource Include="Data\taillard.sln.zip" />
    119128    <None Include="Plugin.cs.frame" />
    120129    <Compile Include="Plugin.cs" />
     
    144153  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    145154  <PropertyGroup>
    146    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     155    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    147156set ProjectDir=$(ProjectDir)
    148157set SolutionDir=$(SolutionDir)
     
    150159
    151160call PreBuildEvent.cmd</PreBuildEvent>
    152 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     161    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    153162export ProjectDir=$(ProjectDir)
    154163export SolutionDir=$(SolutionDir)
  • trunk/sources/HeuristicLab.Problems.Instances.QAPLIB/3.3/QAPLIBInstanceProvider.cs

    r8553 r8909  
    167167    }
    168168
    169     private const string FileName = "qap";
     169    protected virtual string FileName { get { return "qap"; } }
    170170
    171171    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
  • trunk/sources/HeuristicLab.Problems.Instances.QAPLIB/3.3/QAPLIBParser.cs

    r7558 r8909  
    5858      Distances = new double[Size, Size];
    5959      Weights = new double[Size, Size];
    60       char[] delim = new char[] { ' ' };
     60      char[] delim = new char[] { ' ', '\t' };
    6161
    6262      Weights = ParseMatrix(reader, delim);
  • trunk/sources/HeuristicLab.Problems.Instances.QAPLIB/3.3/QAPLIBSolutionParser.cs

    r8553 r8909  
    2323using System.Globalization;
    2424using System.IO;
     25using System.Linq;
    2526
    2627namespace HeuristicLab.Problems.Instances.QAPLIB {
     
    8182      try {
    8283        StreamReader reader = new StreamReader(stream);
    83         char[] delim = new char[] { ' ', ',' }; // comma is added for nug30.sln which is the only file that separates the permutation with commas
     84        char[] delim = new char[] { ' ', '\t', ',' }; // comma is added for nug30.sln which is the only file that separates the permutation with commas
    8485        string[] firstline = reader.ReadLine().Split(delim, StringSplitOptions.RemoveEmptyEntries);
    8586        Size = int.Parse(firstline[0]);
     
    9091          string valLine = reader.ReadLine();
    9192          string[] vals = valLine.Split(delim, StringSplitOptions.RemoveEmptyEntries);
     93          int start = 1;
     94          if (vals.Any(x => x == "0")) start = 0;
    9295          if (vals.Length == 0) continue;
    9396          for (int j = 0; j < vals.Length; j++) {
    9497            if (valueAsLocation)
    95               Assignment[int.Parse(vals[j]) - 1] = read++;
    96             else Assignment[read++] = int.Parse(vals[j]) - 1;
     98              Assignment[int.Parse(vals[j]) - start] = read++;
     99            else Assignment[read++] = int.Parse(vals[j]) - start;
    97100          }
    98101        }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Problems.Instances-3.3/QAPLIBInstanceProviderTest.cs

    r7915 r8909  
    4646      Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
    4747    }
     48
     49    [TestMethod()]
     50    public void GetMicroarrayQAPInstanceTest() {
     51      var target = new MicroarrayQAPInstanceProvider();
     52      StringBuilder erroneousInstances = new StringBuilder();
     53      int count = 0;
     54      foreach (var id in target.GetDataDescriptors()) {
     55        try {
     56          target.LoadData(id);
     57        } catch (Exception ex) {
     58          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
     59        }
     60        count++;
     61      }
     62      Assert.IsTrue(count > 0, "No problem instances were found.");
     63      Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
     64    }
     65
     66    [TestMethod()]
     67    public void GetDreznerQAPInstanceTest() {
     68      var target = new DreznerQAPInstanceProvider();
     69      StringBuilder erroneousInstances = new StringBuilder();
     70      int count = 0;
     71      foreach (var id in target.GetDataDescriptors()) {
     72        try {
     73          target.LoadData(id);
     74        } catch (Exception ex) {
     75          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
     76        }
     77        count++;
     78      }
     79      Assert.IsTrue(count > 0, "No problem instances were found.");
     80      Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
     81    }
     82
     83    [TestMethod()]
     84    public void GetTaillardQAPInstanceTest() {
     85      var target = new TaillardQAPInstanceProvider();
     86      StringBuilder erroneousInstances = new StringBuilder();
     87      int count = 0;
     88      foreach (var id in target.GetDataDescriptors()) {
     89        try {
     90          target.LoadData(id);
     91        } catch (Exception ex) {
     92          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
     93        }
     94        count++;
     95      }
     96      Assert.IsTrue(count > 0, "No problem instances were found.");
     97      Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
     98    }
    4899  }
    49100}
Note: See TracChangeset for help on using the changeset viewer.