Index: /branches/GeneralizedQAP/BenchmarkDataGenerator/App.config
===================================================================
--- /branches/GeneralizedQAP/BenchmarkDataGenerator/App.config	(revision 15578)
+++ /branches/GeneralizedQAP/BenchmarkDataGenerator/App.config	(revision 15578)
@@ -0,0 +1,6 @@
+﻿<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
+    </startup>
+</configuration>
Index: /branches/GeneralizedQAP/BenchmarkDataGenerator/BenchmarkDataGenerator.csproj
===================================================================
--- /branches/GeneralizedQAP/BenchmarkDataGenerator/BenchmarkDataGenerator.csproj	(revision 15578)
+++ /branches/GeneralizedQAP/BenchmarkDataGenerator/BenchmarkDataGenerator.csproj	(revision 15578)
@@ -0,0 +1,71 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{90FDB828-617C-4FA6-AF14-17B750770CBF}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>BenchmarkDataGenerator</RootNamespace>
+    <AssemblyName>BenchmarkDataGenerator</AssemblyName>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="alglibnet2, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>.\alglibnet2.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Common-3.3">
+      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
+      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.Instances-3.3">
+      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="HeuristicLab.Problems.Instances.QAPLIB-3.3">
+      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances.QAPLIB-3.3.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="alglibnet2.dll" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>
Index: /branches/GeneralizedQAP/BenchmarkDataGenerator/Program.cs
===================================================================
--- /branches/GeneralizedQAP/BenchmarkDataGenerator/Program.cs	(revision 15578)
+++ /branches/GeneralizedQAP/BenchmarkDataGenerator/Program.cs	(revision 15578)
@@ -0,0 +1,146 @@
+﻿using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.Instances.QAPLIB;
+
+namespace BenchmarkDataGenerator {
+  class Program {
+    static void Main(string[] args) {
+      var qaplib = new QAPLIBInstanceProvider();
+      foreach (var desc in qaplib.GetDataDescriptors()) {
+        var qap = qaplib.LoadData(desc);
+        if (qap.Dimension < 20) continue;
+
+        var swap = UpperToStream(qap.Distances).Any(x => x == 0)
+          && !UpperToStream(qap.Weights).Any(x => x == 0);
+
+        var weights = qap.Weights;
+        var distances = qap.Distances;
+        if (swap) {
+          weights = qap.Distances;
+          distances = qap.Weights;
+        }
+        
+
+        alglib.clusterizerstate s;
+        alglib.ahcreport rep;
+        
+
+        alglib.clusterizercreate(out s);
+        alglib.clusterizersetdistances(s, distances, true);
+        alglib.clusterizerrunahc(s, out rep);
+
+        var rcount = 0;
+        foreach (var r in new[] { qap.Dimension / 6.0, qap.Dimension / 3.0, qap.Dimension / 1.5 }) {
+          rcount++;
+          var k = (int)Math.Round(r);
+
+          int[] cidx;
+          int[] cz;
+
+          alglib.clusterizergetkclusters(rep, k, out cidx, out cz);
+          var clusters = cidx.Select((v, i) => new { Cluster = v, Location = i })
+                             .GroupBy(x => x.Cluster).ToDictionary(x => x.Key, x => x.Select(y => y.Location).ToList());
+
+          var gqapDist = new double[k, k];
+          for (var i = 0; i < k; i++) {
+            var locs = clusters[i];
+            for (var j = i + 1; j < k; j++) {
+              var locs2 = clusters[j];
+
+              var dist = 0.0;
+              foreach (var u in locs)
+                foreach (var v in locs2)
+                  dist += distances[u, v];
+
+              gqapDist[i, j] = (int)Math.Round(dist / (locs.Count * locs2.Count));
+              gqapDist[j, i] = gqapDist[i, j];
+            }
+          }
+
+          var avgWeight = ToStream(weights).Average();
+          var avgDistance = ToStream(gqapDist).Average();
+
+          var sysRand = new Random((qap.Name + k).GetHashCode());
+          var gqapInstall = new double[qap.Dimension, k];
+          for (var i = 0; i < qap.Dimension; i++)
+            for (var j = 0; j < k; j++)
+              gqapInstall[i, j] = sysRand.Next(1, (int)Math.Ceiling(qap.Dimension * avgWeight * avgDistance));
+
+          var gqapDemands = new double[qap.Dimension];
+          var totalDemand = 0.0;
+
+          for (var i = 0; i < qap.Dimension; i++) {
+            gqapDemands[i] = sysRand.Next(1, 100);
+            totalDemand += gqapDemands[i];
+          }
+          var minDemand = gqapDemands.Min();
+
+          foreach (var fac in new[] { 35, 50, 75, 95 }) {
+            var totalCap = (int)Math.Ceiling(100.0 * totalDemand / fac);
+            var gqapCapacities = new double[k];
+
+            while (true) {
+              var total = 0.0;
+              for (var i = 0; i < k; i++) {
+                gqapCapacities[i] = sysRand.NextDouble();
+                total += gqapCapacities[i];
+              }
+              for (var i = 0; i < k; i++) {
+                gqapCapacities[i] = (int)Math.Round(gqapCapacities[i] / total * totalCap);
+              }
+              // locations should be able to accomodate at least one equipment
+              // and one location should not be able to accomodate all equipments
+              if (gqapCapacities.All(x => x >= minDemand && x < totalDemand)) break;
+              else Console.WriteLine("{0}-{1}-{2}: Another try", qap.Name, k, fac);
+            }
+            var fname = qap.Name + "-" + k + "-" + fac;
+            Console.Write("Writing {0} ... ", fname);
+            var tc = rcount == 1 ? 4 : (rcount == 2 ? 2 : 1);
+            WriteInstance(fname, qap.Dimension, k, tc, weights, gqapDist, gqapInstall, gqapDemands, gqapCapacities);
+            Console.WriteLine("done.");
+          }
+        }
+      }
+    }
+
+    private static void WriteInstance(string name, int equipments, int locations, double tc, double[,] weights, double[,] distances, double[,] installCosts, double[] demands, double[] capacities) {
+      using (var writer = File.CreateText(name + ".gqap")) {
+        writer.WriteLine("\t{0}\t{1}\t{2}", equipments, locations, tc);
+        writer.WriteLine(ToString(weights));
+        writer.WriteLine(ToString(distances));
+        writer.WriteLine(ToString(installCosts));
+        writer.WriteLine(string.Join("\t", demands));
+        writer.WriteLine(string.Join("\t", capacities));
+      }
+    }
+
+    private static IEnumerable<double> ToStream(double[,] mat) {
+      for (var i = mat.GetLowerBound(0); i < mat.GetLowerBound(0) + mat.GetLength(0); i++)
+        for (var j = mat.GetLowerBound(1); j < mat.GetLowerBound(1) + mat.GetLength(1); j++)
+          yield return mat[i, j];
+    }
+
+    private static IEnumerable<double> UpperToStream(double[,] mat) {
+      var dim = mat.GetLength(0);
+      if (dim != mat.GetLength(1)) throw new InvalidOperationException("matrix is not symmetric");
+
+      for (var i = 0; i < dim - 1; i++)
+        for (var j = i + 1; j < dim; j++)
+          yield return mat[i, j];
+    }
+
+    private static string ToString(double[,] mat) {
+      var sb = new StringBuilder();
+      for (var i = mat.GetLowerBound(0); i < mat.GetLowerBound(0) + mat.GetLength(0); i++) {
+        if (i > mat.GetLowerBound(0)) sb.AppendLine();
+        for (var j = mat.GetLowerBound(1); j < mat.GetLowerBound(1) + mat.GetLength(1); j++) {
+          sb.Append("\t" + mat[i, j].ToString());
+        }
+      }
+      return sb.ToString();
+    }
+  }
+}
Index: /branches/GeneralizedQAP/BenchmarkDataGenerator/Properties/AssemblyInfo.cs
===================================================================
--- /branches/GeneralizedQAP/BenchmarkDataGenerator/Properties/AssemblyInfo.cs	(revision 15578)
+++ /branches/GeneralizedQAP/BenchmarkDataGenerator/Properties/AssemblyInfo.cs	(revision 15578)
@@ -0,0 +1,36 @@
+﻿using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("BenchmarkDataGenerator")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("BenchmarkDataGenerator")]
+[assembly: AssemblyCopyright("Copyright ©  2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components.  If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("90fdb828-617c-4fa6-af14-17b750770cbf")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Index: /branches/GeneralizedQAP/GeneralizedQAP.sln
===================================================================
--- /branches/GeneralizedQAP/GeneralizedQAP.sln	(revision 15577)
+++ /branches/GeneralizedQAP/GeneralizedQAP.sln	(revision 15578)
@@ -20,8 +20,7 @@
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms-3.3", "HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms\3.3\HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms-3.3.csproj", "{577239EC-7D7F-4505-A0A4-572E34010DBA}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BenchmarkDataGenerator", "BenchmarkDataGenerator\BenchmarkDataGenerator.csproj", "{90FDB828-617C-4FA6-AF14-17B750770CBF}"
+EndProject
 Global
-	GlobalSection(Performance) = preSolution
-		HasPerformanceSessions = true
-	EndGlobalSection
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -117,4 +116,16 @@
 		{577239EC-7D7F-4505-A0A4-572E34010DBA}.Release|x86.ActiveCfg = Release|Any CPU
 		{577239EC-7D7F-4505-A0A4-572E34010DBA}.Release|x86.Build.0 = Release|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Debug|x64.Build.0 = Debug|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Debug|x86.Build.0 = Debug|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Release|Any CPU.Build.0 = Release|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Release|x64.ActiveCfg = Release|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Release|x64.Build.0 = Release|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Release|x86.ActiveCfg = Release|Any CPU
+		{90FDB828-617C-4FA6-AF14-17B750770CBF}.Release|x86.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
@@ -133,3 +144,6 @@
 		HasPerformanceSessions = true
 	EndGlobalSection
+	GlobalSection(Performance) = preSolution
+		HasPerformanceSessions = true
+	EndGlobalSection
 EndGlobal
