This commit is contained in:
wjsjwr 2022-07-24 11:07:11 +08:00
parent 0ef1ced753
commit 8c2f24ee09
17 changed files with 58 additions and 27 deletions

View File

@ -6,9 +6,9 @@ import json
def calcAndSave(mode, network_type=None):
MAX_ROUND = 30
MAX_ROUND = 16 # = game_end_at
# matches = Matches.from_profile(mode)
matches = Matches('wos-data-2022', network_type=network_type)
matches = Matches('wos-data-2022-1', network_type=network_type)
times = np.zeros(MAX_ROUND)
cs = np.zeros(MAX_ROUND)
crs = []

View File

@ -4,9 +4,10 @@ from island.match import Match
result = {}
MAX_ROUND = 30
# = game_end_at + 1
MAX_ROUND = 17
for f in Path('wos-data-2022').iterdir():
for f in Path('wos-data-2022-1').iterdir():
p = Path(f)
if p.suffix == '.json':
name = p.stem

29
collision_detection.py Normal file
View File

@ -0,0 +1,29 @@
from island.match import Match
from island.matches import Matches
import json
matches = Matches('wos-data-2022-1')
crs = []
for m in matches.data:
game_end_at = int(m.query('game', 'created').first()['info']['game_end_at'])
games = [{} for _ in range(game_end_at)]
for round in range(1, game_end_at+1):
rows = m.query('action', 'done').where(lambda x: x['rno'] == round).raw_data
for row in rows:
players = [f"{row['a']}-{row['b']}", f"{row['b']}-{row['a']}"]
log_id = -1
for p in players:
if p in games[round-1]:
log_id = games[round-1][p]
if log_id != -1:
print("Collision detected: match=%s, row=%s, collision_log_id=%d" %(m.name, json.dumps(row), log_id))
print("History of this two players:")
logs = m.query('action', 'done').where(lambda x: f"{x['a']}-{x['b']}" in players).raw_data + \
m.query('action', 'request').where(lambda x: f"{x['from']}-{x['to']}" in players).raw_data + \
m.query('action', 'approve').where(lambda x: f"{x['from']}-{x['to']}" in players).raw_data
for log in sorted(logs, key=lambda a: a['log_id']):
print(json.dumps(log))
else:
for p in players:
games[round-1][p] = row['log_id']

View File

@ -34,8 +34,8 @@ class Eid:
with open('outputs/neighborhood_new.json', 'r') as f:
self.neighbors = json.load(f)
self.seasons = [
dict(season=Matches('wos-data-2022', network_type='BA'), name='NEW_BA'),
dict(season=Matches('wos-data-2022', network_type='WS'), name='NEW_WS')
dict(season=Matches('wos-data-2022-1', network_type='BA'), name='NEW_BA'),
dict(season=Matches('wos-data-2022-1', network_type='WS'), name='NEW_WS')
]
# self.seasonSurvive = Matches.from_profile('SURVIVE')
# self.seasonClassic = Matches.from_profile('CLASSIC')

View File

@ -19,7 +19,7 @@ nowak_survive = [0.50017833, 0.26068193, 0.88939394, 0.9595738, 0.99796403, 0.99
santos_survive = [0.50071587, 0.27929701, 0.9098483, 0.938, 0.99437628, 0.99861352, 0.99877322, 1, 1, 1, 1, 1, 1, None, None]
santos_classic = [0.49821874, 0.2757036, 0.26718917, 0.26270039, 0.25895974, 0.2562166, 0.25439971, 0.25290346, 0.25187032, 0.25097969, 0.25037406, 0.24983969, 0.24919843, 0.24884218, 0.24862843]
MAX_ROUND = 28
MAX_ROUND = 16
def p1(x, coopr, crawx, crawy, postfix, show=True):
fig = plt.figure(figsize=(5, 2))
@ -39,7 +39,7 @@ def p1(x, coopr, crawx, crawy, postfix, show=True):
ax.tick_params(labelsize=10)
ax.tick_params(direction='in')
ax.set_xlim(0, MAX_ROUND+1)
ax.set_xticks([1, 5, 10, 15, 20, 25, 30])
ax.set_xticks([1, 5, 10, 15])
# ax.set_xticklabels([''])
ax.set_xlabel("Rounds", size=11)
ax.set_ylabel(r"f$_{\rm c}$", size=11, fontstyle='normal')
@ -76,6 +76,7 @@ if __name__ == '__main__':
elif argv[1] == 'nb':
mode = 'NEW'
network_type = 'BA'
MAX_ROUND = 14
else:
mode = 'NEW'
network_type = 'WS'

View File

@ -3,7 +3,7 @@ from island.matches import Matches
# matches = Matches.from_profile_expr(lambda r:True)
matches = Matches('wos-data-2022')
matches = Matches('wos-data-2022-1')
neighbors = {}

View File

@ -1 +1 @@
[[0.7837837837837838, 0.6785714285714286, 0.76, 0.7727272727272727, 0.7843137254901961, 0.7363636363636363, 0.7653061224489796, 0.7608695652173914, 0.7325581395348837, 0.6794871794871795, 0.7307692307692307], [0.8166666666666667, 0.73, 0.7941176470588235, 0.8292682926829268, 0.75, 0.7159090909090909, 0.7674418604651163, 0.7631578947368421, 0.7, 0.7051282051282052, 0.6219512195121951, 0.6309523809523809, 0.6351351351351351, 0.5697674418604651, 0.48484848484848486, 0.625, 0.6447368421052632, 0.6621621621621622, 0.6125, 0.578125, 0.5714285714285714, 0.5285714285714286, 0.5925925925925926, 0.5833333333333334, 0.5833333333333334, 0.5645161290322581, 0.6212121212121212, 0.65625], [0.9433962264150944, 0.8974358974358975, 0.8461538461538461, 0.8103448275862069, 0.8260869565217391, 0.8636363636363636, 0.8333333333333334, 0.8529411764705882, 0.9047619047619048, 0.8809523809523809, 0.8235294117647058, 0.7777777777777778, 0.75, 0.825, 0.8095238095238095, 0.6666666666666666, 0.7105263157894737, 0.78125], [1.0, 0.9210526315789473, 0.8333333333333334, 0.9166666666666666, 0.875, 0.9166666666666666, 0.8636363636363636, 0.8846153846153846, 0.8571428571428571, 0.8333333333333334, 0.7727272727272727, 0.8181818181818182, 0.8846153846153846, 0.7692307692307693, 0.8333333333333334, 0.8125, 0.78125, 0.8333333333333334, 0.8333333333333334, 0.8333333333333334, 0.6666666666666666, 0.8333333333333334, 0.7083333333333334, 0.75, 0.7, 0.8125]]
[[0.9329268292682927, 0.926829268292683, 0.845679012345679, 0.8506493506493507, 0.8287671232876712, 0.8375, 0.7608695652173914, 0.8333333333333334, 0.7954545454545454, 0.7214285714285714, 0.7578125, 0.7622950819672131, 0.6384615384615384, 0.5819672131147541], [0.9038461538461539, 0.831081081081081, 0.8066666666666666, 0.7246376811594203, 0.7578125, 0.7236842105263158, 0.7364864864864865, 0.7121212121212122, 0.7071428571428572, 0.717948717948718, 0.6890243902439024, 0.75, 0.753968253968254]]

View File

@ -1 +1 @@
[[0.984375, 0.9705882352941176, 0.96875, 0.9230769230769231, 0.90625, 0.9333333333333333, 0.9, 0.75, 0.9117647058823529, 0.9117647058823529, 0.90625, 0.96875, 0.8666666666666667, 0.8888888888888888, 0.8888888888888888, 0.8125, 0.7666666666666667, 0.8214285714285714, 0.7142857142857143, 0.7058823529411765, 0.5769230769230769, 0.6666666666666666, 0.5625, 0.5769230769230769, 0.5769230769230769, 0.59375, 0.7142857142857143, 0.47058823529411764], [0.8809523809523809, 0.8055555555555556, 0.8333333333333334, 0.85, 0.8823529411764706, 0.8823529411764706, 0.8125, 0.8333333333333334, 0.8076923076923077, 0.9, 0.8846153846153846, 0.7916666666666666, 0.75, 0.75, 0.85, 0.8076923076923077, 0.75, 0.6923076923076923, 0.8, 0.7307692307692307, 0.75, 0.5416666666666666, 0.5, 0.5909090909090909], [0.8, 0.625, 0.7777777777777778, 0.8888888888888888, 0.7857142857142857, 0.8888888888888888, 0.875, 0.9090909090909091, 0.9, 0.8888888888888888], [0.7222222222222222, 0.7777777777777778, 0.8333333333333334, 0.8333333333333334, 0.8571428571428571, 0.9285714285714286, 0.8571428571428571, 0.8571428571428571, 0.8571428571428571, 0.8], [0.9, 0.7, 0.75, 0.9, 0.8571428571428571, 0.75, 0.8571428571428571, 0.7857142857142857, 0.6875, 0.5, 0.5, 0.6666666666666666, 0.8333333333333334, 0.8, 0.75, 0.9, 0.6666666666666666, 0.75, 0.75, 0.75, 0.8, 0.75, 0.8333333333333334, 0.6666666666666666, 0.75]]
[[0.9274809160305344, 0.8943089430894309, 0.8925619834710744, 0.8878504672897196, 0.8773584905660378, 0.8387096774193549, 0.8333333333333334, 0.8411764705882353, 0.7658227848101266, 0.8035714285714286, 0.788235294117647, 0.7352941176470589, 0.689873417721519, 0.6818181818181818], [0.91015625, 0.9217391304347826, 0.9107142857142857, 0.9030612244897959, 0.8939393939393939, 0.907608695652174, 0.8764705882352941, 0.8166666666666667, 0.788235294117647, 0.7528089887640449, 0.65, 0.5602409638554217, 0.49375, 0.30246913580246915, 0.29411764705882354, 0.23026315789473684]]

View File

@ -1 +1 @@
0.8757062146892656,0.774390243902439,0.795774647887324,0.8102189781021898,0.7884615384615384,0.7669172932330827,0.7862903225806451,0.7894736842105263,0.7669491525423728,0.7432432432432432,0.7083333333333334,0.6971830985915493,0.7142857142857143,0.6710526315789473,0.6515151515151515,0.6753246753246753,0.6917808219178082,0.7279411764705882,0.6634615384615384,0.6477272727272727,0.5957446808510638,0.5909090909090909,0.6282051282051282,0.625,0.6086956521739131,0.6153846153846154,0.6212121212121212,0.65625,0.0,0.0
0.91875,0.8814102564102564,0.8269230769230769,0.791095890410959,0.7956204379562044,0.782051282051282,0.7482517482517482,0.7753623188405797,0.75,0.7195945945945946,0.7191780821917808,0.7560975609756098,0.6953125,0.5819672131147541,0.0,0.0

1 0.8757062146892656 0.91875 0.774390243902439 0.8814102564102564 0.795774647887324 0.8269230769230769 0.8102189781021898 0.791095890410959 0.7884615384615384 0.7956204379562044 0.7669172932330827 0.782051282051282 0.7862903225806451 0.7482517482517482 0.7894736842105263 0.7753623188405797 0.7669491525423728 0.75 0.7432432432432432 0.7195945945945946 0.7083333333333334 0.7191780821917808 0.6971830985915493 0.7560975609756098 0.7142857142857143 0.6953125 0.6710526315789473 0.5819672131147541 0.6515151515151515 0.0 0.6753246753246753 0.0 0.6917808219178082 0.7279411764705882 0.6634615384615384 0.6477272727272727 0.5957446808510638 0.5909090909090909 0.6282051282051282 0.625 0.6086956521739131 0.6153846153846154 0.6212121212121212 0.65625

View File

@ -1 +1 @@
0.8902439024390244,0.8032786885245902,0.853448275862069,0.8773584905660378,0.8703703703703703,0.8888888888888888,0.8596491228070176,0.8240740740740741,0.8454545454545455,0.8529411764705882,0.8285714285714286,0.8529411764705882,0.8181818181818182,0.8333333333333334,0.859375,0.8235294117647058,0.7413793103448276,0.7575757575757576,0.75,0.7222222222222222,0.6833333333333333,0.6363636363636364,0.5882352941176471,0.6,0.631578947368421,0.59375,0.7142857142857143,0.47058823529411764,0.0,0.0
0.918918918918919,0.907563025210084,0.9012875536480687,0.8951219512195122,0.8853658536585366,0.8729729729729729,0.8532608695652174,0.8285714285714286,0.7774390243902439,0.7774566473988439,0.7212121212121212,0.6488095238095238,0.5911949685534591,0.4873417721518987,0.29411764705882354,0.23026315789473684

1 0.8902439024390244 0.918918918918919 0.8032786885245902 0.907563025210084 0.853448275862069 0.9012875536480687 0.8773584905660378 0.8951219512195122 0.8703703703703703 0.8853658536585366 0.8888888888888888 0.8729729729729729 0.8596491228070176 0.8532608695652174 0.8240740740740741 0.8285714285714286 0.8454545454545455 0.7774390243902439 0.8529411764705882 0.7774566473988439 0.7212121212121212 0.8529411764705882 0.6488095238095238 0.8181818181818182 0.5911949685534591 0.8333333333333334 0.4873417721518987 0.859375 0.29411764705882354 0.8235294117647058 0.23026315789473684 0.7413793103448276 0.7575757575757576 0.75 0.7222222222222222 0.6833333333333333 0.6363636363636364 0.5882352941176471 0.6 0.631578947368421 0.59375 0.7142857142857143 0.47058823529411764 0.0 0.0

View File

@ -1 +1 @@
2602.671328671329,2738.048951048951,2240.4055944055945,2148.902097902098,2126.125874125874,2413.006993006993,2532.8811188811187,2209.006993006993,2499.230769230769,2418.3636363636365,2289.569892473118,2191.989247311828,2254.559139784946,2381.8387096774195,2083.7096774193546,2352.8172043010754,2691.8064516129034,2543.84126984127,2766.031746031746,2317.777777777778,2422.15873015873,2524.222222222222,2464.095238095238,2659.6666666666665,2575.84126984127,3127.7954545454545,2913.7727272727275,0.0
1221.2386363636363,1163.7443181818182,1186.4147727272727,1163.4943181818182,1170.2670454545455,1144.4943181818182,1050.6761363636363,1182.8125,1070.0568181818182,1123.6931818181818,1240.5738636363637,1161.4488636363637,1203.4941176470588,0.0,0.0,0.0

1 2602.671328671329 1221.2386363636363 2738.048951048951 1163.7443181818182 2240.4055944055945 1186.4147727272727 2148.902097902098 1163.4943181818182 2126.125874125874 1170.2670454545455 2413.006993006993 1144.4943181818182 2532.8811188811187 1050.6761363636363 2209.006993006993 1182.8125 2499.230769230769 1070.0568181818182 2418.3636363636365 1123.6931818181818 2289.569892473118 1240.5738636363637 2191.989247311828 1161.4488636363637 2254.559139784946 1203.4941176470588 2381.8387096774195 0.0 2083.7096774193546 0.0 2352.8172043010754 0.0 2691.8064516129034 2543.84126984127 2766.031746031746 2317.777777777778 2422.15873015873 2524.222222222222 2464.095238095238 2659.6666666666665 2575.84126984127 3127.7954545454545 2913.7727272727275

View File

@ -1 +1 @@
4158.735632183908,4271.0344827586205,4125.241379310345,3635.862068965517,3409.655172413793,3261.1494252873563,3451.0344827586205,3672.183908045977,3746.896551724138,3076.9811320754716,3836.2264150943397,3801.8867924528304,3747.5471698113206,3430.188679245283,3855.8490566037735,3593.396226415094,3608.301886792453,3701.8867924528304,3258.1132075471696,3515.4716981132074,3428.6792452830186,3148.6792452830186,3881.8867924528304,3901.935483870968,3000.0,3730.5,3583.6363636363635,0.0
1435.4651162790697,1425.843023255814,1429.9883720930231,1429.0697674418604,1435.5755813953488,1427.6744186046512,1431.9011627906978,1434.0755813953488,1433.7093023255813,1433.7209302325582,1432.9941860465117,1438.953488372093,1427.6744186046512,1436.551724137931,1431.7241379310344,0.0

1 4158.735632183908 1435.4651162790697 4271.0344827586205 1425.843023255814 4125.241379310345 1429.9883720930231 3635.862068965517 1429.0697674418604 3409.655172413793 1435.5755813953488 3261.1494252873563 1427.6744186046512 3451.0344827586205 1431.9011627906978 3672.183908045977 1434.0755813953488 3746.896551724138 1433.7093023255813 3076.9811320754716 1433.7209302325582 3836.2264150943397 1432.9941860465117 3801.8867924528304 1438.953488372093 3747.5471698113206 1427.6744186046512 3430.188679245283 1436.551724137931 3855.8490566037735 1431.7241379310344 3593.396226415094 0.0 3608.301886792453 3701.8867924528304 3258.1132075471696 3515.4716981132074 3428.6792452830186 3148.6792452830186 3881.8867924528304 3901.935483870968 3000.0 3730.5 3583.6363636363635

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,27 +5,27 @@ from matplotlib import markers
blue = '#0984e3'
red = '#d63031'
MAX_ROUND = 28
MAX_ROUND = 16 # = game_end_at + 1
x = np.arange(1, MAX_ROUND+1)
tc = np.loadtxt("outputs/EID_NEW_BA.csv", delimiter=',')
ts = np.loadtxt("outputs/EID_NEW_WS.csv", delimiter=',')
fig = plt.figure(figsize=(6,4.5))
ax = fig.gca()
ax.plot(x[:-1], tc[:-1], 'o--', color='limegreen', linewidth=2, label=r"BA")
ax.plot(x[:-3], tc[:-3], 'o--', color='limegreen', linewidth=2, label=r"BA")
ax.plot(x[:-1], ts[:-1], 'o-', color='darkorange', linewidth=2, label=r"WS")
# ax.set_ylim(-1500, 500)
# ax.set_yticks(sp.linspace(-1500, 500, 6))
ax.tick_params(labelsize=14)
ax.set_xlim(1, MAX_ROUND)
ax.set_xticks(sp.linspace(1,MAX_ROUND,8, dtype=int))
ax.set_xticks(sp.linspace(1,MAX_ROUND-1,8, dtype=int))
ax.set_xlabel("Rounds", size=22)
ax.set_ylabel(r"$\theta$", family='sans-serif', size=22)
# ax.tick_params(axis='y', labelcolor=red)
plt.legend(numpoints=2, fontsize=14)
plt.tight_layout()
# plt.show()
plt.show()
# plt.savefig("graph/theta_plot.eps")
plt.savefig("graph/theta_plot_new.pdf")
# plt.savefig("graph/theta_plot_new.pdf")

View File

@ -22,7 +22,7 @@ import numpy as np
from island.match import Match
from island.matches import Matches
MAX_ROUND = 28
MAX_ROUND = 16 # game_end_at
class theta_r_i:
def __init__(self):
@ -34,8 +34,8 @@ class theta_r_i:
with open('outputs/neighborhood_new.json', 'r') as f:
self.neighbors = json.load(f)
self.seasons = [
dict(season=Matches('wos-data-2022', network_type='BA'), name='NEW_BA'),
dict(season=Matches('wos-data-2022', network_type='WS'), name='NEW_WS')
dict(season=Matches('wos-data-2022-1', network_type='BA'), name='NEW_BA'),
dict(season=Matches('wos-data-2022-1', network_type='WS'), name='NEW_WS')
]
# self.seasonSurvive = Matches.from_profile('SURVIVE')
# self.seasonClassic = Matches.from_profile('CLASSIC')
@ -82,7 +82,7 @@ class theta_r_i:
ans = {}
sigma = 0.0
for p in self.survivals[m.name][str(r)]:
e = max(0, min(144000000, self.getNeighborTR(m, r, p, self.getNeighborhood(m, r, p))))
e = max(0, min(1440, self.getNeighborTR(m, r, p, self.getNeighborhood(m, r, p))))
ans[p] = e
sigma += e
return (sigma, ans)