Commit 6268ed28 authored by 张晓彤's avatar 张晓彤

测试锁定排斥及问题修复

parent 89948a75
...@@ -193,6 +193,10 @@ class Group: ...@@ -193,6 +193,10 @@ class Group:
# material control # material control
self.group_walk_available = None self.group_walk_available = None
# device exclude
self.truck_excavator_exclude = set()
self.truck_excavator_exclude_modify = {}
def update_group_mode(self): def update_group_mode(self):
""" """
update group mode. update group mode.
...@@ -291,13 +295,33 @@ class Group: ...@@ -291,13 +295,33 @@ class Group:
else: else:
self.excavator_truck_bind[excavator_id].append(truck_id) self.excavator_truck_bind[excavator_id].append(truck_id)
def get_device_exclude(self, truck_id): def update_device_exclude(self):
""" """
get device exclude modify vector. get device exclude modify vector.
:param truck_id: request truck id
:return: :return:
""" """
pass self.truck_excavator_exclude = {}
self.truck_excavator_exclude_modify = {}
for truck_id in self.group_trucks:
self.truck_excavator_exclude_modify[truck_id] = np.zeros(len(self.group_excavators))
if truck_id in self.truck.truck_excavator_exclude:
exclude_excavators = self.truck.truck_excavator_exclude[truck_id]
else:
continue
for excavator_id in exclude_excavators:
if excavator_id in self.group_excavators:
if truck_id not in self.truck_excavator_exclude:
self.truck_excavator_exclude[truck_id] = [excavator_id]
else:
self.truck_excavator_exclude[truck_id].append(excavator_id)
excavator_index = self.excavator_uuid_index_dict[excavator_id]
self.truck_excavator_exclude_modify[truck_id][excavator_index] = 1000000
self.logger.info("group.truck_excavator_exclude")
self.logger.info(self.truck_excavator_exclude_modify)
def info_update(self): def info_update(self):
""" """
...@@ -309,6 +333,7 @@ class Group: ...@@ -309,6 +333,7 @@ class Group:
self.update_group_device_map() self.update_group_device_map()
self.update_group_road_network() self.update_group_road_network()
self.update_device_material() self.update_device_material()
self.update_device_exclude()
class GroupDispatcher: class GroupDispatcher:
...@@ -477,7 +502,8 @@ class GroupDispatcher: ...@@ -477,7 +502,8 @@ class GroupDispatcher:
else: else:
next_excavator_value = s.solve(truck_info) next_excavator_value = s.solve(truck_info)
# min_index = next_excavator_list.index(min(next_excavator_list)) # min_index = next_excavator_list.index(min(next_excavator_list))
min_index = np.argmin(next_excavator_value) self.logger.info(f'车辆排斥修正 {i}, {self.group.truck_excavator_exclude_modify[i]}')
min_index = np.argmin(next_excavator_value + self.group.truck_excavator_exclude_modify[i])
next_excavator_id = self.group.excavator_uuid_index_dict.inverse[min_index] next_excavator_id = self.group.excavator_uuid_index_dict.inverse[min_index]
if truck_task == -2: if truck_task == -2:
next_unload_area_id = "Park" next_unload_area_id = "Park"
...@@ -513,7 +539,9 @@ class GroupDispatcher: ...@@ -513,7 +539,9 @@ class GroupDispatcher:
next_excavator_id = self.group.truck.truck_excavator_bind[i] next_excavator_id = self.group.truck.truck_excavator_bind[i]
else: else:
next_excavator_value = s.solve(truck_info) next_excavator_value = s.solve(truck_info)
min_index = np.argmin(next_excavator_value) self.logger.info(f'车辆排斥修正 {i}, {self.group.truck_excavator_exclude_modify[i]}')
min_index = np.argmin(next_excavator_value + self.group.truck_excavator_exclude_modify[i])
# min_index = np.argmin(next_excavator_value)
next_excavator_id = self.group.excavator_uuid_index_dict.inverse[min_index] next_excavator_id = self.group.excavator_uuid_index_dict.inverse[min_index]
self.logger.info(f'目标挖机 {min_index} {next_excavator_id}') self.logger.info(f'目标挖机 {min_index} {next_excavator_id}')
......
...@@ -57,10 +57,13 @@ class PreSchedule: ...@@ -57,10 +57,13 @@ class PreSchedule:
excavator_avl_ls: (list) 驶往挖机的各矿卡抵达时间 excavator_avl_ls: (list) 驶往挖机的各矿卡抵达时间
dump_avl_ls: (list) 驶往卸点的各矿卡抵达时间 dump_avl_ls: (list) 驶往卸点的各矿卡抵达时间
""" """
try: # try:
dynamic_excavator_num = self.excavator.get_excavator_num() # dynamic_excavator_num = self.excavator.get_excavator_num()
dumps = self.dump.get_dump_num() dynamic_excavator_num = get_value("dynamic_excavator_num")
trucks = self.truck.get_truck_num() # dumps = self.dump.get_dump_num()
dumps = get_value("dynamic_dump_num")
# trucks = self.truck.get_truck_num()
trucks = get_value("dynamic_truck_num")
truck_current_task = self.truck.get_truck_current_task() truck_current_task = self.truck.get_truck_current_task()
...@@ -74,6 +77,7 @@ class PreSchedule: ...@@ -74,6 +77,7 @@ class PreSchedule:
dump_avl_ls = [[] for _ in range(dumps)] dump_avl_ls = [[] for _ in range(dumps)]
# self.logger.info("update_truck_reach_time-trucks") # self.logger.info("update_truck_reach_time-trucks")
# self.logger.info(trucks) # self.logger.info(trucks)
try:
for i in range(trucks): for i in range(trucks):
if truck_id is not None and i == self.truck.truck_uuid_to_index_dict[truck_id]: if truck_id is not None and i == self.truck.truck_uuid_to_index_dict[truck_id]:
continue continue
...@@ -99,7 +103,7 @@ class PreSchedule: ...@@ -99,7 +103,7 @@ class PreSchedule:
except Exception as es: except Exception as es:
self.logger.error("矿卡预计抵达时间计算异常") self.logger.error("矿卡预计抵达时间计算异常")
self.logger.error(es) self.logger.error(es)
return [], [] return excavator_avl_ls, dump_avl_ls
return excavator_avl_ls, dump_avl_ls return excavator_avl_ls, dump_avl_ls
......
...@@ -246,7 +246,6 @@ class DispatchSubmission: ...@@ -246,7 +246,6 @@ class DispatchSubmission:
self.logger.info("dispatch_plan_dict") self.logger.info("dispatch_plan_dict")
self.logger.info(dispatch_plan_dict) self.logger.info(dispatch_plan_dict)
print(group.truck_info_list)
for truck_id, dispatch_plan in dispatch_plan_dict.items(): for truck_id, dispatch_plan in dispatch_plan_dict.items():
try: try:
......
...@@ -652,21 +652,22 @@ class TruckInfo(WalkManage): ...@@ -652,21 +652,22 @@ class TruckInfo(WalkManage):
except Exception as es: except Exception as es:
session_postgre.rollback() session_postgre.rollback()
session_mysql.rollback() session_mysql.rollback()
if rule5.disabled == 0: if not rule5.disabled:
for excavator_id in get_value("dynamic_excavator_set"): for excavator_id in get_value("dynamic_excavator_set"):
try:
item = ( item = (
session_mysql.query(Equipment) session_mysql.query(Equipment)
.filter_by(id=excavator_id, only_allowed=1) .filter_by(id=excavator_id, only_allowed=1)
.first() .first()
) )
except Exception as es: if item is not None and len(eval(item.bind_list)) > 0:
session_postgre.rollback()
session_mysql.rollback()
if item is not None:
for truck_id in self.dynamic_truck_set: for truck_id in self.dynamic_truck_set:
if truck_uuid_to_name_dict[truck_id] not in item.bind_list: if truck_uuid_to_name_dict[truck_id] not in item.bind_list:
self.truck_excavator_exclude[truck_id] = excavator_id if truck_id not in self.truck_excavator_exclude:
self.truck_excavator_exclude[truck_id] = set()
self.truck_excavator_exclude[truck_id].add(excavator_id)
else:
self.truck_excavator_exclude[truck_id].add(excavator_id)
# self.truck_excavator_exclude[truck_id] = excavator_id
self.excavator_exclude_modify[ self.excavator_exclude_modify[
self.truck_uuid_to_index_dict[truck_id] self.truck_uuid_to_index_dict[truck_id]
][ ][
......
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