Commit 2c77ecd3 authored by Allvey's avatar Allvey

log more

parent 73bfa283
......@@ -177,16 +177,16 @@ class ExcavatorInfo(WalkManage):
self.excavator_priority_coefficient[self.excavator_uuid_to_index_dict[excavator_id]] = item.priority + 1
# 物料优先级控制
rule = 1
rule = 2
rule7 = session_mysql.query(DispatchRule).filter_by(id=7).first()
material_priority_use = rule7.disabled
if material_priority_use == 0:
rule = rule7.rule_weight
if rule == 0:
if rule == 3:
if session_mysql.query(Material).filter_by(id=self.excavator_material[excavator_id]).first().name == '土':
self.excavator_material_priority[self.excavator_uuid_to_index_dict[excavator_id]] = 5
elif rule == 2:
elif rule == 1:
if session_mysql.query(Material).filter_by(id=self.excavator_material[excavator_id]).first().name == '煤':
self.excavator_material_priority[self.excavator_uuid_to_index_dict[excavator_id]] = 5
......
......@@ -251,7 +251,6 @@ class TruckInfo(WalkManage):
self.excavator_uuid_to_index_dict[item.exactor_id],
]
# if truck_uuid_to_name_dict[self.truck_index_to_uuid_dict[i]] in tmp_set:
# print("here")
# self.cur_truck_reach_excavator[i] = last_unload_time + 10 * self.walk_time_to_load_area[start_area_index][
# end_area_index]
# else:
......@@ -337,6 +336,9 @@ class TruckInfo(WalkManage):
elif item.priority == 3:
self.truck_priority[truck_index] = 10
logger.info("矿卡优先级:")
logger.info(self.truck_priority)
def update_truck_dump_area_bind(self):
try:
rule5 = session_mysql.query(DispatchRule).filter_by(id=5).first()
......@@ -352,6 +354,10 @@ class TruckInfo(WalkManage):
logger.error("矿卡-卸载区域绑定关系读取异常")
logger.error(es)
logger.info("矿卡-卸载点绑定关系")
logger.info(self.truck_dump_bind)
def update_truck_excavator_bind(self):
try:
rule5 = session_mysql.query(DispatchRule).filter_by(id=5).first()
......@@ -368,6 +374,9 @@ class TruckInfo(WalkManage):
logger.error("矿卡-挖机绑定关系读取异常")
logger.error(es)
logger.info("矿卡-挖机绑定关系")
logger.info(self.truck_excavator_bind)
def update_truck_excavator_exclude(self):
self.truck_excavator_exclude = {}
......@@ -398,6 +407,10 @@ class TruckInfo(WalkManage):
logger.error("矿卡-挖机禁止关系读取异常")
logger.error(es)
logger.info("矿卡-挖机禁止关系")
logger.info(self.truck_excavator_exclude)
logger.info(self.excavator_exclude_modify)
def update_truck_dump_exclude(self):
pass
......@@ -424,11 +437,9 @@ class TruckInfo(WalkManage):
if truck_id in self.truck_excavator_bind:
excavator_id = self.truck_excavator_bind[truck_id]
# print(self.excavator.excavator_material)
excavator_material_id = self.excavator.excavator_material[excavator_id]
self.truck_material_bind[truck_id] = excavator_material_id
for truck_id in dynamic_truck_set:
truck_index = self.truck_uuid_to_index_dict[truck_id]
......@@ -449,6 +460,9 @@ class TruckInfo(WalkManage):
if dump_material_id != material:
self.dump_material_bind_modify[truck_index][dump_index] = 1000000
logger.info("矿卡-物料类型")
logger.info(self.truck_material_bind)
def update_truck_spec(self):
for truck_id in dynamic_truck_set:
self.size[truck_id] = session_mysql.query(Equipment).filter_by(id=truck_id).first().equipment_spec
......
......@@ -134,8 +134,8 @@ class PathPlanner(WalkManage):
# 读取路网成本
for walk_time in session_postgre.query(WalkTime).all():
print(str(walk_time.load_area_id), str(walk_time.unload_area_id))
print(walk_time.load_area_name, walk_time.unload_area_name)
# print(str(walk_time.load_area_id),str(walk_time.unload_area_id))
# print(walk_time.load_area_name, walk_time.unload_area_name)
load_area_id, unload_area_id = str(walk_time.load_area_id), str(walk_time.unload_area_id)
unload_area_index = unload_area_uuid_to_index_dict[unload_area_id]
load_area_index = load_area_uuid_to_index_dict[load_area_id]
......@@ -163,8 +163,7 @@ class PathPlanner(WalkManage):
# 路网禁用关系
walk_available = available_walk()
print("path_weight", walk_weight)
logger.info("walk_weight", walk_weight)
for i in range(dynamic_dump_num):
for j in range(dynamic_excavator_num):
......@@ -179,10 +178,10 @@ class PathPlanner(WalkManage):
logger.info("真实路网距离-驶往卸点:")
logger.info(self.distance_to_dump)
logger.info("阻塞路网距离-驶往挖机:")
logger.info("加权-阻塞路网距离-驶往挖机:")
logger.info(cost_to_excavator)
logger.info("阻塞路网距离-驶往卸点:")
logger.info("加权-阻塞路网距离-驶往卸点:")
logger.info(cost_to_dump)
return cost_to_excavator, cost_to_dump, walk_weight, walk_available
......
......@@ -686,12 +686,10 @@ class Dispatcher(WalkManage):
break
else:
if rule3 and rule4:
print("here233")
transport_value = (cost_to_excavator / walk_weight * walk_available)[:, int(trip[1])]
logger.info("不含车流规划:")
logger.info(transport_value)
else:
print("here122")
transport_value = \
(self.actual_goto_dump_traffic_flow[int(trip[1]), :] + 0.001) \
/ (self.opt_goto_dump_traffic_flow[int(trip[1]), :] + 0.001)
......@@ -780,10 +778,8 @@ class Dispatcher(WalkManage):
]
else:
if rule3 and rule4:
print("here233")
transport_value = (cost_to_excavator / walk_weight * walk_available)[int(trip[1]), :]
else:
print("here122")
transport_value = \
(self.actual_goto_excavator_traffic_flow[trip[1], :] + 0.001) \
/ (self.opt_goto_excavator_traffic_flow[trip[1], :] + 0.001)
......
......@@ -13,6 +13,7 @@ from urllib.parse import quote
import logging.handlers
from redis import StrictRedis, ConnectionPool
import numpy as np
import os
from redis import StrictRedis, ConnectionPool
import redis
from datetime import datetime, timedelta
......@@ -26,9 +27,9 @@ import time
# 日志存储地址
log_path = "/usr/local/fleet-log/dispatch"
# # 创建日志目录
# if not os.path.exists(log_path):
# os.mkdir(log_path)
# 创建日志目录
if not os.path.exists(log_path):
os.mkdir(log_path)
# logging初始化工作
logging.basicConfig()
......@@ -38,10 +39,8 @@ logger.setLevel(logging.INFO)
# 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(
"./Logs/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)
# 设置后缀名称,跟strftime的格式一样
filehandler.suffix = "%Y-%m-%d_%H-%M.log"
......
......@@ -194,7 +194,6 @@ class Traffic_para(WalkManage):
#
# if rule == 0:
# if self.excavator.excavator_material[excavator_id] == 'c8092d59-7597-44d7-a731-5a568b46060e':
# print("here111")
# self.excavator_material_priority[self.excavator_uuid_to_index_dict[excavator_id]] = 5
# elif rule == 2:
# if self.excavator.excavator_material[excavator_id] == 'c481794b-6ced-45b9-a9c4-c4a388f44418':
......@@ -339,7 +338,6 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# # 设备优先级
# if not device_priority_use:
# print("here1")
# # 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
# tra_para.priority_coefficient_goto_dump[i][j] = tra_para.excavator_priority_coefficient[i] \
# * tra_para.dump_priority_coefficient[j]
......@@ -349,7 +347,6 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# * tra_para.dump_priority_coefficient[j]
# # 物料优先级
# if not material_priority_use:
# print("here2")
# # # 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
# # tra_para.priority_coefficient_goto_dump[i][j] += tra_para.excavator_material_priority[i] \
# # * tra_para.dump_material_priority[j]
......@@ -367,7 +364,10 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# tra_para.walk_time_to_dump[i][j] = \
# tra_para.walk_time_to_unload_area[load_area_index][unload_area_index]
print("cout", tra_para.priority_coefficient_goto_dump, tra_para.priority_coefficient_goto_excavator)
logger.info("priority_coefficient_goto_dump")
logger.info(tra_para.priority_coefficient_goto_dump)
logger.info("priority_coefficient_goto_excavator")
logger.info(tra_para.priority_coefficient_goto_excavator)
# except Exception as es:
# logger.error(es)
......
......@@ -168,7 +168,7 @@ def traffic_flow_plan():
walk_time_to_dump = traffic_programme_para.walk_time_to_dump
truck_total_num = traffic_programme_para.truck_total_num
print(w_ij, s_ij, b_excavator, b_dump)
# print(w_ij, s_ij, b_excavator, b_dump)
res = transportation_problem_slove(coefficient_goto_dump, coefficient_goto_excavator, w_ij, s_ij, b_excavator, b_dump,
grade_loading_array, max_unload_weigh_alg_flag, truck_total_num,
......@@ -184,12 +184,16 @@ def traffic_flow_plan():
print('各变量的取值为:')
logger.info('各变量取值:')
print(dynamic_dump_set)
logger.info(dynamic_excavator_set)
logger.info(dynamic_dump_set)
print(dynamic_excavator_set)
print(dynamic_dump_set)
print(np.array(res['var_x']).round(3))
logger.info(f'重运车流:{res["var_x"]} 单位: 吨/时')
print(dynamic_excavator_set)
logger.info(dynamic_dump_set)
logger.info(dynamic_excavator_set)
print(dynamic_dump_set)
print(dynamic_excavator_set)
print(np.array(res['var_y']).round(3))
logger.info(f'空运车流:{res["var_y"]} 单位: 吨/时')
......
......@@ -668,7 +668,6 @@ class Dispatcher:
self.truck_current_trip[i] = [self.dump_uuid_to_index_dict[item.dump_id],
self.excavator_uuid_to_index_dict[item.exactor_id]]
# if truck_uuid_to_name_dict[self.truck_index_to_uuid_dict[i]] in tmp_set:
# print("here")
# self.cur_truck_reach_shovel[i] = last_unload_time + 10 * self.com_time_area[start_area_index][
# end_area_index]
# else:
......
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