From 1f5cde57617df69e10d712084dc3685fd2be50ae Mon Sep 17 00:00:00 2001 From: wjsjwr Date: Sat, 1 Sep 2018 16:32:24 +0800 Subject: [PATCH] sync --- island/match.py | 5 ++++- tau_p_co.py => tau_f_co.py | 13 ++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) rename tau_p_co.py => tau_f_co.py (94%) diff --git a/island/match.py b/island/match.py index d04bee2..fe529e7 100644 --- a/island/match.py +++ b/island/match.py @@ -99,10 +99,13 @@ class Match: def get_tr(self, i, target, nb, sv): """ - # 计算tau_p的方式是统计周围邻居剩余的tr + # 计算tau_f的方式是统计周围邻居剩余的tr # 本函数计算第i轮,所有有消耗tr的player,最后剩余的tr # 由于是计算剩余tr,所以不能计算和target之间的交互 # nb是target的邻居 + # 2018/08/31 更新:即便是已经交互过的邻居,他的剩余时间资源依旧应该计算入tau_f中,使得公式完整。 + # 2018/09/01 更新:不应该算在tau_P中,尝试单独列成一项,因为优化目标不同。 + # 2018/09.01 更新:将tau_p更改为tau_f """ trs = {} req = self.query('action', 'request').where(lambda x: x['rno'] == i+1) diff --git a/tau_p_co.py b/tau_f_co.py similarity index 94% rename from tau_p_co.py rename to tau_f_co.py index 923a2f9..78e12d8 100644 --- a/tau_p_co.py +++ b/tau_f_co.py @@ -15,18 +15,18 @@ def error(f,x,y): return sp.sum((f(x)-y)**2) def p1(x, coopr, tau, postfix, show=True): - fig = plt.figure(figsize=(5, 4)) + fig = plt.figure(figsize=(2.5, 2)) ax = fig.gca() ax.plot(x, coopr, color=blue, linewidth=2, label="$f_c$") ax.set_ylim(0, 1) ax2 = ax.twinx() - ax2.plot(x, tau, color=red, linewidth=2, label=r"$\tau_p$") + ax2.plot(x, tau, color=red, linewidth=2, label=r"$\tau_f$") ax2.set_ylim(0, 1440) ax.set_xlim(1, 15) ax.set_xlabel("Rounds") ax.set_ylabel(r"$f_c$", color=blue) ax.tick_params(axis='y', labelcolor=blue) - ax2.set_ylabel(r"$\tau_{p}$", family='sans-serif', color=red) + ax2.set_ylabel(r"$\tau_{f}$", family='sans-serif', color=red) ax2.tick_params(axis='y', labelcolor=red) fig.legend() @@ -49,6 +49,8 @@ def p2(tau, coopr, limited, postfix, show=True): tau_r.append(tau[i]) coopr_r.append(coopr[i]) + print(tau, coopr) + print(tau2, coopr2) # p2散点图 fig = plt.figure(figsize=(4, 3)) ax = fig.gca() @@ -154,7 +156,7 @@ if __name__ == '__main__': else: trs = matches.data[j].get_tr(i, k, neighbors[matches.names[j]][k], survivals[matches.names[j]][str(i)]) for l in neighbors[matches.names[j]][k]: - if l in trs: + if l in trs and trs[l] > 0: t += trs[l] tp.append(t if t < 1440 else 1440) mwTau["%s-%d"%(j,i)] = tp[-1] @@ -170,8 +172,9 @@ if __name__ == '__main__': # p1折线图 # p1(x, coopr, tau, 'classic', False) + p1(x, coopr, tau, 'survive', True) - p2(tau[:12], coopr[:12], 720, 'survive', True) + # p2(tau[:12], coopr[:12], 720, 'survive', True) # p2(tau, coopr, 1440, 'classic', False)