-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.Rmd
More file actions
69 lines (53 loc) · 2.18 KB
/
README.Rmd
File metadata and controls
69 lines (53 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
output: github_document
---
```{r echo=FALSE, results = 'asis'}
pkg <- 'qap'
source("https://raw.githubusercontent.com/mhahsler/pkg_helpers/main/pkg_helpers.R")
pkg_title(pkg)
```
## Introduction
This package implements heuristics for the [Quadratic Assignment Problem (QAP)](https://en.wikipedia.org/wiki/Quadratic_assignment_problem).
The QAP was introduced as a combinatorial optimization problem from the category of facilities location
problems in operations research (Koopmans and Beckmann; 1957).
It also has many applications in data analysis including cluster analysis and seriation (see Hubert and Schultz; 1976).
The problem is NP-hard and the package implements the very effective simulated annealing heuristic
described in Burkard and Rendl (1984).
```{r echo=FALSE, results = 'asis'}
pkg_usage(pkg)
pkg_citation(pkg)
pkg_install(pkg)
```
## Usage
The package contains a copy of the problem instances and solutions
from [QAPLIB](https://coral.ise.lehigh.edu/data-sets/qaplib/).
We load the `had20` QAPLIB problem. The problem contains the A and B matrices and the optimal solution and the optimal
objective function value.
```{r}
library(qap)
set.seed(1000)
p <- read_qaplib(system.file("qaplib", "had20.dat", package = "qap"))
p$solution
p$opt
```
We run the simulated annealing heuristic 10 times and use the best solution.
```{r}
a <- qap(p$A, p$B, rep = 10)
a
```
Compare the solution with known optimum (% above optimum).
```{r}
(attr(a, "obj") - p$opt)/p$opt * 100
```
## References
*
```{r results="asis", echo = FALSE}
print(citation("qap"), style = "text")
```
* R.E. Burkard and F. Rendl (1984). A thermodynamically motivated simulation procedure for combinatorial optimization problems. _European Journal of Operations Research,_ 17(2):169-174.
https://doi.org/10.1016/0377-2217(84)90231-5
* Koopmans TC, Beckmann M (1957). Assignment problems and the location of economic activities. _Econometrica_ 25(1):53-76.
https://doi.org/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.
https://doi.org/10.1111/j.2044-8317.1976.tb00714.x