MyNixOS website logo
Description

Heuristics for the Quadratic Assignment Problem (QAP).

Implements heuristics for the Quadratic Assignment Problem (QAP). Although, the QAP was introduced as a combinatorial optimization problem for the facility location problem in operations research, it also has many applications in data analysis. The problem is NP-hard and the package implements a simulated annealing heuristic.

R package qap - Heuristics for the Quadratic Assignment Problem (QAP)

CRANversion stream r-universestatus CRAN RStudio mirrordownloads

This package implements heuristics for the Quadratic Assignment Problem (QAP) first introduced by Koopmans and Beckmann (1957). Although, the QAP was introduced as a combinatorial optimization problem for the facility location problem in operations research, it also has many applications in data analysis (see Hubert and Schultz; 1976).

The problem is NP-hard and the package implements the simulated annealing heuristic described in Burkard and Rendl (1984).

Installation

Stable CRAN version: Install from within R with

install.packages("qap")

Current development version: Install from r-universe.

install.packages("qap", repos = "https://mhahsler.r-universe.dev")

Usage

The package contains a copy of the problem instances and solutions from 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.

library(qap)
set.seed(1000)

p <- read_qaplib(system.file("qaplib", "had20.dat", package = "qap"))
p$solution
##  [1]  8 15 16 14 19  6  7 17  1 12 10 11  5 20  2  3  4  9 18 13
p$opt
## [1] 6922

We run the simulated annealing heuristic 10 times and use the best solution.

a <- qap(p$A, p$B, rep = 10)
a
##  [1]  8 15 16 14 19  6  7 12  1 11 10  5  3 20  2 17  4  9 18 13
## attr(,"obj")
## [1] 6926

Compare the solution with known optimum (% above optimum).

(attr(a, "obj") - p$opt)/p$opt * 100
## [1] 0.058

References

Metadata

Version

0.1-2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows