https://github.com/mhahsler/qap
Heuristics for the Quadratic Assignment Problem (QAP) - R package
https://github.com/mhahsler/qap
combinatorial-optimization cran heuristic qap quadratic-assignment-problem r
Last synced: 24 days ago
JSON representation
Heuristics for the Quadratic Assignment Problem (QAP) - R package
- Host: GitHub
- URL: https://github.com/mhahsler/qap
- Owner: mhahsler
- License: gpl-3.0
- Created: 2015-09-30T14:09:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-27T22:16:18.000Z (9 months ago)
- Last Synced: 2024-11-02T02:42:27.148Z (7 months ago)
- Topics: combinatorial-optimization, cran, heuristic, qap, quadratic-assignment-problem, r
- Language: Fortran
- Homepage:
- Size: 543 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
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