土屋直之です。リンクはこちら。


In [1]:
using MyMatching

testを実行します。


In [2]:
Pkg.test("MyMatching")


INFO: Testing MyMatching
INFO: MyMatching tests passed

testは通りました。次にone-to-oneのWikipediaの例を試してみます。


In [3]:
prop_prefs = [[1, 2, 3, 4], [3, 2, 1, 4], [1, 2, 4, 3], [3, 1, 4, 2]]
resp_prefs = [[1, 2, 3, 4], [2, 1, 4, 3], [2, 3, 1, 4], [1, 4, 3, 2]]
my_deferred_acceptance(prop_prefs, resp_prefs)


Out[3]:
([1,3,2,4],[1,3,2,4])

次に、many-to-oneの医師臨床研修マッチング協議会の例を試してみます。


In [4]:
prop_prefs = [[2], [2, 1], [2, 1], [1, 2, 3, 4], [2, 1, 4, 3], [2, 3, 1, 4], [2, 1, 4, 3], [4, 2, 1, 3]]
resp_prefs = [[3, 7], [7, 8, 5, 1, 2, 3, 4, 6], [2, 5, 8, 1, 3, 4, 7], [2, 5, 1, 3, 6, 4, 7]]
caps = [2, 2, 2, 2]
my_deferred_acceptance(prop_prefs, resp_prefs, caps)


Out[4]:
([0,0,1,3,4,4,2,2],[3,0,7,8,4,0,6,5],[1,3,5,7,9])

以上のように、正しくマッチングされました。