Learn R Programming

matchFeat (version 1.0)

match.2x: Pairwise Interchange Heuristic (2-Assignment-Exchange)

Description

This function implements the Pairwise Interchange Heuristic for the multidimensional assignment problem with decomposable costs (MDADC).

Usage

match.2x(x, sigma = NULL, unit = NULL, w = NULL, control = list())

Value

A list of class matchFeat with components

sigma

best assignment as set of permutations (\((m,n)\) matrix)

cluster

best assignment as a cluster membership vector

objective

minimum objective value

mu

mean vector for each class/label (\((p,m)\) matrix)

V

covariance matrix for each class/label (\((p,p,m)\) array)

call

function call

Arguments

x

data: matrix of dimensions \((mn,p)\) or 3D array of dimensions \((p,m,n)\) with \(m\) = number of labels/classes, \(n\) = number of sample units, and \(p\) = number of variables)

sigma

permutations: matrix of dimensions \((m,n)\)

unit

integer (=number of units) or vector mapping rows of x to sample units (length \(mn\)). Must be specified only if x is a matrix.

w

weights for loss function: single positive number, \(p\)-vector of length, or \((p,p)\) positive definite matrix

control

tuning parameters

Details

Use of this function requires to have the GUROBI software and its R interface package installed. Both can be downloaded from https://www.gurobi.com after obtaining a free academic license.

References

Degras (2022) "Scalable feature matching across large data collections." tools:::Rd_expr_doi("10.1080/10618600.2022.2074429")

See Also

match.bca, match.bca.gen, match.gaussmix, match.kmeans, match.rec, match.template

Examples

Run this code
if (require(gurobi)) {
## Generate small example
  m <- 3  # number of classes
  n <- 10 # number of statistical units 
  p <- 5  # number of variables
  mu <- matrix(rnorm(p*m),p,m) # mean vectors
  sigma <- 0.1
  x <- array(as.vector(mu) + rnorm(p*m*n,sigma), c(p,m,n))

## Match all feature vectors
  result <- match.2x(x)

## Display results 
  result$cost  # objective value = assignment cost
  result$sigma # solution permutations
  xmatched <- array(dim=dim(x)) 
  
## Matched feature vectors
  for (i in 1:n)
	  xmatched[,,i] <- x[,result$sigma[,i],i]
	
}

Run the code above in your browser using DataLab