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). 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).

pkg_usage(pkg)
pkg_citation(pkg)
pkg_install(pkg)

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
p$opt

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

a <- qap(p$A, p$B, rep = 10)
a

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

(attr(a, "obj") - p$opt)/p$opt * 100

References

  print(citation("qap"), style = "text")


mhahsler/qap documentation built on April 24, 2024, 10:07 p.m.