課題4:DAアルゴリズム (many-to-one)

瀧川英輝


In [1]:
using MyMatching

ソースコードはこちら
とりあえず、one-to-oneの例を試してみます


In [2]:
m_prefs = [[3], [3, 2, 1], [1, 3, 2], [3, 1]]
f_prefs = [[2, 3], [2, 3, 4, 1], [4, 1, 2]];

In [3]:
my_deferred_acceptance(m_prefs, f_prefs)


Out[3]:
([0, 2, 1, 3], [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];

In [5]:
my_deferred_acceptance(prop_prefs, resp_prefs, caps)


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

期待通りの結果が出てくれました
最後にテストを実行します


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


INFO: Testing MyMatching
Test Summary:               | Pass  Total
Testing deferred acceptance |   18     18
INFO: MyMatching tests passed