Stable marriage problem with transferable utilities
There's two implementations that should somewhat cover your needs, matchingR which does reduced-form algorithmic matching and matchingMarkets, which estimates estructural matching models with some baysean tools to correct for endogeneity. 

The problem is you're looking for some very specific models which may require some tweaks on these implementations.