In [1]:
using MatchingMarkets

In [2]:
m_prefs, f_prefs = random_prefs(4, 3);

In [3]:
m_prefs


Out[3]:
4×4 Array{Int64,2}:
 2  3  1  2
 0  2  0  1
 3  0  2  0
 1  1  3  3

In [4]:
f_prefs


Out[4]:
5×3 Array{Int64,2}:
 2  3  1
 4  2  3
 3  4  4
 0  0  0
 1  1  2

In [5]:
m_prefs, f_prefs = random_prefs(4, 3, allow_unmatched=false);

In [6]:
m_prefs


Out[6]:
4×4 Array{Int64,2}:
 2  3  2  3
 1  2  1  2
 3  1  3  1
 0  0  0  0

In [7]:
f_prefs


Out[7]:
5×3 Array{Int64,2}:
 1  2  4
 3  3  3
 4  4  1
 2  1  2
 0  0  0

In [8]:
s_prefs, c_prefs, caps = random_prefs(4, 3, ReturnCaps);

In [9]:
s_prefs


Out[9]:
4×4 Array{Int64,2}:
 3  2  3  3
 2  1  2  2
 1  0  1  1
 0  3  0  0

In [10]:
c_prefs


Out[10]:
5×3 Array{Int64,2}:
 4  1  3
 1  3  0
 0  0  1
 2  4  4
 3  2  2

In [11]:
caps


Out[11]:
3-element Array{Int64,1}:
 3
 2
 2

In [12]:
s_prefs, c_prefs, caps = random_prefs(4, 3, ReturnCaps, allow_unmatched=false);

In [13]:
s_prefs


Out[13]:
4×4 Array{Int64,2}:
 1  2  3  1
 2  1  1  3
 3  3  2  2
 0  0  0  0

In [14]:
c_prefs


Out[14]:
5×3 Array{Int64,2}:
 3  3  2
 1  4  1
 4  2  4
 2  1  3
 0  0  0

In [15]:
caps


Out[15]:
3-element Array{Int64,1}:
 2
 2
 2

In [16]:
?random_prefs


search: random_prefs

Out[16]:
random_prefs([rng, ]m, n[, ReturnCaps]; allow_unmatched=true)

Generate random preference order lists for two groups, say, m males and n females.

Each male has a preference order over femals [1, ..., n] and "unmatched" which is represented by 0, while each female has a preference order over males [1, ..., m] and "unmatched" which is again represented by 0.

The argument ReturnCaps should be supplied in the context of college admissions, in which case "males" and "females" should be read as "students" and "colleges", respectively, where each college has its capacity.

The optional rng argument specifies a random number generator.

Arguments

  • m::Integer : Number of males.
  • n::Integer : Number of females.
  • ::Type{ReturnCaps} : If supplied, caps is also returned.
  • ;allow_unmatched::Bool(true) : If false, return preference order lists of males and females where 0 is always placed in the last place, (i.e., "unmatched" is least preferred by every individual).

Returns

  • m_prefs::Matrix{Int} : Array of shape (n+1, m), where each column contains a random permutation of 0, 1, ..., n.
  • f_prefs::Matrix{Int} : Array of shape (m+1, n), where each column contains a random permutation of 0, 1, ..., m.
  • caps::Vector{Int} : Vector of length n containing each female's (or college's) capacity. Returned only when ReturnCaps is supplied.

Examples

julia> m_prefs, f_prefs = random_prefs(4, 3);

julia> m_prefs
4x4 Array{Int64,2}:
 3  3  1  3
 0  2  3  1
 2  1  2  0
 1  0  0  2

julia> f_prefs
5x3 Array{Int64,2}:
 1  2  4
 4  3  1
 3  4  2
 0  0  0
 2  1  3

julia> m_prefs, f_prefs = random_prefs(4, 3, allow_unmatched=false);

julia> m_prefs
4x4 Array{Int64,2}:
 1  3  1  2
 2  1  3  3
 3  2  2  1
 0  0  0  0

julia> f_prefs
5x3 Array{Int64,2}:
 1  2  3
 2  3  4
 4  1  1
 3  4  2
 0  0  0

julia> s_prefs, c_prefs, caps = random_prefs(4, 3, ReturnCaps);

julia> s_prefs
4x4 Array{Int64,2}:
 2  1  2  1
 1  3  1  0
 3  2  3  3
 0  0  0  2

julia> c_prefs
5x3 Array{Int64,2}:
 3  4  1
 0  1  4
 4  3  0
 1  2  3
 2  0  2

julia> caps
3-element Array{Int64,1}:
 1
 2
 2

In [ ]: