金正賢です。 MyMatchingのコードは以下より https://github.com/ellenjunghyunkim/MyMatching.jl/blob/master/src/MyMatching.jl my_deferred_acceptanceのデモです。


In [1]:
using MyMatching

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


INFO: Checking out MyMatching master...
INFO: Pulling MyMatching latest master...
INFO: No packages to install, update or remove

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


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

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

In [5]:
my_deferred_acceptance(m_prefs, f_prefs)


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

In [6]:
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]];

In [7]:
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]];

In [8]:
caps = [2, 2, 2, 2];

In [9]:
my_deferred_acceptance(prop_prefs::Vector{Vector{Int}},
                                resp_prefs::Vector{Vector{Int}},
                                caps::Vector{Int})


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

遅くなりました💦