代码拉取完成,页面将自动刷新
同步操作将从 Secure_DisOpt&Cont/基于交替方向乘子法的VRPTW问题分解模式 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# coding=gb18030
'''
Author = Yao
'''
from define_class import *
import numpy
import re
# read input 改成能读取通用数据集的,测试更方便
def g_ReadInputData(paraVRP):
print("Read input nodes ...")
f = open(paraVRP.input_file)
data_list = f.readlines()
#定位到node坐标和node需求位置
start_line_of_location = list(filter(lambda x: data_list[x] == 'NODE_COORD_SECTION\n', list(range(len(data_list)))))[0]
start_line_of_demand = list(filter(lambda x: data_list[x] == 'DEMAND_SECTION\n', list(range(len(data_list)))))[0]
start_line_of_depot = list(filter(lambda x: data_list[x] == 'DEPOT_SECTION\n', list(range(len(data_list)))))[0]
for i in range(start_line_of_location):
line = data_list[i]
if ('NAME' in line):
paraVRP.file_name = re.split(": |\n",line)[1]
elif ('DIMENSION' in line):
paraVRP.num_customers = int(re.split(": |\n",line)[1])
elif ('CAPACITY' in line):
paraVRP.veh_cap = int(re.split(": |\n",line)[1])
else:
pass
for i in range(start_line_of_location+1,start_line_of_demand):
line = data_list[i]
node_id,node_x,node_y = int(line.split()[0]),int(line.split()[1]),int(line.split()[2])
node = Node()
node.node_id = node_id
node.x = node_x
node.y = node_y
paraVRP.g_node_dict[node_id] = node
for i in range(start_line_of_demand+1,start_line_of_depot):
line = data_list[i]
node_id, node_demand = int(line.split()[0]), int(line.split()[1])
paraVRP.g_node_dict[node_id].demand = node_demand
paraVRP.origin_node = int(data_list[start_line_of_depot+1])
paraVRP.destination_node = int(data_list[start_line_of_depot+1])
# generate links
print("Generate links ...")
for i in paraVRP.g_node_dict.keys():
for j in paraVRP.g_node_dict.keys():
if i != j:
link = Link()
link.from_node_id = i
link.to_node_id = j
link.distance = int(numpy.sqrt(numpy.square(paraVRP.g_node_dict[i].x - paraVRP.g_node_dict[j].x) + numpy.square(
paraVRP.g_node_dict[i].y - paraVRP.g_node_dict[j].y)))
link.spend_tm = int(link.distance)
paraVRP.g_link_dict[(i, j)] = link
paraVRP.g_node_dict[i].outbound_node_list.append(j)
link = Link()
link.from_node_id = paraVRP.origin_node
link.to_node_id = paraVRP.destination_node
link.distance = 0
link.spend_tm = 0
paraVRP.g_link_dict[(paraVRP.origin_node, paraVRP.destination_node)] = link
paraVRP.g_node_dict[paraVRP.origin_node].outbound_node_list.append(paraVRP.destination_node)
return paraVRP.g_node_dict,paraVRP.g_link_dict
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。