Comparison of Objectives for Different P Values in a Balanced vs. Unbalanced Scenario
import matplotlib.pyplot as plt from matplotlib import rcParams
设置字体
rcParams['font.family'] = 'serif' rcParams['font.serif'] = ['Times New Roman']
配送成本数据
costs_p6 = [15791.4426,15566.6707] costs_p7 = [16703.4532,16373.4197] costs_p8 = [15722.7008,15819.5234]
客户效用数据
utility_p6 = [-56.5051,-68.9298] utility_p7 = [-56.0023,-63.5487] utility_p8 = [-48.82791,-52.4017]
紧凑性数据
compactness_p6 = [4700.1671,4677.9404] compactness_p7 = [4313.738,4307.662] compactness_p8 = [4001.1592,3997.655]
车辆数量数据
vehicles_p6 = [33,32] vehicles_p7 = [35, 34] vehicles_p8 = [33, 33]
绘制子图
fig, axs = plt.subplots(nrows=2, ncols=2, figsize=(10,8))
配送成本子图
axs[0, 0].bar(['
P=6', '
P=6'], costs_p6, align='center', alpha=0.5, label='Unbalanced', color=['blue', 'orange']) axs[0, 0].bar(['P=7', 'P=7'], costs_p7, align='center', alpha=0.5, label='Balanced', color=['blue', 'orange']) axs[0, 0].bar(['P=8', 'P=8'], costs_p8, align='center', alpha=0.5, color=['blue', 'orange']) axs[0, 0].set_xlabel('P', fontstyle='italic') axs[0, 0].set_ylabel('Delivery cost') axs[0, 0].legend()
客户效用子图
axs[0, 1].bar(['
P=6', '
P=6'], utility_p6, align='center', alpha=0.5, label='Unbalanced', color=['blue', 'orange']) axs[0, 1].bar(['P=7', 'P=7'], utility_p7, align='center', alpha=0.5, label='Balanced', color=['blue', 'orange']) axs[0, 1].bar(['P=8', 'P=8'], utility_p8, align='center', alpha=0.5, color=['blue', 'orange']) axs[0, 1].set_xlabel('P', fontstyle='italic') axs[0, 1].set_ylabel('Customer utility') axs[0, 1].legend()
紧凑性子图
axs[1, 0].bar(['
P=6', '
P=6'], compactness_p6, align='center', alpha=0.5, label='Unbalanced', color=['blue', 'orange']) axs[1, 0].bar(['P=7', 'P=7'], compactness_p7, align='center', alpha=0.5, label='Balanced', color=['blue', 'orange']) axs[1, 0].bar(['P=8', 'P=8'], compactness_p8, align='center', alpha=0.5, color=['blue', 'orange']) axs[1, 0].set_xlabel('P', fontstyle='italic') axs[1, 0].set_ylabel('Compactness') axs[1, 0].legend()
车辆数量子图
axs[1, 1].bar(['
P=6', '
P=6'], vehicles_p6, align='center', alpha=0.5, label='Unbalanced', color=['blue', 'orange']) axs[1, 1].bar(['P=7', 'P=7'], vehicles_p7, align='center', alpha=0.5, label='Balanced', color=['blue', 'orange']) axs[1, 1].bar(['P=8', 'P=8'], vehicles_p8, align='center', alpha=0.5, color=['blue', 'orange']) axs[1, 1].set_xlabel('P', fontstyle='italic') axs[1, 1].set_ylabel('Number of vehicles') axs[1, 1].legend()
标题和标签
fig.suptitle('Comparison of objectives for different P values') fig.tight_layout(rect=[0, 0.03, 1, 0.95])
plt.show()
原文地址: https://www.cveoy.top/t/topic/obkQ 著作权归作者所有。请勿转载和采集!