卒業論文


第6章「経済実験」


In [1]:
# coding: UTF-8
%matplotlib inline
import itertools
import numpy as np
import matplotlib.pyplot as plt
import matchfuncs as mf

In [2]:
prop_num = 4
resp_num = 4
prop_prefs = [
    [3, 1, 0, 2],
    [1, 3, 2, 0],
    [2, 3, 0, 1],
    [3, 1, 2, 0]
]
resp_prefs = [
    [3, 0, 2, 1],
    [3, 0, 2, 1],
    [3, 0, 2, 1],
    [3, 0, 2, 1]
]
prop_caps = [1, 1, 2, 2]
resp_caps = [1, 1, 2, 2]
list_length = 2

In [3]:
prop_matched, resp_matched, prop_indptr, resp_indptr = mf.BOS(prop_prefs, resp_prefs, resp_caps, prop_caps, list_length)
print('prop_matched = ' + str(prop_matched))
print('resp_matched = ' + str(resp_matched))
print('prop_indptr = ' + str(prop_indptr))
print('resp_indptr = ' + str(resp_indptr))
mf.Graph(prop_matched, resp_matched, prop_indptr, resp_indptr, prop_name=["1", "2", "3", "4"], resp_name=["A", "B", "C", "D"])
plt.savefig('bos.png', dpi=150)


prop_matched = [3 1 2 0 3 2]
resp_matched = [2 1 2 3 0 3]
prop_indptr = [0 1 2 4 6]
resp_indptr = [0 1 2 4 6]

In [5]:
prop_matched, resp_matched, prop_indptr, resp_indptr = mf.DA(prop_prefs, resp_prefs, resp_caps, prop_caps, list_length)
print('prop_matched = ' + str(prop_matched))
print('resp_matched = ' + str(resp_matched))
print('prop_indptr = ' + str(prop_indptr))
print('resp_indptr = ' + str(resp_indptr))
mf.Graph(prop_matched, resp_matched, prop_indptr, resp_indptr, prop_name=["1", "2", "3", "4"], resp_name=["A", "B", "C", "D"])
plt.savefig('da.png', dpi=150)


prop_matched = [3 4 2 4 3 1]
resp_matched = [4 3 2 4 0 3]
prop_indptr = [0 1 2 4 6]
resp_indptr = [0 1 2 4 6]

In [6]:
mf.Comp('BOS', prop_prefs, prop_prefs, resp_prefs, resp_caps, prop_caps, list_length)


Out[6]:
(1.0, 4.0, 1.0, 0.5, 0.0, 0.0, 6.0)

In [7]:
mf.Comp('DA', prop_prefs, prop_prefs, resp_prefs, resp_caps, prop_caps, list_length)


Out[7]:
(2.0, 4.0, 0.5, 0.5, 1.0, 2.0, 8.0)

In [7]:
data1 = np.loadtxt("data/grad/data1.csv",delimiter=",").astype(int)

In [8]:
data2 = np.loadtxt("data/grad/data2.csv",delimiter=",").astype(int)

In [9]:
list_length = 2
values1 = [0, 0, 0, 0, 0, 0, 0]
for i in range(5):
    prefs = data1[4*i:4*i+4].tolist()
    values1 += np.array(mf.Comp('BOS', prefs, prop_prefs, resp_prefs, resp_caps, prop_caps, list_length))
values1 /= 5
print(values1)


[ 1.8  1.6  1.3  0.8  0.   1.   6. ]

In [10]:
list_length = 2
values2 = [0, 0, 0, 0, 0, 0, 0]
for i in range(5):
    prefs = data2[4*i:4*i+4].tolist()
    values2 += np.array(mf.Comp('DA', prefs, prop_prefs, resp_prefs, resp_caps, prop_caps, list_length))
values2 /= 5
print(values2)


[ 2.8  0.6  1.3  0.2  0.6  0.8  8. ]