Commit 3c2d53dd authored by Allvey's avatar Allvey

speed update debug

parent dca1c2f1
...@@ -48,11 +48,11 @@ class PathPlanner(WalkManage): ...@@ -48,11 +48,11 @@ class PathPlanner(WalkManage):
to_unload_cost = 0 to_unload_cost = 0
# 装载道路总成本初始化 # 装载道路总成本初始化
to_load_cost = 0 to_load_cost = 0
# 道路权重 # # 道路权重
weighted_distance = weighted_walk_cost() # weighted_distance = weighted_walk_cost()
# 修正因子 # 修正因子
weight = 100 weight = 60
# 阻塞成本权重 # 阻塞成本权重
alpha = 0 alpha = 0
# 距离成本权重 # 距离成本权重
...@@ -101,6 +101,10 @@ class PathPlanner(WalkManage): ...@@ -101,6 +101,10 @@ class PathPlanner(WalkManage):
to_unload_cost = alpha * cost_to_unload_blockage + beta * path.to_unload_distance to_unload_cost = alpha * cost_to_unload_blockage + beta * path.to_unload_distance
to_load_cost = alpha * cost_to_load_blockage + beta * path.to_load_distance to_load_cost = alpha * cost_to_load_blockage + beta * path.to_load_distance
# print("拥堵因子-挖机")
# print(alpha, cost_to_load_blockage)
# print("拥堵因子-卸点")
# print(alpha, cost_to_unload_blockage)
except Exception as es: except Exception as es:
logger.error(f'道路{load_area_id + "-" +unload_area_id}行驶成本计算异常') logger.error(f'道路{load_area_id + "-" +unload_area_id}行驶成本计算异常')
logger.error(es) logger.error(es)
...@@ -136,6 +140,9 @@ class PathPlanner(WalkManage): ...@@ -136,6 +140,9 @@ class PathPlanner(WalkManage):
self.period_map_para_load() self.period_map_para_load()
# 计算行驶成本前,更新路网速度信息
self.lane.lane_speed_generate()
try: try:
# 读取路网成本 # 读取路网成本
for walk_time in session_postgre.query(WalkTime).all(): for walk_time in session_postgre.query(WalkTime).all():
......
...@@ -393,6 +393,8 @@ class Dispatcher(WalkManage): ...@@ -393,6 +393,8 @@ class Dispatcher(WalkManage):
# 卸载设备可用时间 # 卸载设备可用时间
self.update_dump_ava_time(dump_reach_list) self.update_dump_ava_time(dump_reach_list)
self.cost_to_excavator, self.cost_to_dump, self.cost_park_to_excavator = self.path.walk_cost()
def sim_para_reset(self): def sim_para_reset(self):
...@@ -406,7 +408,7 @@ class Dispatcher(WalkManage): ...@@ -406,7 +408,7 @@ class Dispatcher(WalkManage):
rule3 = session_mysql.query(DispatchRule).filter_by(id=3).first().disabled rule3 = session_mysql.query(DispatchRule).filter_by(id=3).first().disabled
rule4 = session_mysql.query(DispatchRule).filter_by(id=4).first().disabled rule4 = session_mysql.query(DispatchRule).filter_by(id=4).first().disabled
cost_to_excavator, cost_to_dump, cost_park_to_excavator = self.path.walk_cost() # cost_to_excavator, cost_to_dump, cost_park_to_excavator = self.path.walk_cost()
excavator_priority_coefficient = self.excavator.excavator_priority_coefficient excavator_priority_coefficient = self.excavator.excavator_priority_coefficient
...@@ -459,7 +461,7 @@ class Dispatcher(WalkManage): ...@@ -459,7 +461,7 @@ class Dispatcher(WalkManage):
if truck_id in self.truck.truck_excavator_bind: if truck_id in self.truck.truck_excavator_bind:
target = self.excavator_uuid_to_index_dict[self.truck.truck_excavator_bind[truck_id]] target = self.excavator_uuid_to_index_dict[self.truck.truck_excavator_bind[truck_id]]
else: else:
transport_value = cost_park_to_excavator transport_value = self.cost_park_to_excavator
logger.info("transport_value") logger.info("transport_value")
logger.info(transport_value) logger.info(transport_value)
...@@ -514,7 +516,7 @@ class Dispatcher(WalkManage): ...@@ -514,7 +516,7 @@ class Dispatcher(WalkManage):
if truck_id in self.truck.truck_material_bind: if truck_id in self.truck.truck_material_bind:
logger.info(self.truck.truck_material_bind[truck_id]) logger.info(self.truck.truck_material_bind[truck_id])
logger.info("驶往卸点的运输成本") logger.info("驶往卸点的运输成本")
logger.info(cost_to_dump) logger.info(self.cost_to_dump)
logger.info("卸点物料修正") logger.info("卸点物料修正")
logger.info(self.truck.dump_material_bind_modify) logger.info(self.truck.dump_material_bind_modify)
...@@ -530,7 +532,7 @@ class Dispatcher(WalkManage): ...@@ -530,7 +532,7 @@ class Dispatcher(WalkManage):
break break
else: else:
if rule3 and rule4: if rule3 and rule4:
transport_value = cost_to_dump[:, int(trip[1])] transport_value = self.cost_to_dump[:, int(trip[1])]
else: else:
transport_value = (self.actual_goto_dump_traffic_flow[int(trip[1]), :] + 0.001) \ transport_value = (self.actual_goto_dump_traffic_flow[int(trip[1]), :] + 0.001) \
/ (self.opt_goto_dump_traffic_flow[int(trip[1]), :] + 0.001) / (self.opt_goto_dump_traffic_flow[int(trip[1]), :] + 0.001)
...@@ -590,7 +592,7 @@ class Dispatcher(WalkManage): ...@@ -590,7 +592,7 @@ class Dispatcher(WalkManage):
if truck_id in self.truck.truck_material_bind: if truck_id in self.truck.truck_material_bind:
logger.info(self.truck.truck_material_bind[truck_id]) logger.info(self.truck.truck_material_bind[truck_id])
logger.info("驶往挖机的运输成本") logger.info("驶往挖机的运输成本")
logger.info(cost_to_excavator) logger.info(self.cost_to_excavator)
logger.info("挖机物料修正") logger.info("挖机物料修正")
logger.info(self.truck.excavator_material_bind_modify) logger.info(self.truck.excavator_material_bind_modify)
logger.info("挖机优先级修正") logger.info("挖机优先级修正")
...@@ -603,7 +605,7 @@ class Dispatcher(WalkManage): ...@@ -603,7 +605,7 @@ class Dispatcher(WalkManage):
target = self.excavator_uuid_to_index_dict[self.truck.truck_excavator_bind[truck_id]] target = self.excavator_uuid_to_index_dict[self.truck.truck_excavator_bind[truck_id]]
else: else:
if rule3 and rule4: if rule3 and rule4:
transport_value = cost_to_excavator[int(trip[1]), :] transport_value = self.cost_to_excavator[int(trip[1]), :]
else: else:
transport_value = (self.actual_goto_excavator_traffic_flow[trip[1], :] + 0.001) \ transport_value = (self.actual_goto_excavator_traffic_flow[trip[1], :] + 0.001) \
/ (self.opt_goto_excavator_traffic_flow[trip[1], :] + 0.001) / (self.opt_goto_excavator_traffic_flow[trip[1], :] + 0.001)
......
...@@ -27,8 +27,8 @@ import time ...@@ -27,8 +27,8 @@ import time
log_path = "/usr/local/fleet-log/dispatch" log_path = "/usr/local/fleet-log/dispatch"
# 创建日志目录 # 创建日志目录
if not os.path.exists(log_path): # if not os.path.exists(log_path):
os.mkdir(log_path) # os.mkdir(log_path)
# logging初始化工作 # logging初始化工作
logging.basicConfig() logging.basicConfig()
...@@ -38,8 +38,8 @@ logger.setLevel(logging.INFO) ...@@ -38,8 +38,8 @@ logger.setLevel(logging.INFO)
# timefilehandler = logging.handlers.TimedRotatingFileHandler(log_path + "/dispatch.log", when='M', interval=1, backupCount=60) # timefilehandler = logging.handlers.TimedRotatingFileHandler(log_path + "/dispatch.log", when='M', interval=1, backupCount=60)
filehandler = logging.handlers.RotatingFileHandler(log_path + "/dispatch.log", maxBytes=3*1024*1024, backupCount=10) # filehandler = logging.handlers.RotatingFileHandler(log_path + "/dispatch.log", maxBytes=3*1024*1024, backupCount=10)
# filehandler = logging.handlers.RotatingFileHandler("./Logs/dispatch.log", maxBytes=3 * 1024 * 1024, backupCount=10) filehandler = logging.handlers.RotatingFileHandler("./Logs/dispatch.log", maxBytes=3 * 1024 * 1024, backupCount=10)
# 设置后缀名称,跟strftime的格式一样 # 设置后缀名称,跟strftime的格式一样
filehandler.suffix = "%Y-%m-%d_%H-%M.log" filehandler.suffix = "%Y-%m-%d_%H-%M.log"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment