| roommate.checkStability {matchingR} | R Documentation |
Check if a roommate matching is stable
Description
This function checks if a particular roommate matching is stable. A matching
is stable if there is no roommate r1 that would rather be matched to
some other roommate d2 than to his current roommate r2 and the
other roommate d2 would rather be matched to r1 than to his
current roommate d1.
Usage
roommate.checkStability(utils = NULL, pref = NULL, matching)
Arguments
utils |
is a matrix with cardinal utilities for each individual in the
market. If there are |
pref |
is a matrix with the preference order of each individual in the
market. This argument is only required when |
matching |
is a vector of length |
Value
true if stable, false if not
Examples
# define preferences
pref <- matrix(c(
3, 1, 2, 3,
4, 3, 4, 2,
2, 4, 1, 1
), byrow = TRUE, ncol = 4)
pref
# compute matching
results <- roommate(pref = pref)
results
# check if matching is stable
roommate.checkStability(pref = pref, matching = results)