Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
integrated-scheduling-v3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张晓彤
integrated-scheduling-v3
Commits
197d83a2
Commit
197d83a2
authored
Sep 01, 2023
by
Allvey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日志及异常处理优化
parent
5a5ae936
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
186 deletions
+23
-186
algorithm.py
alg/algorithm.py
+5
-2
group.py
core/group.py
+5
-171
para_config.py
data/para_config.py
+2
-2
static_data_process.py
data/static_data_process.py
+9
-9
dump.py
equipment/dump.py
+1
-1
truck.py
equipment/truck.py
+1
-1
No files found.
alg/algorithm.py
View file @
197d83a2
...
@@ -250,12 +250,12 @@ class ExpectedTime(AlgorithmBase):
...
@@ -250,12 +250,12 @@ class ExpectedTime(AlgorithmBase):
# get truck located group_excavators id (uuid) from truck trip
# get truck located group_excavators id (uuid) from truck trip
if
int
(
trip
[
1
])
<
0
or
int
(
trip
[
1
])
>=
len
(
DeviceMap
.
excavator_index_to_uuid_dict
):
if
int
(
trip
[
1
])
<
0
or
int
(
trip
[
1
])
>=
len
(
DeviceMap
.
excavator_index_to_uuid_dict
):
raise
CoreException
(
105
,
f
'车辆 {truck_id} 行程驶往 {int(trip[1])} 号挖机越界'
)
raise
Exception
(
f
'车辆 {truck_id} 行程驶往 {int(trip[1])} 号挖机越界'
)
excavator_id
=
DeviceMap
.
excavator_index_to_uuid_dict
[
int
(
trip
[
1
])]
excavator_id
=
DeviceMap
.
excavator_index_to_uuid_dict
[
int
(
trip
[
1
])]
# get group_excavators index (int) within group from group's excavator_group_index
# get group_excavators index (int) within group from group's excavator_group_index
if
excavator_id
not
in
self
.
group
.
excavator_uuid_index_dict
:
if
excavator_id
not
in
self
.
group
.
excavator_uuid_index_dict
:
raise
Core
Exception
(
106
,
f
'挖机 {excavator_id} 不存在于分组 {self.group.name} excavator_uuid_index_dict'
)
raise
Exception
(
106
,
f
'挖机 {excavator_id} 不存在于分组 {self.group.name} excavator_uuid_index_dict'
)
excavator_group_index
=
self
.
group
.
excavator_uuid_index_dict
[
excavator_id
]
excavator_group_index
=
self
.
group
.
excavator_uuid_index_dict
[
excavator_id
]
# get travelling time (List) to each group_dumps
# get travelling time (List) to each group_dumps
...
@@ -288,6 +288,7 @@ class ExpectedTime(AlgorithmBase):
...
@@ -288,6 +288,7 @@ class ExpectedTime(AlgorithmBase):
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
"矿卡空载调度异常"
)
self
.
logger
.
error
(
"矿卡空载调度异常"
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
.
__traceback__
.
tb_lineno
)
transport_value
=
np
.
zeros
(
group_dynamic_unload_area_num
)
transport_value
=
np
.
zeros
(
group_dynamic_unload_area_num
)
elif
task
in
[
3
,
4
,
5
]:
elif
task
in
[
3
,
4
,
5
]:
...
@@ -316,6 +317,8 @@ class ExpectedTime(AlgorithmBase):
...
@@ -316,6 +317,8 @@ class ExpectedTime(AlgorithmBase):
group_excavator_avl_time_ls
[
excavator_index
]
=
excavator_val_time
[
excavator_id
]
group_excavator_avl_time_ls
[
excavator_index
]
=
excavator_val_time
[
excavator_id
]
# get truck located group_dumps id (uuid) from truck trip
# get truck located group_dumps id (uuid) from truck trip
if
int
(
trip
[
1
])
<
0
or
int
(
trip
[
1
])
>=
len
(
DeviceMap
.
dump_index_to_uuid_dict
):
raise
Exception
(
f
'车辆 {truck_id} 行程驶往 {int(trip[1])} 号卸点越界'
)
dump_id
=
DeviceMap
.
dump_index_to_uuid_dict
[
int
(
trip
[
1
])]
dump_id
=
DeviceMap
.
dump_index_to_uuid_dict
[
int
(
trip
[
1
])]
# get unload area id (uuid) from DispatchInfo dump_id to group_unload_areas mapping
# get unload area id (uuid) from DispatchInfo dump_id to group_unload_areas mapping
...
...
core/group.py
View file @
197d83a2
...
@@ -551,19 +551,19 @@ class GroupDispatcher:
...
@@ -551,19 +551,19 @@ class GroupDispatcher:
try
:
try
:
truck_task
=
truck_info
.
get_task
()
truck_task
=
truck_info
.
get_task
()
if
truck_task
is
None
:
if
truck_task
is
None
:
raise
Exception
(
"车辆任务信息丢失"
)
raise
Exception
(
f
'车辆 {truck_name} 任务信息丢失'
)
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
truck_dispatch
[
truck_id
]
=
[
None
,
None
]
#
truck_dispatch[truck_id] = [None, None]
return
return
# 获取车辆位置信息
# 获取车辆位置信息
try
:
try
:
# truck_locate = self.group.truck.get_truck_lane_locate_dict()[truck_id]
# truck_locate = self.group.truck.get_truck_lane_locate_dict()[truck_id]
truck_locate
=
self
.
group
.
truck
.
update_trucks_lane_locate
()
[
truck_id
]
truck_locate
=
self
.
group
.
truck
.
truck_lane_locate_dict
[
truck_id
]
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
f
'车辆位置信息丢失 {es}
'
)
self
.
logger
.
warning
(
f
'车辆 {truck_name} 位置信息丢失
'
)
truck_locate
=
None
truck_locate
=
None
# 获取车辆临时字段
# 获取车辆临时字段
...
@@ -679,7 +679,7 @@ class GroupDispatcher:
...
@@ -679,7 +679,7 @@ class GroupDispatcher:
f
'{next_excavator_id} next_unload_area_id: {next_unload_area_id}'
)
f
'{next_excavator_id} next_unload_area_id: {next_unload_area_id}'
)
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
"
空
载车辆全智能模式-计算异常"
)
self
.
logger
.
error
(
"
重
载车辆全智能模式-计算异常"
)
self
.
logger
.
error
(
es
.
__traceback__
.
tb_lineno
)
self
.
logger
.
error
(
es
.
__traceback__
.
tb_lineno
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
...
@@ -813,172 +813,6 @@ class GroupDispatcher:
...
@@ -813,172 +813,6 @@ class GroupDispatcher:
return
truck_info
return
truck_info
# def redispatch_to_dump(self, truck_id: str, truck_dispatch: Mapping[str, List[str]], truck_locate: str, truck_trip: List[int]):
# """
# redispatch truck to dumps.
# :param truck_id:
# :param truck_dispatch:
# :param truck_locate:
# :param truck_trip:
# :return:
# """
# # 当前绑定装载区
# if truck_trip[0] == -1:
# next_excavator_id = session_mysql.query(EquipmentPair).filter_by(truck_id=truck_id,
# isdeleted=0).first().exactor_id
# else:
# next_excavator_id = get_value("excavator_index_to_uuid_dict")[truck_trip[0]]
# # 当前绑定卸载区
# if truck_trip[-1] == -1:
# item = session_mysql.query(EquipmentPair).filter_by(truck_id=truck_id, isdeleted=0).first()
# current_dump_id = item.dump_id
# current_unload_area_id = item.unload_area_id
# else:
# current_dump_id = get_value("dump_index_to_uuid_dict")[truck_trip[-1]]
# current_unload_area_id = DispatchInfo.dump_unload_area_dict[current_dump_id]
# unload_area_dict, unload_area_lane_dict = self.group.topo.get_unload_target_node_real(truck_locate,
# current_unload_area_id,
# True)
# # 获取拥堵路段
# congestion_lane_dict = self.get_congestion_lanes()
# # 获取当前交叉口下一路段集合
# next_lane_list = get_cross_next_lanes(truck_locate)
# # 交叉口下一路段可达的装载区
# next_lane_load_area_dict = get_lane_reach_load_areas(unload_area_lane_dict,
# next_lane_list)
# # 排除下一个路段阻塞的装载区
# delete_congestion_load_area(congestion_lane_dict, unload_area_dict,
# next_lane_load_area_dict)
# min_trip_time = 10000000
# best_dump_id = current_dump_id
# for unload_area, value in unload_area_dict.items():
# # 车辆不需要掉头
# if value[-1] == 1 and unload_area in DispatchInfo.unload_area_dump_dict:
# dump_id = DispatchInfo.unload_area_dump_dict[unload_area]
#
# traveling_time = value[0] / heavy_speed
#
# now = float(
# (datetime.now() - self.group.pre_sch.start_time) / timedelta(hours=0, minutes=1,
# seconds=0))
# reach_time = now + traveling_time
#
# trip_time = max(reach_time,
# self.group.pre_sch.get_dump_avl_time()[dump_id]) - now
#
# if min_trip_time > trip_time:
# best_dump_id = dump_id
# next_unload_area_id = DispatchInfo.dump_unload_area_dict[best_dump_id]
# truck_dispatch[truck_id] = [next_excavator_id, next_unload_area_id]
# # res = redispatch_request(truck_id, next_excavator_id, next_unload_area_id)
# # self.logger.info(res)
# self.logger.info(f'二次调度结果 {truck_id}')
# self.logger.info(truck_dispatch[truck_id])
#
# def redispatch_to_excavator(self, truck_id, truck_dispatch, truck_locate):
# """
# redispatch truck to excavators.
# :param truck_id:
# :param truck_dispatch:
# :param truck_locate:
# :return:
# """
# # 当前绑定卸载区
# # if truck_trip[0] == -1:
# next_unload_area_id = session_mysql.query(EquipmentPair).filter_by(truck_id=truck_id,
# isdeleted=0).first().unload_area_id
# # else:
# # dump_id = get_value("dump_index_to_uuid_dict")[truck_trip[0]]
# # next_unload_area_id = get_value("dump_uuid_to_unload_area_uuid_dict")[dump_id]
# # 当前绑定装载区
# # if truck_trip[-1] == -1:
# item = session_mysql.query(EquipmentPair).filter_by(truck_id=truck_id, isdeleted=0).first()
# current_excavator_id = item.exactor_id
# current_load_area_id = item.load_area_id
# self.logger.info(f'truck_id {truck_id}')
# self.logger.info(f'current_load_area_id {current_load_area_id}')
# # else:
# # current_excavator_id = get_value("excavator_index_to_uuid_dict")[truck_trip[-1]]
# # current_load_area_id = DispatchInfo.excavator_load_dict[current_excavator_id]
# load_area_dict, load_area_lane_dict = self.group.topo.get_load_target_node_real(truck_locate,
# current_load_area_id, True)
# self.logger.info("所有可达装载区")
# self.logger.info(load_area_dict)
# # 获取拥堵路段
# congestion_lane_dict = self.get_congestion_lanes()
# # 获取当前交叉口下一路段集合
# next_lane_list = get_cross_next_lanes(truck_locate)
# # 交叉口下一路段可达的装载区
# next_lane_load_area_dict = get_lane_reach_load_areas(load_area_lane_dict, next_lane_list)
# # 排除下一个路段阻塞的装载区
# delete_congestion_load_area(congestion_lane_dict, load_area_dict,
# next_lane_load_area_dict)
# self.logger.info("剔除堵塞装载区")
# self.logger.info(load_area_dict)
# # 获取最佳挖机
# best_excavator_id = self.get_best_excavator(current_excavator_id, truck_id, load_area_dict)
# next_excavator_id = best_excavator_id
# truck_dispatch[truck_id] = [next_excavator_id, next_unload_area_id]
# self.logger.info(f'二次调度结果 {truck_id}')
# self.logger.info(truck_dispatch[truck_id])
#
# def get_best_excavator(self, current_excavator_id, truck_id, load_area_dict):
# """
# get best group_excavators
# :param current_excavator_id: 当前车辆配对挖机
# :param truck_id:
# :param load_area_dict: 备选装载区
# :return:
# """
# min_trip_time = 10000000
# best_excavator_id = current_excavator_id
# try:
# for load_area, value in load_area_dict.items():
# # 车辆不需要掉头
# if load_area in DispatchInfo.load_excavator_dict:
# excavator_id = DispatchInfo.load_excavator_dict[load_area]
# else:
# continue
# if value[-1] == 1 and excavator_id in self.group.group_excavators:
# traveling_time = 60 * (value[0] / 1000) / empty_speed
#
# self.logger.info(f'load_area {load_area}')
# self.logger.info(f'traveling_time {traveling_time}')
#
# now = float(
# (datetime.now() - self.group.pre_sch.start_time) / timedelta(hours=0, minutes=1, seconds=0))
#
# reach_time = now + traveling_time
#
# self.logger.info(f'reach_time {reach_time}')
#
# trip_time = max(reach_time,
# self.group.pre_sch.get_excavator_avl_time(truck_id=truck_id)[excavator_id]) - now
#
# self.logger.info(f'trip_time {trip_time}')
#
# if min_trip_time > trip_time:
# best_excavator_id = excavator_id
# min_trip_time = trip_time
#
# except Exception as es:
# self.logger.error("寻找最佳装载区异常")
# self.logger.error(f'exception {es}')
# self.logger.error(f'in line {es.__traceback__.tb_lineno}')
# return best_excavator_id
#
# def get_congestion_lanes(self):
# # 存在车辆拥堵的路段
# truck_locate_dict = self.group.truck.get_truck_locate_dict()
# congestion_lane_list = []
# for key, value in truck_locate_dict.items():
# if self.group.truck.truck_current_state[key] == 2:
# congestion_lane_list.append(value)
#
# print("congestion_lane_list")
# print(list(set(congestion_lane_list)))
# return list(set(congestion_lane_list))
class
ReDispatcher
:
class
ReDispatcher
:
"""
"""
...
...
data/para_config.py
View file @
197d83a2
...
@@ -294,8 +294,8 @@ def global_period_para_update():
...
@@ -294,8 +294,8 @@ def global_period_para_update():
# 矿卡集合
# 矿卡集合
truck_set
=
set
(
update_total_truck
())
truck_set
=
set
(
update_total_truck
())
logger
.
info
(
"group_trucks"
)
#
logger.info("group_trucks")
logger
.
info
(
truck_set
)
#
logger.info(truck_set)
# 固定派车矿卡集合
# 固定派车矿卡集合
fixed_truck_set
=
set
(
update_fixdisp_truck
())
fixed_truck_set
=
set
(
update_fixdisp_truck
())
...
...
data/static_data_process.py
View file @
197d83a2
...
@@ -203,13 +203,13 @@ def update_deveices_map(unload_area_uuid_to_index_dict, load_area_uuid_to_index_
...
@@ -203,13 +203,13 @@ def update_deveices_map(unload_area_uuid_to_index_dict, load_area_uuid_to_index_
session_postgre
.
rollback
()
session_postgre
.
rollback
()
session_mysql
.
rollback
()
session_mysql
.
rollback
()
logger
.
info
(
"excavator_index_to_load_area_index_dict"
)
#
logger.info("excavator_index_to_load_area_index_dict")
logger
.
info
(
excavator_index_to_load_area_index_dict
)
#
logger.info(excavator_index_to_load_area_index_dict)
#
logger
.
info
(
"load_area_uuid_to_index_dict"
)
#
logger.info("load_area_uuid_to_index_dict")
logger
.
info
(
load_area_uuid_to_index_dict
)
#
logger.info(load_area_uuid_to_index_dict)
logger
.
info
(
"static_excavator_uuid_to_index_dict"
)
#
logger.info("static_excavator_uuid_to_index_dict")
logger
.
info
(
excavator_uuid_to_index_dict
)
#
logger.info(excavator_uuid_to_index_dict)
return
{
return
{
"excavator_uuid_to_index_dict"
:
excavator_uuid_to_index_dict
,
"excavator_uuid_to_index_dict"
:
excavator_uuid_to_index_dict
,
...
@@ -234,8 +234,8 @@ def build_truck_uuid_index_map(dynamic_truck_set):
...
@@ -234,8 +234,8 @@ def build_truck_uuid_index_map(dynamic_truck_set):
truck_index_to_uuid_dict
[
truck_num
]
=
truck_id
truck_index_to_uuid_dict
[
truck_num
]
=
truck_id
truck_num
=
truck_num
+
1
truck_num
=
truck_num
+
1
logger
.
info
(
"static_data_process.py-truck_uuid_to_index_dict"
)
#
logger.info("static_data_process.py-truck_uuid_to_index_dict")
logger
.
info
(
truck_uuid_to_index_dict
)
#
logger.info(truck_uuid_to_index_dict)
return
{
return
{
"truck_uuid_to_index_dict"
:
truck_uuid_to_index_dict
,
"truck_uuid_to_index_dict"
:
truck_uuid_to_index_dict
,
...
...
equipment/dump.py
View file @
197d83a2
...
@@ -175,7 +175,7 @@ class DumpInfo(WalkManage):
...
@@ -175,7 +175,7 @@ class DumpInfo(WalkManage):
if
unload_ability
<
200
:
if
unload_ability
<
200
:
self
.
dump_strength
[
dump_index
]
=
200
self
.
dump_strength
[
dump_index
]
=
200
raise
Exception
(
"卸载点卸载能力异常
"
)
self
.
logger
.
warning
(
"卸载点卸载能力异常 < 200
"
)
else
:
else
:
self
.
dump_strength
[
dump_index
]
=
unload_ability
# 卸载设备最大卸载能力,单位吨/小时
self
.
dump_strength
[
dump_index
]
=
unload_ability
# 卸载设备最大卸载能力,单位吨/小时
else
:
else
:
...
...
equipment/truck.py
View file @
197d83a2
...
@@ -599,7 +599,7 @@ class TruckInfo(WalkManage):
...
@@ -599,7 +599,7 @@ class TruckInfo(WalkManage):
if
item
.
bind_list
is
not
None
:
if
item
.
bind_list
is
not
None
:
for
truck_name
in
json
.
loads
(
item
.
bind_list
):
for
truck_name
in
json
.
loads
(
item
.
bind_list
):
if
truck_name
not
in
truck_name_to_uuid_dict
:
if
truck_name
not
in
truck_name_to_uuid_dict
:
self
.
logger
.
error
(
f
'truck_name_to_uuid_dict (db2) 不存在 {truck_name}'
)
self
.
logger
.
warning
(
f
'truck_name_to_uuid_dict (db2) 不存在 {truck_name}'
)
continue
continue
self
.
truck_excavator_bind
[
self
.
truck_excavator_bind
[
truck_name_to_uuid_dict
[
truck_name
]
truck_name_to_uuid_dict
[
truck_name
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment