research/uefa/cycle24/draw24/calendar/directed_vs_undirected.py
2024-01-31 17:12:11 +01:00

745 lines
14 KiB
Python
Executable File

# %%
# libraries
import numpy as np
import matplotlib.pyplot as plt
# width of the bars
# barWidth = 0.3
# # Choose the height of the blue bars
# undirected = [
# # 5390.36,
# 2.56,
# 8.42,
# 39.5,
# ]
# # Choose the height of the cyan bars
# directed = [
# # 5440.1,
# 2.8,
# 7.48,
# 39.76,
# ]
# # The x position of bars
# r1 = np.arange(len(undirected))
# r2 = [x + barWidth for x in r1]
# # Create blue bars
# plt.bar(r2, undirected, width = barWidth, color = 'blue', edgecolor = 'black', capsize=7, label='undirected')
# # Create cyan bars
# plt.bar(r1, directed, width = barWidth, color = 'cyan', edgecolor = 'black', capsize=7, label='directed')
# # general layout
# plt.xticks([r + barWidth/2 for r in range(len(undirected))], ['Pairings', 'HAWishes', 'EncWishes'])
# plt.ylabel('# Violations')
# plt.legend()
# plt.title("Directed vs Undirected")
# # Show graphic
# plt.show()
# # %%
# # libraries
# import numpy as np
# import matplotlib.pyplot as plt
# # width of the bars
# barWidth = 0.3
# # Choose the height of the blue bars
# undirected = [
# 18.9313149871523
# ]
# # Choose the height of the cyan bars
# directed = [
# 21.8851814402876
# ]
# # The x position of bars
# r1 = np.arange(len(undirected))
# r2 = [x + barWidth for x in r1]
# # Create blue bars
# plt.bar(r1, undirected, width = barWidth, color = 'blue', edgecolor = 'black', capsize=7, label='undirected')
# # Create cyan bars
# plt.bar(r2, directed, width = barWidth, color = 'cyan', edgecolor = 'black', capsize=7, label='directed')
# # general layout
# plt.xticks([r + barWidth/2 for r in range(len(undirected))], ['Improvement'])
# plt.ylabel('%')
# plt.legend()
# plt.title("Directed vs Undirected")
# # Show graphic
# plt.show()
# # %%
# # libraries
# import numpy as np
# import matplotlib.pyplot as plt
# # width of the bars
# barWidth = 1
# # Choose the height of the blue bars
# ucl = [
# 0,
# 0.08,
# (0.08+0.04)/2,
# (2.36+2.64)/2,
# ]
# # Choose the height of the cyan bars
# relaxed = [
# 0,
# 0,
# (0.24+0.12)/2,
# (2.36+2.72)/2,
# ]
# diff = [-round(ucl[i] - relaxed[i],2) for i in range(len(ucl))]
# bars4 = ucl + relaxed + diff
# # The x position of bars
# # r1 = np.arange(len(ucl))
# # r2 = [x + barWidth for x in r1]
# # r3 = [x + 2*barWidth for x in r1]
# r1 = [0, 4, 8, 12]
# r2 = [1, 5, 9, 13]
# r3 = [2, 6, 10, 14]
# r4 = r1 + r2 + r3
# # Create labels
# label = bars4
# # Text on the top of each bar
# for i in range(len(r4)):
# plt.text(x = r4[i]-0.3 , y = bars4[i]+0.1, s = label[i], size = 6)
# # Create blue bars
# plt.bar(r1, ucl, width = barWidth, color = 'blue', edgecolor = 'black', capsize=7, label='ucl')
# # Create cyan bars
# plt.bar(r2, relaxed, width = barWidth, color = 'cyan', edgecolor = 'black', capsize=7, label='relaxed')
# # Create cyan bars
# plt.bar(r3, diff, width = barWidth, color = 'red', edgecolor = 'black', capsize=7, label='diff')
# # general layout
# plt.xticks([1 + r*4 for r in range(len(ucl))], ['Hard','A','B','C'])
# plt.ylabel('%')
# plt.legend()
# plt.title("Pairings")
# # Show graphic
# plt.show()
# # %%
# # libraries
# import numpy as np
# import matplotlib.pyplot as plt
# # width of the bars
# barWidth = 1
# # Choose the height of the blue bars
# ucl = [
# round((0 + 0)/2,2),
# round((1.28 + 1.44)/2,2),
# round((6.28 + 7.24)/2,2),
# round((0 + 0)/2,2),
# ]
# # Choose the height of the cyan bars
# relaxed = [
# round((0+0)/2,2),
# round((1.44+1.36)/2,2),
# round((5.96+6.8)/2,2),
# round((0+0)/2,2),
# ]
# diff = [-round(ucl[i] - relaxed[i],2) for i in range(len(ucl))]
# bars4 = ucl + relaxed + diff
# # The x position of bars
# # r1 = np.arange(len(ucl))
# # r2 = [x + barWidth for x in r1]
# # r3 = [x + 2*barWidth for x in r1]
# r1 = [0, 4, 8, 12]
# r2 = [1, 5, 9, 13]
# r3 = [2, 6, 10, 14]
# r4 = r1 + r2 + r3
# # Create labels
# label = bars4
# # Text on the top of each bar
# for i in range(len(r4)):
# plt.text(x = r4[i]-0.3 , y = bars4[i]+0.1, s = label[i], size = 6)
# # Create blue bars
# plt.bar(r1, ucl, width = barWidth, color = 'blue', edgecolor = 'black', capsize=7, label='ucl')
# # Create cyan bars
# plt.bar(r2, relaxed, width = barWidth, color = 'cyan', edgecolor = 'black', capsize=7, label='relaxed')
# # Create cyan bars
# plt.bar(r3, diff, width = barWidth, color = 'red', edgecolor = 'black', capsize=7, label='diff')
# # general layout
# plt.xticks([1 + r*4 for r in range(len(ucl))], ['Hard','A','B','C'])
# plt.ylabel('%')
# plt.legend()
# plt.title("HAWishes")
# # Show graphic
# plt.show()
# # %%
# # libraries
# import numpy as np
# import matplotlib.pyplot as plt
# # width of the bars
# barWidth = 1
# # Choose the height of the blue bars
# ucl = [
# round((0+0)/2,2),
# round((2.56+2.72)/2,2),
# round((27.64+27.84)/2,2),
# round((11.92+12.24)/2,2),
# ]
# # Choose the height of the cyan bars
# relaxed = [
# round((0+0)/2,2),
# round((0.96+0.76)/2,2),
# round((26.6+26.52)/2,2),
# round((9.32+9.44)/2,2),
# ]
# diff = [-round(ucl[i] - relaxed[i],2) for i in range(len(ucl))]
# bars4 = ucl + relaxed + diff
# # The x position of bars
# # r1 = np.arange(len(ucl))
# # r2 = [x + barWidth for x in r1]
# # r3 = [x + 2*barWidth for x in r1]
# r1 = [0, 4, 8, 12]
# r2 = [1, 5, 9, 13]
# r3 = [2, 6, 10, 14]
# r4 = r1 + r2 + r3
# # Create labels
# label = bars4
# # Text on the top of each bar
# for i in range(len(r4)):
# plt.text(x = r4[i]-0.3 , y = bars4[i]+0.1, s = label[i], size = 6)
# # Create blue bars
# plt.bar(r1, ucl, width = barWidth, color = 'blue', edgecolor = 'black', capsize=7, label='ucl')
# # Create cyan bars
# plt.bar(r2, relaxed, width = barWidth, color = 'cyan', edgecolor = 'black', capsize=7, label='relaxed')
# # Create cyan bars
# plt.bar(r3, diff, width = barWidth, color = 'red', edgecolor = 'black', capsize=7, label='diff')
# # general layout
# plt.xticks([1 + r*4 for r in range(len(ucl))], ['Hard','A','B','C'])
# plt.ylabel('%')
# plt.legend()
# plt.title("EncWishes")
# # Show graphic
# plt.show()
# # %%
# # library
# import matplotlib.pyplot as plt
# # create random data
# values=[
# round((204+208)/2,2),
# round((516+560)/2,2),
# round((4756+4755)/2,2),
# ]
# names=f'Pairings {round(values[0]/sum(values)*100)}%', f'HAWishes {round(values[1]/sum(values)*100)}%', f'Encounters {round(values[2]/sum(values)*100)}%',
# # Create a pieplot
# plt.pie(values)
# # Label distance: gives the space between labels and the center of the pie
# plt.pie(values, labels=names, labeldistance=1.15);
# plt.show();
# # %%
# # %%
# # libraries
# import numpy as np
# import matplotlib.pyplot as plt
# # width of the bars
# barWidth = 0.3
# # Choose the height of the blue bars
# undirected = [
# 18.9313149871523
# ]
# # Choose the height of the cyan bars
# directed = [
# 21.8851814402876
# ]
# # The x position of bars
# r1 = np.arange(len(undirected))
# r2 = [x + barWidth for x in r1]
# # Create blue bars
# plt.bar(r1, undirected, width = barWidth, color = 'blue', edgecolor = 'black', capsize=7, label='undirected')
# # Create cyan bars
# plt.bar(r2, directed, width = barWidth, color = 'cyan', edgecolor = 'black', capsize=7, label='directed')
# # general layout
# plt.xticks([r + barWidth/2 for r in range(len(undirected))], ['Improvement'])
# plt.ylabel('%')
# plt.ylim(0, 40)
# plt.legend()
# # Show graphic
# plt.show()
# # %%
# # %%
# # libraries
# import numpy as np
# import matplotlib.pyplot as plt
# # width of the bars
# barWidth = 0.3
# # Choose the height of the blue bars
# undirected = [
# 6008.88,
# 6052.68,
# ]
# # Choose the height of the cyan bars
# directed = [
# 4871.32,
# 4728.04,
# ]
# # The x position of bars
# r1 = np.arange(len(undirected))
# r2 = [x + barWidth for x in r1]
# # Create blue bars
# plt.bar(r1, undirected, width = barWidth, color = 'salmon', edgecolor = 'black', capsize=7, label='classic')
# # Create cyan bars
# plt.bar(r2, directed, width = barWidth, color = 'lightgreen', edgecolor = 'black', capsize=7, label='relaxed')
# # general layout
# plt.xticks([r + barWidth/2 for r in range(len(undirected))], ['undirected','directed'])
# plt.ylabel('Objective')
# # plt.ylim(0, 40)
# plt.legend()
# # Show graphic
# plt.show()
# # %%
# %%
# libraries
import numpy as np
import matplotlib.pyplot as plt
# width of the bars
barWidth = 15
columns = [
# 'Overall Quality',
# 'Stadium/city clash',
'Stadium/City Clash',
'TV-pairing NA5 1st',
'TV-pairing other 1st',
'TV-pairing NA5 2nd (HA)',
'SKO (HA)',
'Weekdays (HA)',
'Balance (ENC)',
'Quality (ENC)',
'Structure',
]
# Choose the height of the blue bars
ucl = [
# 3040.22,
0,
0,
0,
0.4,
0.2,
9.53,
11.49,
3.99,
0,
]
# Choose the height of the cyan bars
relaxed = [
# 2644.3,
0,
0,
0,
0.52,
0.19,
9.9,
9.74,
2.9,
0,
]
print(len(columns),len(ucl),len(relaxed))
diff = [-round(ucl[i] - relaxed[i],2) for i in range(len(ucl))]
bars4 = ucl + relaxed + diff
# The x position of bars
# r1 = np.arange(len(ucl))
# r2 = [x + barWidth for x in r1]
# r3 = [x + 2*barWidth for x in r1]
r1 = [4*i*barWidth for i in range(len(ucl))]
r2 = [4*i*barWidth+1*barWidth for i in range(len(ucl))]
r3 = [4*i*barWidth+2*barWidth for i in range(len(ucl))]
r4 = r1 + r2 + r3
# Create labels
label = bars4
# Text on the top of each bar
for i in range(len(r4)):
plt.text(x = r4[i]-0.3 , y = bars4[i]+0.1, s = label[i], size = 12, rotation=90)
# Create blue bars
plt.bar(r1, ucl, width = barWidth, color = 'blue', edgecolor = 'black', capsize=20, label='classic')
# Create cyan bars
plt.bar(r2, relaxed, width = barWidth, color = 'cyan', edgecolor = 'black', capsize=7, label='3breaks')
# Create cyan bars
plt.bar(r3, diff, width = barWidth, color = 'red', edgecolor = 'black', capsize=7, label='diff')
# general layout
plt.xticks([10+ r*4*barWidth for r in range(len(ucl))], columns, rotation=25, fontsize=12)
plt.ylabel('average # of violations', fontsize=12)
plt.legend()
# plt.ylim((0,3))
plt.title("Comparison based on 100 random draws")
# plt.savefig('classic_vs_3.png', dpi=300)
# Show graphic
plt.show()
# %%
# %%
# libraries
import numpy as np
import matplotlib.pyplot as plt
# width of the bars
barWidth = 15
columns = [
# 'Overall Quality',
# 'Stadium/city clash',
'Stadium/City Clash',
'TV-pairing NA5 1st',
'TV-pairing other 1st',
'TV-pairing NA5 2nd (HA)',
'SKO (HA)',
'Weekdays (HA)',
'Balance (ENC)',
'Quality (ENC)',
'Structure',
]
# Choose the height of the blue bars
ucl = [
# 3040.22,
# 0,
# 0,
# 0,
# 0.4,
# 0,
0,
0,
0,
0.45,
0.19,
9.52,
11.67,
3.76,
0,
]
# Choose the height of the cyan bars
relaxed = [
# 2644.3,
# 0,
# 0,
# 0,
# 0.52,
# 0,
0,
0,
0,
0.6,
0.19,
9.27,
11.3,
3.17,
0,
]
print(len(columns),len(ucl),len(relaxed))
diff = [-round(ucl[i] - relaxed[i],2) for i in range(len(ucl))]
bars4 = ucl + relaxed + diff
# The x position of bars
# r1 = np.arange(len(ucl))
# r2 = [x + barWidth for x in r1]
# r3 = [x + 2*barWidth for x in r1]
r1 = [4*i*barWidth for i in range(len(ucl))]
r2 = [4*i*barWidth+1*barWidth for i in range(len(ucl))]
r3 = [4*i*barWidth+2*barWidth for i in range(len(ucl))]
r4 = r1 + r2 + r3
# Create labels
label = bars4
# Text on the top of each bar
for i in range(len(r4)):
plt.text(x = r4[i]-0.3 , y = bars4[i]+0.1, s = label[i], size = 12, rotation=90)
# Create blue bars
plt.bar(r1, ucl, width = barWidth, color = 'blue', edgecolor = 'black', capsize=7, label='classic')
# Create cyan bars
plt.bar(r2, relaxed, width = barWidth, color = 'cyan', edgecolor = 'black', capsize=7, label='startwbreak')
# Create cyan bars
plt.bar(r3, diff, width = barWidth, color = 'red', edgecolor = 'black', capsize=7, label='diff')
# general layout
plt.xticks([10+ r*4*barWidth for r in range(len(ucl))], columns, rotation=30, fontsize=12)
plt.ylabel('average # of violations', fontsize=12)
plt.legend()
# plt.ylim((0,3))
plt.title("Comparison based on 100 random draws", fontsize=12)
# plt.savefig('classic_vs_sw.png', dpi=300)
# Show graphic
plt.show()
# %%
# %%
# libraries
import numpy as np
import matplotlib.pyplot as plt
# width of the bars
barWidth = 15
columns = [
# 'Overall Quality',
# 'Stadium/city clash',
'Stadium/City Clash',
'TV-pairing NA5 1st',
'TV-pairing other 1st',
'TV-pairing NA5 2nd (HA)',
'SKO (HA)',
'Weekdays (HA)',
'Balance (ENC)',
'Quality (ENC)',
'Structure',
]
# Choose the height of the blue bars
ucl = [
# 3040.22,
# 0,
# 0,
# 0,
# 0.4,
# 0,
0,
0,
0,
0.34,
0.32,
9.82,
10.71,
3.1,
0,
]
# Choose the height of the cyan bars
relaxed = [
# 2644.3,
# 0,
# 0,
# 0,
# 0.52,
# 0,
0,
0,
0,
0.51,
0.19,
9.43,
9.67,
2.91,
0,
]
print(len(columns),len(ucl),len(relaxed))
diff = [-round(ucl[i] - relaxed[i],2) for i in range(len(ucl))]
bars4 = ucl + relaxed + diff
# The x position of bars
# r1 = np.arange(len(ucl))
# r2 = [x + barWidth for x in r1]
# r3 = [x + 2*barWidth for x in r1]
r1 = [4*i*barWidth for i in range(len(ucl))]
r2 = [4*i*barWidth+1*barWidth for i in range(len(ucl))]
r3 = [4*i*barWidth+2*barWidth for i in range(len(ucl))]
r4 = r1 + r2 + r3
# Create labels
label = bars4
# Text on the top of each bar
for i in range(len(r4)):
plt.text(x = r4[i]-0.3 , y = bars4[i]+0.1, s = label[i], size = 12, rotation=90)
# Create blue bars
plt.bar(r1, ucl, width = barWidth, color = 'blue', edgecolor = 'black', capsize=7, label='startwbreak')
# Create cyan bars
plt.bar(r2, relaxed, width = barWidth, color = 'cyan', edgecolor = 'black', capsize=7, label='3breaks')
# Create cyan bars
plt.bar(r3, diff, width = barWidth, color = 'red', edgecolor = 'black', capsize=7, label='diff')
# general layout
plt.xticks([10+ r*4*barWidth for r in range(len(ucl))], columns, rotation=30, fontsize=12)
plt.ylabel('average # of violations', fontsize=12)
plt.legend()
# plt.ylim((0,3))
plt.title("Comparison based on 100 random draws", fontsize=12)
# plt.savefig('sw_vs_3.png', dpi=300)
# Show graphic
plt.show()
# %%