Finds the stable matching in the house allocation problem with existing tenants. Uses the Top-Trading-Cycles Algorithm proposed in Abdulkadiroglu and Sonmez (1999).

1 |

`P` |
list of individuals' preference rankings over objects. |

`X` |
2-column-matrix of objects ( |

`ttc`

returns a 2-column matrix of the stable matching solution for the housing market problem based on the Top-Trading-Cycles algorithm.

Thilo Klein

Abdulkadiroglu, A. and Sonmez, T. (1999). House Allocation with Existing Tenants. *Journal of Economic Theory*, 88(2):233–260.

Shapley, L. and H. Scarf (1974). On Cores and Indivisibility. *Journal of Mathematical Economics*, 1(1):23–37.

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
## generate list of individuals' preference rankings over objects
P <- list()
P[[1]] <- c(2,5,1,4,3) # individual 1
P[[2]] <- c(1,5,4,3,2) # individual 2
P[[3]] <- c(2,1,4,3,5) # individual 3
P[[4]] <- c(2,4,3,1,5) # individual 4
P[[5]] <- c(4,3,1,2,5); P # individual 5
## generate 2-column-matrix of objects ('obj') and their owners ('ind')
X <- data.frame(ind=1:5, obj=1:5); X
## find assignment based on TTC algorithm
ttc(P=P,X=X)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.