-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathreselection_visualization.py
155 lines (98 loc) · 4.3 KB
/
reselection_visualization.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import pickle
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from functions import*
def DataFormation(data):
data = pd.DataFrame(data, columns = ['SW_1', 'SW_2'])
SW_1, SW_2 = data['SW_1'], data['SW_2']
SW_1 = DataExtraction(SW_1)
SW_2 = DataExtraction(SW_2)
return SW_1, SW_2
#platform capacity
capacity_unit = 100
capacity_range = 15
data_path = 'data/reselection/latest_reselection_result.p'
data = pickle.load(open(data_path, 'rb'))
#[mere_SW, expected_SW, realized_SW, pre_budget, post_budget, payment, fee, changed_payment, changed_fee, cost, running_time]
SW_1, SW_2 = DataFormation(data)
SW_1 = DataTrimming(SW_1)
SW_2 = DataTrimming(SW_2)
#capacity range
capacity = capacity_unit*np.arange(1, capacity_range + 0.1)
reselection_distribution = np.load('data/reselection/reselection_distribution.npy')
num_requester = reselection_distribution[0].mean(axis = 0)
num_provider = reselection_distribution[1].mean(axis = 0)
print(num_requester)
print(num_provider)
#[mere_SW, expected_SW, realized_SW, pre_budget, post_budget, payment, fee, changed_payment, changed_fee, cost, running_time]
#mere SW
plt.plot(capacity, SW_1[:, 0], 'ko-', markersize = 13, label = 'B.M: NSW')
plt.plot(capacity, SW_2[:, 0], 'k^-', markersize = 13, label = 'ESWM: NSW')
#added
plt.plot(capacity, SW_1[:, 1], 'ro--', markersize = 13, label = 'B.M : ESW')
plt.plot(capacity, SW_2[:, 1], 'g^--', markersize = 13, label = 'ESWM: ESW')
#added
plt.xlim(50, 1050)
plt.xlabel('Platform Capacity', fontsize = 25)
plt.ylabel(r'Social Welfare (x$10^4$)', fontsize = 25)
plt.xticks(fontsize = 25)
plt.yticks(fontsize = 25)
plt.yticks(np.arange(0, 51000, 10000), np.arange(0, 5.1, 1), fontsize = 25)
plt.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol = 2, fontsize = 18, fancybox = True, framealpha = 0.5)
plt.tight_layout()
plt.show()
#Platform utility: before submission
plt.plot(capacity, SW_1[:, 3], 'r--o', markersize = 13, label = 'B.M:t$\leq t_{sub}$')
plt.plot(capacity, SW_2[:, 3], 'g--^', markersize = 13, label = 'ESWM:t$\leq t_{sub}$')
#added
plt.plot(capacity, SW_1[:, 4], 'r-o', markersize = 13, label = 'B.M:t$>t_{sub}$')
plt.plot(capacity, SW_2[:, 4], 'g-^', markersize = 13, label = 'ESWM:t$> t_{sub}$')
#added
plt.xlim(50, 1050)
plt.xlabel('Platform Capacity', fontsize = 25)
plt.ylabel(r'Platform Utility (x$10^3$)', fontsize = 25)
plt.xticks(fontsize = 25)
plt.yticks(fontsize = 25)
plt.yticks(np.arange(0, 17000, 4000), np.arange(0, 17, 4),fontsize = 25)
plt.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol = 2, fontsize = 17, fancybox = True, framealpha = 0.5)
plt.tight_layout()
plt.show()
#Q1: In the previous simulation, I divided the summation of requester and provider utility
#with the number of requesters and providers. However, should the avg utility be only for selected winners?
#avg requester utility
plt.plot(capacity, (SW_1[:, 2] + SW_1[:, -2] - SW_1[:, -3]) / num_requester[0], 'ro--', markersize = 13, label = 'B.M')
plt.plot(capacity, (SW_2[:, 2] + SW_2[:, -2] - SW_2[:, -3]) / num_requester[1], 'g^--', markersize = 13, label = 'ESWM')
plt.xlim(50, 1050)
plt.xlabel('Platform Capacity', fontsize = 25)
plt.ylabel('Average Requester Utility', fontsize = 25)
plt.xticks(fontsize = 25)
#plt.yticks(fontsize = 25)
plt.yticks(np.arange(0, 26, 5), fontsize = 25)
plt.legend(loc = 'best', fontsize = 25)
plt.tight_layout()
plt.show()
#avg provider utility
plt.plot(capacity, (SW_1[:, -4] - SW_1[:, -2]) / num_provider[0], 'ro--', markersize = 13, label = 'B.M')
plt.plot(capacity, (SW_2[:, -4] - SW_2[:, -2]) / num_provider[1], 'g^--', markersize = 13, label = 'ESWM')
plt.xlim(50, 1050)
plt.xlabel('Platform Capacity', fontsize = 25)
plt.ylabel('Average provider Utility', fontsize = 25)
plt.xticks(fontsize = 25)
plt.yticks(np.arange(0, 2.1, 0.5), fontsize = 25)
plt.legend(loc = 'best', fontsize = 25)
plt.tight_layout()
plt.show()
#running time
plt.plot(capacity, SW_1[:, -1], 'ro--', label = '[8]')
plt.plot(capacity, SW_2[:, -1], 'g^--', label = 'ESWM')
plt.xlim(50, 1050)
plt.xlabel('Platform Capacity', fontsize = 25)
plt.ylabel('Running Time(s)', fontsize = 25)
plt.xticks(fontsize = 25)
plt.yticks(fontsize = 25)
#plt.yticks(np.arange(0, 61000, 10000), np.arange(0, 61, 10),fontsize = 25)
#plt.legend(loc = 'best', fontsize = 25)
plt.tight_layout()
plt.show()
#end