awkqap.gms : Input file generation with AWK for the Quadratic Assignment Problem

Description

The model writes an AWK script on the fly to process the input file
format defined by the maintainers of the QAPLib. More input instances
are available from

https://qaplib.mgi.polymtl.ca/


Small Model of Type : MIQCP


Category : GAMS Model library


Main file : awkqap.gms   includes :  tai7a.inc

$title Input file generation with AWK for the Quadratic Assignment Problem (AWKQAP,SEQ=296)

$onText
The model writes an AWK script on the fly to process the input file
format defined by the maintainers of the QAPLib. More input instances
are available from

https://qaplib.mgi.polymtl.ca/


Burkard, R E, Karisch, S E, and Rendl, F, QAPLIB - A Quadratic Assignment
Problem Library. Journal of Global Optimization 10 (1997), 391-403.

Keywords: mixed integer quadratic constraint programming, quadratic assignment problem,
          QAPLib, awk script
$offText

$set fn tai7a.inc
$if not exist %fn% $abort %fn% ist not present

$echoN "$setGlobal n " > %gams.scrdir%n.%gams.scrext%
$call head -n1 %fn%   >> "%gams.scrdir%n.%gams.scrext%"
$include %gams.scrdir%n.%gams.scrext%

$onEcho > %gams.scrdir%awkscript.%gams.scrext%
BEGIN { print "$onDelim" }
NF == 0 && cnter ==  0 { print "Table d(i,j)";
                         for (i=0; i <= %n%; i++) printf i " "; print }
NF == 0 && cnter == %n% { adj=%n%; print ";"; print "Table f(i,j)";
                          for (i=0; i <= %n%; i++) printf i " "; print }
NF == %n% { cnter++; print cnter-adj, $0; }
END { print ";"; print "$offDelim"; }
$offEcho
$call awk -f "%gams.scrdir%awkscript.%gams.scrext%" %fn% > "%gams.scrdir%data.%gams.scrext%"

Set i / 1*%n% /;

Alias (i,j,k,l);

$include %gams.scrdir%data.%gams.scrext%

* Let's do a trivial MIQCP model
Binary Variable x(i,j);

Variable z;

Equation defobj, assign1(i), assign2(j);

defobj..     z =e= sum((i,j,k,l)$(d(i,j)*f(k,l)), x(i,k)*d(i,j)*f(k,l)*x(j,l));

assign1(i).. sum(j,x(i,j)) =e= 1;

assign2(j).. sum(i,x(i,j)) =e= 1;

Model qap / all /;

* Starting Point
x.l(i,j) = 1/sqr(card(i));

option optCr = 0, optCa = 0.99;

solve qap minimizing z using miqcp;