Description Usage Arguments Value Examples
This function checks if a given matching is stable for a particular set of
preferences. This stability check can be applied to both the stable marriage
problem and the college admission problem. The function requires preferences
to be specified in cardinal form. If necessary, the function
rankIndex
can be used to turn ordinal preferences into cardinal
utilities.
1 2 3 4 5 6 | galeShapley.checkStability(
proposerUtils,
reviewerUtils,
proposals,
engagements
)
|
proposerUtils |
is a matrix with cardinal utilities of the proposing
side of the market. If there are |
reviewerUtils |
is a matrix with cardinal utilities of the courted side
of the market. If there are |
proposals |
is a matrix that contains the number of the reviewer that a given proposer is matched to: the first row contains the reviewer that is matched to the first proposer, the second row contains the reviewer that is matched to the second proposer, etc. The column dimension accommodates proposers with multiple slots. |
engagements |
is a matrix that contains the number of the proposer that a given reviewer is matched to. The column dimension accommodates reviewers with multiple slots. |
true if the matching is stable, false otherwise
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # define cardinal utilities
uM <- matrix(c(
0.52, 0.85,
0.96, 0.63,
0.82, 0.08,
0.55, 0.34
), nrow = 4, byrow = TRUE)
uW <- matrix(c(
0.76, 0.88, 0.74, 0.02,
0.32, 0.21, 0.02, 0.79
), ncol = 4, byrow = TRUE)
# define matching
results <- list(
proposals = matrix(c(2, 1), ncol = 1),
engagements = matrix(c(2, 1, NA, NA), ncol = 1)
)
# check stability
galeShapley.checkStability(uM, uW, results$proposals, results$engagements)
# if preferences are in ordinal form, we can use galeShapley.validate
# to transform them into cardinal form and then use checkStability()
prefM <- matrix(c(
2, 1,
3, 2,
4, 4,
1, 3
), nrow = 4, byrow = TRUE)
prefW <- matrix(c(
1, 1, 1, 2,
2, 2, 2, 1
), ncol = 4, byrow = TRUE)
# define matching
results <- list(
proposals = matrix(c(2, 1), ncol = 1),
engagements = matrix(c(2, 1, NA, NA), ncol = 1)
)
# check stability
pref.validated <- galeShapley.validate(
proposerPref = prefM,
reviewerPref = prefW
)
galeShapley.checkStability(
pref.validated$proposerUtils,
pref.validated$reviewerUtils,
results$proposals,
results$engagements
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.