| qap | R Documentation |
Solve a quadratic assignment problem (QAP) with a simulated annealing
heuristic. qap.obj() calculates the objective value of an assignment.
qap(A, B, method = NULL, ...)
qap.obj(A, B, o)
A |
A numeric matrix of flows between facilities. For |
B |
A numeric matrix of distances between locations. For |
method |
Solver name. Currently only |
... |
Additional arguments passed to the simulated annealing solver. See Details. |
o |
A permutation of |
The problem is to assign n facilities to n locations to minimize total transportation or
interaction costs.
Required flows between the facilities are represented by the matrix A and distances between locations
is given in matrix B. The QAP seeks an assignment that minimizes the
sum of flows times distance.
For an assignment represented by a n \times n permutation matrix X used to
assign the facilities to the locations in the order given by the
permutation,
the objective can be written as
\min_{X \in \Pi}\; \mathrm{tr}(AXB^TX^T)
where \Pi is the set of all valid n \times n permutation matrices.
Note that for symmetric distances, the distance matrix B does not need to be transposed.
The QAP originated as a facility location problem (Koopmans and Beckmann, 1957) and also has applications in data analysis (Hubert and Schultz, 1976). It is NP-hard. The solver uses the simulated annealing heuristic of Burkard and Rendl (1984), based on Rendl's Fortran implementation from QAPLIB. The authors suggest it can produce heuristic solutions for problems with up to 256 objects, although the implementation does not enforce this limit.
Additional solver arguments are:
repPositive integer number of restarts; default 1L.
miterPositive integer number of iterations at a fixed temperature; default
2 * nrow(A).
fiterFactor of at least 1 by which miter grows
after each cooling step; default 1.1.
ftFactor by which the temperature decreases after each
cooling step; default 0.5 (strictly between 0 and 1).
maxstepsPositive integer maximum number of cooling steps; default
50L.
verbosePrint progress; default FALSE.
qap() returns an integer vector of facility to location
assignments with the objective value in its "obj" attribute.
qap.obj() returns the objective value for permutation o.
Burkard, R. E. and Rendl, F. (1984). A thermodynamically motivated simulation procedure for combinatorial optimization problems. European Journal of Operational Research, 17(2), 169-174. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/0377-2217(84)90231-5")}
Koopmans, T. C. and Beckmann, M. (1957). Assignment problems and the location of economic activities. Econometrica, 25(1), 53-76. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/1907742")}
Hubert, L. and Schultz, J. (1976). Quadratic assignment as a general data analysis strategy. British Journal of Mathematical and Statistical Psychology, 29(2), 190-241. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/j.2044-8317.1976.tb00714.x")}
read_qaplib()
p <- read_qaplib(system.file("qaplib", "had12.dat", package = "qap"))
a <- qap(p$A, p$B, verbose = TRUE)
a
qap.obj(p$A, p$B, a)
(attr(a, "obj") - p$opt) / p$opt * 100
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.