如何解决Python Mesa - 如何可视化供应链
美好的一天,
我正在尝试使用 Python Mesa 将供应链网络可视化。我已经设法将网络可视化,但是没有清晰的供应链布局。我已经定义了描绘,具有以下功能:
定义供应网络(G):
portrayal = dict()
portrayal["nodes"] = [
{
"id": node_id,"size": 3,"color": "#CC0000" if node_id[0] == 'S' else '#ff5100' if node_id[0] == 'W' else '#616BF9' if node_id[0] == 'A' else '#F9F142',"label": None,}
for (node_id,agents) in G.nodes.data("agent")
]
portrayal["edges"] = [
{"id": edge_id,"source": edge[0],"target": edge[1],'distance': edge[2]['distance'],"color": "#000000"}
for edge_id,edge in enumerate(G.edges(data=True))
]
return portrayal
以 .json 格式提供网络。
[{'id': 0,'source': 'S_C_1','target': 'WH_G_1','distance': 8699.71476,'color': '#000000'},{'id': 1,'source': 'WH_G_1','target': 'S_C_2','distance': 8703.94796,{'id': 2,'target': 'S_C_3','distance': 8708.564081,{'id': 3,'target': 'S_C_4','distance': 8698.159713,{'id': 4,'target': 'S_C_5','distance': 8751.0441,'color': '#000000'}
然后将函数提供给 mesa 的 NetworkModule。
grid = NetworkModule(supply_network,750,library="sigma")
但是,输出看起来像这样:
如何将网络可视化,布局更清晰?我是否需要提供带距离的边权重?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。