Learn R Programming

matchingR (version 1.3.3)

cpp_wrapper_galeshapley: C++ wrapper for Gale-Shapley Algorithm

Description

This function provides an R wrapper for the C++ backend. Users should not call this function directly and instead use galeShapley.marriageMarket or galeShapley.collegeAdmissions.

Usage

cpp_wrapper_galeshapley(proposerPref, reviewerUtils)

Arguments

proposerPref

is a matrix with the preference order of the proposing side of the market. If there are n proposers and m reviewers in the market, then this matrix will be of dimension m by n. The i,jth element refers to j's ith most favorite partner. Preference orders must be complete and specified using C++ indexing (starting at 0).

reviewerUtils

is a matrix with cardinal utilities of the courted side of the market. If there are n proposers and m reviewers, then this matrix will be of dimension n by m. The i,jth element refers to the payoff that individual j receives from being matched to individual i.

Value

A list with elements that specify who is matched to whom. Suppose there are n proposers and m reviewers. The list contains the following items:

  • proposals is a vector of length n whose ith element contains the number of the reviewer that proposer i is matched to using C++ indexing. Proposers that remain unmatched will be listed as being matched to m.

  • engagements is a vector of length m whose jth element contains the number of the proposer that reviewer j is matched to using C++ indexing. Reviwers that remain unmatched will be listed as being matched to n.