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
79ec12f7
Commit
79ec12f7
authored
Nov 09, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异常捕获优化
parent
52f07aa5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
131 deletions
+140
-131
dispatcher.py
core/dispatcher.py
+14
-10
group.py
core/group.py
+126
-121
No files found.
core/dispatcher.py
View file @
79ec12f7
...
@@ -73,8 +73,7 @@ class Dispatcher:
...
@@ -73,8 +73,7 @@ class Dispatcher:
Group dispatching logic.
Group dispatching logic.
:return:
:return:
"""
"""
a
=
len
(
self
.
group_list
)
aa
=
self
.
group_list
for
group
in
self
.
group_list
.
values
():
for
group
in
self
.
group_list
.
values
():
try
:
try
:
...
@@ -83,14 +82,19 @@ class Dispatcher:
...
@@ -83,14 +82,19 @@ class Dispatcher:
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
f
'分组{group.group_id} 调度异常'
)
self
.
logger
.
error
(
f
'分组 {group.group_id} 调度异常'
)
self
.
logger
.
info
(
f
'调度分组: {group.group_id} {DispatchInfo.group_name[group.group_id]}'
)
try
:
self
.
logger
.
info
(
"组内挖机"
)
self
.
logger
.
info
(
group
.
excavator
)
self
.
logger
.
info
(
f
'调度分组: {group.group_id} {DispatchInfo.group_name[group.group_id]}'
)
self
.
logger
.
info
(
"组内卸点"
)
self
.
logger
.
info
(
"组内挖机"
)
self
.
logger
.
info
(
group
.
dump
)
self
.
logger
.
info
(
group
.
excavator
)
self
.
submission
.
group_dispatch_to_redis
(
group
,
truck_dispatch_plan_dict
)
self
.
logger
.
info
(
"组内卸点"
)
self
.
logger
.
info
(
group
.
dump
)
self
.
submission
.
group_dispatch_to_redis
(
group
,
truck_dispatch_plan_dict
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
class
DispatchSubmission
:
class
DispatchSubmission
:
...
...
core/group.py
View file @
79ec12f7
...
@@ -267,154 +267,159 @@ class Group:
...
@@ -267,154 +267,159 @@ class Group:
s
=
solver
(
self
,
self
.
truck
,
self
.
pre_sch
)
# algorithm init
s
=
solver
(
self
,
self
.
truck
,
self
.
pre_sch
)
# algorithm init
for
i
in
list
(
self
.
truck_set
):
for
i
in
list
(
self
.
truck_set
):
truck_trip
=
self
.
truck
.
get_truck_current_trip
()[
self
.
truck
.
truck_uuid_to_index_dict
[
i
]]
try
:
truck_task
=
self
.
truck
.
get_truck_current_task
()[
i
]
truck_trip
=
self
.
truck
.
get_truck_current_trip
()[
self
.
truck
.
truck_uuid_to_index_dict
[
i
]]
truck_info
=
CurrentTruck
(
i
,
self
.
group_id
,
truck_trip
,
truck_task
)
truck_task
=
self
.
truck
.
get_truck_current_task
()[
i
]
self
.
truck_info_list
[
i
]
=
truck_info
truck_info
=
CurrentTruck
(
i
,
self
.
group_id
,
truck_trip
,
truck_task
)
# 全智能模式
self
.
truck_info_list
[
i
]
=
truck_info
if
self
.
group_mode
==
1
:
# 全智能模式
if
truck_task
in
[
-
2
,
3
,
4
,
5
]:
if
self
.
group_mode
==
1
:
try
:
if
truck_task
in
[
-
2
,
3
,
4
,
5
]:
if
i
in
self
.
truck
.
truck_excavator_bind
:
try
:
next_excavator_id
=
self
.
truck
.
truck_excavator_bind
[
i
]
if
i
in
self
.
truck
.
truck_excavator_bind
:
else
:
next_excavator_id
=
self
.
truck
.
truck_excavator_bind
[
i
]
next_excavator_value
=
s
.
solve
(
truck_info
)
else
:
# next_excavator_value = s.solve(i, truck_task, truck_trip)
next_excavator_value
=
s
.
solve
(
truck_info
)
# min_index = next_excavator_list.index(min(next_excavator_list))
# next_excavator_value = s.solve(i, truck_task, truck_trip)
min_index
=
np
.
argmin
(
next_excavator_value
)
# min_index = next_excavator_list.index(min(next_excavator_list))
next_excavator_id
=
self
.
excavator_uuid_index_dict
.
inverse
[
min_index
]
min_index
=
np
.
argmin
(
next_excavator_value
)
next_excavator_id
=
self
.
excavator_uuid_index_dict
.
inverse
[
min_index
]
if
truck_task
==
-
2
:
next_unload_area_id
=
"Park"
if
truck_task
==
-
2
:
else
:
next_unload_area_id
=
"Park"
dump_id
=
get_value
(
"dump_index_to_uuid_dict"
)[
truck_trip
[
-
1
]]
else
:
next_unload_area_id
=
get_value
(
"dump_uuid_to_unload_area_uuid_dict"
)[
dump_id
]
dump_id
=
get_value
(
"dump_index_to_uuid_dict"
)[
truck_trip
[
-
1
]]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
next_unload_area_id
=
get_value
(
"dump_uuid_to_unload_area_uuid_dict"
)[
dump_id
]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
except
Exception
as
es
:
self
.
logger
.
error
(
"重载车辆全智能模式-计算异常"
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
"重载车辆全智能模式-计算异常"
)
self
.
logger
.
error
(
es
)
if
truck_task
in
[
0
,
1
,
2
]:
try
:
if
truck_task
in
[
0
,
1
,
2
]:
next_excavator_id
=
get_value
(
"excavator_index_to_uuid_dict"
)[
truck_trip
[
-
1
]]
try
:
next_unload_area_value
=
s
.
solve
(
truck_info
)
next_excavator_id
=
get_value
(
"excavator_index_to_uuid_dict"
)[
truck_trip
[
-
1
]]
self
.
logger
.
info
(
f
'车辆 {i}'
)
next_unload_area_value
=
s
.
solve
(
truck_info
)
self
.
logger
.
info
(
f
'group distance {self.to_unload_area_distance}'
)
self
.
logger
.
info
(
f
'车辆 {i}'
)
self
.
logger
.
info
(
f
'walk available {self.group_walk_available}'
)
self
.
logger
.
info
(
f
'group distance {self.to_unload_area_distance}'
)
self
.
logger
.
info
(
f
'walk available {self.group_walk_available}'
)
self
.
logger
.
info
(
self
.
unload_area_uuid_index_dict
)
self
.
logger
.
info
(
self
.
excavator_uuid_index_dict
)
self
.
logger
.
info
(
self
.
unload_area_uuid_index_dict
)
self
.
logger
.
info
(
self
.
excavator_uuid_index_dict
)
if
i
in
self
.
truck
.
truck_dump_bind
:
dump_uuid_to_unload_area_uuid_dict
=
get_value
(
"dump_uuid_to_unload_area_uuid_dict"
)
if
i
in
self
.
truck
.
truck_dump_bind
:
next_unload_area_id
=
dump_uuid_to_unload_area_uuid_dict
[
self
.
truck
.
truck_dump_bind
[
i
]]
dump_uuid_to_unload_area_uuid_dict
=
get_value
(
"dump_uuid_to_unload_area_uuid_dict"
)
else
:
next_unload_area_id
=
dump_uuid_to_unload_area_uuid_dict
[
self
.
truck
.
truck_dump_bind
[
i
]]
tmp
=
self
.
group_walk_available
[
else
:
self
.
excavator_uuid_index_dict
[
next_excavator_id
],
:]
.
flatten
()
tmp
=
self
.
group_walk_available
[
self
.
logger
.
info
(
f
'group_walk_available_pick {tmp}'
)
self
.
excavator_uuid_index_dict
[
next_excavator_id
],
:]
.
flatten
()
self
.
logger
.
info
(
f
'next_excavator_id {next_excavator_id}'
)
self
.
logger
.
info
(
f
'group_walk_available_pick {tmp}'
)
self
.
logger
.
info
(
next_unload_area_value
)
self
.
logger
.
info
(
f
'next_excavator_id {next_excavator_id}'
)
next_unload_area_value
*=
self
.
group_walk_available
[
self
.
logger
.
info
(
next_unload_area_value
)
self
.
excavator_uuid_index_dict
[
next_excavator_id
],
:]
.
flatten
()
next_unload_area_value
*=
self
.
group_walk_available
[
self
.
excavator_uuid_index_dict
[
next_excavator_id
],
:]
.
flatten
()
self
.
logger
.
info
(
next_unload_area_value
)
min_index
=
np
.
argmin
(
next_unload_area_value
)
self
.
logger
.
info
(
next_unload_area_value
)
next_unload_area_id
=
self
.
unload_area_uuid_index_dict
.
inverse
[
min_index
]
min_index
=
np
.
argmin
(
next_unload_area_value
)
# next_excavator_id = self.excavator_uuid_index_dict.inverse[truck_trip[-1]]
next_unload_area_id
=
self
.
unload_area_uuid_index_dict
.
inverse
[
min_index
]
# next_excavator_id = self.excavator_uuid_index_dict.inverse[truck_trip[-1]]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
except
Exception
as
es
:
self
.
logger
.
error
(
"空载车辆全智能模式-计算异常"
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
"空载车辆全智能模式-计算异常"
)
truck_dispatch
[
i
]
=
[
None
,
None
]
self
.
logger
.
error
(
es
)
# 空车智能模式
truck_dispatch
[
i
]
=
[
None
,
None
]
elif
self
.
group_mode
==
2
:
# 空车智能模式
if
truck_task
in
[
-
2
,
3
,
4
,
5
]:
elif
self
.
group_mode
==
2
:
try
:
if
truck_task
in
[
-
2
,
3
,
4
,
5
]:
try
:
if
i
in
self
.
truck
.
truck_excavator_bind
:
next_excavator_id
=
self
.
truck
.
truck_excavator_bind
[
i
]
if
i
in
self
.
truck
.
truck_excavator_bind
:
else
:
next_excavator_id
=
self
.
truck
.
truck_excavator_bind
[
i
]
next_excavator_value
=
s
.
solve
(
truck_info
)
else
:
# min_index = next_excavator_list.index(min(next_excavator_list))
next_excavator_value
=
s
.
solve
(
truck_info
)
min_index
=
np
.
argmin
(
next_excavator_value
)
# min_index = next_excavator_list.index(min(next_excavator_list))
next_excavator_id
=
self
.
excavator_uuid_index_dict
.
inverse
[
min_index
]
min_index
=
np
.
argmin
(
next_excavator_value
)
if
truck_task
==
-
2
:
next_excavator_id
=
self
.
excavator_uuid_index_dict
.
inverse
[
min_index
]
next_unload_area_id
=
"Park"
if
truck_task
==
-
2
:
else
:
next_unload_area_id
=
"Park"
# next_unload_area_id = self.unload_area_uuid_index_dict.inverse[truck_trip[-1]]
else
:
dump_id
=
get_value
(
"dump_index_to_uuid_dict"
)[
truck_trip
[
-
1
]]
# next_unload_area_id = self.unload_area_uuid_index_dict.inverse[truck_trip[-1]]
next_unload_area_id
=
get_value
(
"dump_uuid_to_unload_area_uuid_dict"
)[
dump_id
]
dump_id
=
get_value
(
"dump_index_to_uuid_dict"
)[
truck_trip
[
-
1
]]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
next_unload_area_id
=
get_value
(
"dump_uuid_to_unload_area_uuid_dict"
)[
dump_id
]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
except
Exception
as
es
:
self
.
logger
.
error
(
"重载车辆空车智能模式-计算异常"
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
"重载车辆空车智能模式-计算异常"
)
if
truck_task
in
[
0
,
1
,
2
]:
self
.
logger
.
error
(
es
)
if
truck_task
in
[
0
,
1
,
2
]:
try
:
truck_dispatch
[
i
]
=
DispatchInfo
.
get_truck_match
(
i
)
except
Exception
as
es
:
self
.
logger
.
error
(
"空载车辆空车智能模式-计算异常"
)
self
.
logger
.
error
(
es
)
# 定铲派车
elif
self
.
group_mode
==
3
:
try
:
try
:
truck_dispatch
[
i
]
=
DispatchInfo
.
get_truck_match
(
i
)
truck_dispatch
[
i
]
=
DispatchInfo
.
get_truck_match
(
i
)
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
"
空载车辆空车智能模式
-计算异常"
)
self
.
logger
.
error
(
"
固定派车
-计算异常"
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
# 定铲派车
elif
self
.
group_mode
==
3
:
try
:
truck_dispatch
[
i
]
=
DispatchInfo
.
get_truck_match
(
i
)
except
Exception
as
es
:
self
.
logger
.
error
(
"固定派车-计算异常"
)
self
.
logger
.
error
(
es
)
# 分流配比模式
# 分流配比模式
elif
self
.
group_mode
==
4
:
elif
self
.
group_mode
==
4
:
next_exactor_id
=
DispatchInfo
.
get_truck_exactor
(
i
)
# 获取该卡车对应的exactor_id
next_exactor_id
=
DispatchInfo
.
get_truck_exactor
(
i
)
# 获取该卡车对应的exactor_id
self
.
logger
.
info
(
f
"分流配比模式,对应的卡车:{i}"
)
self
.
logger
.
info
(
f
"分流配比模式,对应的卡车:{i}"
)
self
.
logger
.
info
(
f
"矿卡对应的铲车:{next_exactor_id}"
)
self
.
logger
.
info
(
f
"矿卡对应的铲车:{next_exactor_id}"
)
next_unload_area_id
=
None
next_unload_area_id
=
None
if
truck_task
==
-
2
:
if
truck_task
==
-
2
:
next_unload_area_id
=
"Park"
next_unload_area_id
=
"Park"
# 空载模式下,计算下一次卸载区的位置,按照分流配比的模式进行计算
# 空载模式下,计算下一次卸载区的位置,按照分流配比的模式进行计算
elif
truck_task
in
[
0
,
1
,
2
]:
elif
truck_task
in
[
0
,
1
,
2
]:
try
:
try
:
if
i
in
self
.
truck
.
truck_dump_bind
:
if
i
in
self
.
truck
.
truck_dump_bind
:
dump_uuid_to_unload_area_uuid_dict
=
get_value
(
"dump_uuid_to_unload_area_uuid_dict"
)
dump_uuid_to_unload_area_uuid_dict
=
get_value
(
"dump_uuid_to_unload_area_uuid_dict"
)
next_unload_area_id
=
dump_uuid_to_unload_area_uuid_dict
[
self
.
truck
.
truck_dump_bind
[
i
]]
next_unload_area_id
=
dump_uuid_to_unload_area_uuid_dict
[
self
.
truck
.
truck_dump_bind
[
i
]]
else
:
else
:
next_unload_area_id
=
DistributionRatio
(
next_exactor_id
,
self
.
truck
)
.
ratio_main
()
next_unload_area_id
=
DistributionRatio
(
next_exactor_id
,
self
.
truck
)
.
ratio_main
()
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
"分流配比模式-->>空载车辆计算异常"
)
self
.
logger
.
error
(
"分流配比模式-->>空载车辆计算异常"
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
# 重载模式下,按照固定派车进行计算
# 重载模式下,按照固定派车进行计算
elif
truck_task
in
[
3
,
4
,
5
]:
elif
truck_task
in
[
3
,
4
,
5
]:
try
:
try
:
next_unload_area_id
=
DispatchInfo
.
get_truck_match
(
i
)[
1
]
next_unload_area_id
=
DispatchInfo
.
get_truck_match
(
i
)[
1
]
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
"分流配比模式-->>重载车辆计算异常"
)
self
.
logger
.
error
(
"分流配比模式-->>重载车辆计算异常"
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
truck_dispatch
[
i
]
=
[
next_exactor_id
,
next_unload_area_id
]
truck_dispatch
[
i
]
=
[
next_exactor_id
,
next_unload_area_id
]
except
Exception
as
es
:
self
.
logger
.
error
(
f
'车辆 {i} 调度异常'
)
self
.
logger
.
error
(
es
)
# return dispatch plan
# return dispatch plan
return
truck_dispatch
return
truck_dispatch
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