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
9b576902
Commit
9b576902
authored
May 11, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
启动异常检测&任务状态修正
parent
2cd49cca
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
134 additions
and
293 deletions
+134
-293
config.json
config.json
+0
-6
dispatcher.py
dispatcher.py
+62
-57
truck.py
equipment/truck.py
+5
-5
group_control.py
group_control/group_control.py
+2
-2
path_plannner.py
path_plan/path_plannner.py
+38
-38
priority_control_2.py
path_plan/priority_control_2.py
+0
-158
realtime_dispatch.py
realtime_dispatch.py
+27
-27
No files found.
config.json
View file @
9b576902
{
"para"
:
{
<<<<<<<
HEAD
"log_path"
:
"E:
\\
Pycharm Projects
\\
Waytous
\\
"
,
"empty_speed"
:
25
,
"heavy_speed"
:
22
,
=======
"log_path"
:
"/usr/local/fleet-log/dispatch"
,
"empty_speed"
:
17
,
"heavy_speed"
:
17
,
>>>>>>>
new
"dump_target_mass"
:
5000
,
"excavator_target_mass"
:
5000
},
...
...
dispatcher.py
View file @
9b576902
This diff is collapsed.
Click to expand it.
equipment/truck.py
View file @
9b576902
...
...
@@ -183,7 +183,7 @@ class TruckInfo(WalkManage):
# 判断是否为矿卡
if
device_type
==
1
:
task
=
self
.
truck_current_task
[
item
]
if
task
in
heavy_task_set
:
if
task
in
[
3
,
4
,
5
]:
# 矿卡重载行驶或仍未出场
if
str_to_byte
(
"lastLoadTime"
)
in
key_value_dict
.
keys
():
# 若最后装载时间存在
last_load_time_tmp
=
eval
(
byte_to_str
(
key_value_dict
[
str_to_byte
(
"lastLoadTime"
)]))
tmp_time
=
datetime
.
strptime
(
last_load_time_tmp
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
...
...
@@ -206,7 +206,7 @@ class TruckInfo(WalkManage):
# print("相对last_load_time", self.relative_last_load_time[item])
self
.
logger
.
info
(
"相对last_load_time"
)
self
.
logger
.
info
(
self
.
relative_last_load_time
[
item
])
if
task
in
empty_task_set
:
if
task
in
[
0
,
1
,
2
]:
# 矿卡空载行驶或仍未出场
if
str_to_byte
(
"lastUnloadTime"
)
in
key_value_dict
.
keys
():
last_unload_time_tmp
=
eval
(
key_value_dict
[
str_to_byte
(
"lastUnloadTime"
)])
tmp_time
=
datetime
.
strptime
(
last_unload_time_tmp
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
...
...
@@ -277,7 +277,7 @@ class TruckInfo(WalkManage):
try
:
# 若矿卡状态为空运
if
task
in
empty_task_set
:
if
task
in
[
0
,
1
,
2
]:
# 矿卡空载或仍未出装载区
last_unload_time
=
self
.
relative_last_unload_time
[
self
.
truck_index_to_uuid_dict
[
i
]
]
...
...
@@ -312,7 +312,7 @@ class TruckInfo(WalkManage):
# # 目的地矿卡数加一
# self.excavator_hold_truck_num[end_eqp_index] = self.excavator_hold_truck_num[end_eqp_index] + 1
# 若矿卡状态为重载
elif
task
in
heavy_task_set
:
elif
task
in
[
3
,
4
,
5
]:
# 矿卡重载或仍未出卸载区
# print("读取重载行程")
# print(item.exactor_id, item.dump_id)
last_load_time
=
self
.
relative_last_load_time
[
...
...
@@ -383,7 +383,7 @@ class TruckInfo(WalkManage):
.
filter_by
(
truck_id
=
truck_id
,
isdeleted
=
0
)
.
first
()
)
if
task
in
empty_task_set
+
heavy_task_set
and
item
is
None
:
if
task
in
empty_task_set
+
heavy_task_set
and
item
is
None
:
# 矿卡处于正常工作状态, 但查询不到派车计划
raise
Exception
(
f
"矿卡 {truck_id} 配对关系异常"
)
except
Exception
as
es
:
self
.
logger
.
error
(
"配对关系异常"
)
...
...
group_control/group_control.py
View file @
9b576902
...
...
@@ -119,11 +119,11 @@ class Group(WalkManage):
end_area_index
=
truck_current_trip
[
i
][
1
]
start_area_index
=
truck_current_trip
[
i
][
0
]
if
task
in
heavy_task_set
:
if
task
in
[
3
,
4
]:
# 矿卡空载或正在入场装载区
self
.
goto_dump_truck_num
[
start_area_index
][
end_area_index
]
+=
1
self
.
actual_goto_dump_traffic_flow
[
start_area_index
][
end_area_index
]
+=
float
(
payload
[
i
])
if
task
in
empty_task_set
:
if
task
in
[
0
,
1
]:
# 矿卡重载或正在入场卸载区
self
.
goto_excavator_truck_num
[
start_area_index
][
end_area_index
]
+=
1
self
.
actual_goto_excavator_traffic_flow
[
start_area_index
][
end_area_index
]
+=
float
(
payload
[
i
])
...
...
path_plan/path_plannner.py
View file @
9b576902
...
...
@@ -349,45 +349,45 @@ class LaneInfo:
# used lane, 存在行驶矿卡的路段
tmp_lane_set
=
[]
#
try:
# 初始化
for
lane_id
in
lane_set
:
self
.
lane_speed_dict
[
str
(
lane_id
)]
=
0
lane_trucks_dict
[
str
(
lane_id
)]
=
0
# 对于各路段信息
print
(
"truck_locate_dict"
)
print
(
truck_locate_dict
.
keys
())
for
truck
in
truck_locate_dict
.
keys
():
lane_id
=
truck_locate_dict
[
truck
]
logger
.
info
(
"lane_speed_generate-lane_id"
)
logger
.
info
(
lane_id
)
if
lane_id
in
lane_set
and
truck
in
truck_speed_dict
and
truck
in
truck_locate_dict
:
self
.
lane_speed_dict
[
truck_locate_dict
[
truck
]]
=
self
.
lane_speed_dict
[
truck_locate_dict
[
truck
]]
+
\
truck_speed_dict
[
truck
]
# 该路段矿卡数量加一
lane_trucks_dict
[
truck_locate_dict
[
truck
]]
=
lane_trucks_dict
[
truck_locate_dict
[
truck
]]
+
1
# 记录存在行驶矿卡的路段
tmp_lane_set
.
append
(
lane_id
)
# 存在矿卡的路段
logger
.
info
(
"存在矿卡的路段:"
)
logger
.
info
(
tmp_lane_set
)
# 对不存在的矿卡路段,实时速度设置为最高
for
lane_id
in
lane_set
:
if
lane_id
not
in
tmp_lane_set
:
self
.
lane_speed_dict
[
str
(
lane_id
)]
=
session_postgre
.
query
(
Lane
)
.
filter_by
(
Id
=
lane_id
)
.
first
()
.
MaxSpeed
lane_trucks_dict
[
str
(
lane_id
)]
=
1
# 各路段实时速度取平均
for
lane
in
lane_trucks_dict
:
self
.
lane_speed_dict
[
lane
]
=
self
.
lane_speed_dict
[
lane
]
/
lane_trucks_dict
[
lane
]
try
:
# 初始化
for
lane_id
in
lane_set
:
self
.
lane_speed_dict
[
str
(
lane_id
)]
=
0
lane_trucks_dict
[
str
(
lane_id
)]
=
0
# 对于各路段信息
print
(
"truck_locate_dict"
)
print
(
truck_locate_dict
.
keys
())
for
truck
in
truck_locate_dict
.
keys
():
lane_id
=
truck_locate_dict
[
truck
]
logger
.
info
(
"lane_speed_generate-lane_id"
)
logger
.
info
(
lane_id
)
if
lane_id
in
lane_set
and
truck
in
truck_speed_dict
and
truck
in
truck_locate_dict
:
self
.
lane_speed_dict
[
truck_locate_dict
[
truck
]]
=
self
.
lane_speed_dict
[
truck_locate_dict
[
truck
]]
+
\
truck_speed_dict
[
truck
]
# 该路段矿卡数量加一
lane_trucks_dict
[
truck_locate_dict
[
truck
]]
=
lane_trucks_dict
[
truck_locate_dict
[
truck
]]
+
1
# 记录存在行驶矿卡的路段
tmp_lane_set
.
append
(
lane_id
)
# 存在矿卡的路段
logger
.
info
(
"存在矿卡的路段:"
)
logger
.
info
(
tmp_lane_set
)
# 对不存在的矿卡路段,实时速度设置为最高
for
lane_id
in
lane_set
:
if
lane_id
not
in
tmp_lane_set
:
self
.
lane_speed_dict
[
str
(
lane_id
)]
=
session_postgre
.
query
(
Lane
)
.
filter_by
(
Id
=
lane_id
)
.
first
()
.
MaxSpeed
lane_trucks_dict
[
str
(
lane_id
)]
=
1
# 各路段实时速度取平均
for
lane
in
lane_trucks_dict
:
self
.
lane_speed_dict
[
lane
]
=
self
.
lane_speed_dict
[
lane
]
/
lane_trucks_dict
[
lane
]
#
except Exception as es:
#
logger.error("路段实时速度计算异常")
#
logger.error(es)
except
Exception
as
es
:
logger
.
error
(
"路段实时速度计算异常"
)
logger
.
error
(
es
)
return
self
.
lane_speed_dict
...
...
path_plan/priority_control_2.py
deleted
100644 → 0
View file @
2cd49cca
#!E:\Pycharm Projects\Waytous
# -*- coding: utf-8 -*-
# @Time : 2021/9/3 14:44
# @Author : Opfer
# @Site :
# @File : priority_control.py
# @Software: PyCharm
from
equipment.truck
import
*
from
equipment.dump
import
*
from
equipment.excavator
import
*
from
para_config
import
*
from
path_plan.topo_graph
import
*
class
PriorityController
():
def
__init__
(
self
,
dump
,
excavator
,
truck
):
# 设备类
self
.
dump
=
dump
self
.
excavator
=
excavator
self
.
truck
=
truck
# 获取日志器
self
.
logger
=
get_logger
(
"zxt.prio"
)
def
weighted_walk_calc
(
self
):
"""
计算运输路线权重, 权重影响因素:设备优先级, 物料优先级,
:return:
walk_weight: 卸载-装载区 路网权重
park_walk_weight: 备停区-装载区 路网权重
"""
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
dynamic_excavator_num
=
get_value
(
"dynamic_excavator_num"
)
dynamic_dump_set
=
get_value
(
"dynamic_dump_set"
)
dynamic_excavator_set
=
get_value
(
"dynamic_excavator_set"
)
walk_to_excavator_weight
=
np
.
ones
((
dynamic_dump_num
,
dynamic_excavator_num
))
walk_to_dump_weight
=
np
.
ones
((
dynamic_excavator_num
,
dynamic_dump_num
))
excavator_priority
=
self
.
excavator
.
excavator_priority_coefficient
excavator_material_priority
=
self
.
excavator
.
excavator_material_priority
dump_priority
=
self
.
dump
.
dump_priority_coefficient
dump_material_priority
=
np
.
ones
(
dynamic_dump_num
)
park_walk_weight
=
np
.
ones
((
park_num
,
dynamic_excavator_num
))
rule6
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
6
)
.
first
()
if
not
rule6
.
disabled
:
for
dump_id
in
dynamic_dump_set
:
for
excavator_id
in
dynamic_excavator_set
:
dump_index
=
self
.
dump
.
dump_uuid_to_index_dict
[
dump_id
]
excavator_inedx
=
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
walk_to_excavator_weight
[
dump_index
][
excavator_inedx
]
+=
excavator_priority
[
excavator_inedx
]
walk_to_dump_weight
[
excavator_inedx
][
dump_index
]
+=
dump_priority
[
dump_index
]
park_walk_weight
=
park_walk_weight
*
self
.
excavator
.
excavator_priority_coefficient
rule7
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
7
)
.
first
()
if
not
rule7
.
disabled
:
for
dump_id
in
dynamic_dump_set
:
for
excavator_id
in
dynamic_excavator_set
:
dump_index
=
self
.
dump
.
dump_uuid_to_index_dict
[
dump_id
]
excavator_inedx
=
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
walk_to_excavator_weight
[
dump_index
][
excavator_inedx
]
+=
excavator_material_priority
[
excavator_inedx
]
walk_to_dump_weight
[
excavator_inedx
][
dump_index
]
+=
dump_material_priority
[
dump_index
]
park_walk_weight
=
park_walk_weight
*
self
.
excavator
.
excavator_material_priority
try
:
walk_to_excavator_weight
=
walk_to_excavator_weight
-
(
walk_to_excavator_weight
.
min
()
-
1
)
walk_to_dump_weight
=
walk_to_dump_weight
-
(
walk_to_dump_weight
.
min
()
-
1
)
park_walk_weight
=
park_walk_weight
-
(
park_walk_weight
.
min
()
-
1
)
except
Exception
as
es
:
self
.
logger
.
errro
(
es
)
self
.
logger
.
error
(
"优先级归一化异常"
)
return
walk_to_excavator_weight
,
walk_to_dump_weight
,
park_walk_weight
def
walk_available_calc
(
self
):
"""
计算路网可通行性(物料, 地图, 分组三者综合)
:return:
walk_available: 路网可通行性(dump_num, excavator_num)
"""
map_walk_available
=
self
.
update_map_walk_available
()
group_walk_available
=
self
.
update_group_walk_available
()
material_walk_available
=
self
.
update_material_walk_available
()
walk_available
=
map_walk_available
*
group_walk_available
*
material_walk_available
return
walk_available
def
update_group_walk_available
(
self
):
"""
计算调度分组间的路网可通行性, 不同分组间路网不可通行
:return:
group_walk_available: 调度分组路网可通行性矩阵(dump_num, excavator_num)
"""
group_walk_available
=
np
.
zeros
((
get_value
(
"dynamic_dump_num"
),
get_value
(
"dynamic_excavator_num"
)))
for
dump_id
in
get_value
(
"dynamic_dump_set"
):
for
excavator_id
in
get_value
(
"dynamic_excavator_set"
):
item
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
,
exactor_id
=
excavator_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
if
item
is
not
None
:
dump_index
=
self
.
dump
.
dump_uuid_to_index_dict
[
dump_id
]
excavator_index
=
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
group_walk_available
[
dump_index
][
excavator_index
]
=
1
return
group_walk_available
def
update_material_walk_available
(
self
):
"""
更新物料兼容性下路网可通行性
:return:
walk_available: 物料兼容路网可通行性矩阵(dump_num, excavator_num)
"""
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
dynamic_excavator_num
=
get_value
(
"dynamic_excavator_num"
)
dynamic_dump_set
=
get_value
(
"dynamic_dump_set"
)
dynamic_excavator_set
=
get_value
(
"dynamic_excavator_set"
)
walk_available
=
np
.
ones
((
dynamic_dump_num
,
dynamic_excavator_num
))
try
:
for
dump_id
in
dynamic_dump_set
:
for
excavator_id
in
dynamic_excavator_set
:
dump_index
=
self
.
dump
.
dump_uuid_to_index_dict
[
dump_id
]
excavator_inedx
=
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
# 两设备处理物料不同, 相关路网不可通行
if
self
.
excavator
.
excavator_material
[
excavator_id
]
!=
self
.
dump
.
dump_material
[
dump_id
]:
walk_available
[
dump_index
][
excavator_inedx
]
=
0
except
Exception
as
es
:
self
.
logger
.
info
(
es
)
self
.
logger
.
info
(
"error-12"
)
return
walk_available
def
update_map_walk_available
(
self
):
"""
更新物理路网可通行性
:return:
walk_available: 物理路网可通行性矩阵(dump_num, excavator_num)
"""
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
dynamic_excavator_num
=
get_value
(
"dynamic_excavator_num"
)
walk_available
=
np
.
ones
((
dynamic_dump_num
,
dynamic_excavator_num
))
walk_manage
.
period_walk_para_update
()
for
dump_index
in
range
(
dynamic_dump_num
):
for
excavator_index
in
range
(
dynamic_excavator_num
):
if
walk_manage
.
distance_to_excavator
[
dump_index
][
excavator_index
]
>
M
/
2
:
walk_available
[
dump_index
][
excavator_index
]
=
0
return
walk_available
realtime_dispatch.py
View file @
9b576902
...
...
@@ -19,42 +19,42 @@ from dispatcher import Dispatcher, PreSchedule
def
process
(
dispatcher
):
#
try:
# 更新周期参数
logger
.
info
(
"#####################################周期更新开始#####################################"
)
try
:
# 更新周期参数
logger
.
info
(
"#####################################周期更新开始#####################################"
)
if
get_value
(
"dynamic_dump_num"
)
*
get_value
(
"dynamic_excavator_num"
)
==
0
:
raise
Exception
(
"无动态派车计划可用"
)
return
if
get_value
(
"dynamic_truck_num"
)
==
0
:
raise
Exception
(
"无动态派车可用矿卡"
)
return
if
get_value
(
"dynamic_dump_num"
)
*
get_value
(
"dynamic_excavator_num"
)
==
0
:
raise
Exception
(
"无动态派车计划可用"
)
return
if
get_value
(
"dynamic_truck_num"
)
==
0
:
raise
Exception
(
"无动态派车可用矿卡"
)
return
# 清空数据库缓存
session_mysql
.
commit
()
session_mysql
.
flush
()
# 清空数据库缓存
session_mysql
.
commit
()
session_mysql
.
flush
()
# 清空数据库缓存
session_postgre
.
commit
()
session_postgre
.
flush
()
# 清空数据库缓存
session_postgre
.
commit
()
session_postgre
.
flush
()
# 周期更新
dispatcher
.
dispatcher_period_update
()
# 周期更新
dispatcher
.
dispatcher_period_update
()
# try:
# try:
# 调度计算
dispatcher
.
schedule_construct
()
# 调度计算
dispatcher
.
schedule_construct
()
# except Exception as es:
# logger.error("更新不及时")
# logger.error(es)
# except Exception as es:
# logger.error("更新不及时")
# logger.error(es)
logger
.
info
(
"#####################################周期更新结束#####################################"
)
logger
.
info
(
"#####################################周期更新结束#####################################"
)
#
except Exception as es:
#
logger.error("最外层异常捕获")
#
logger.error(es)
except
Exception
as
es
:
logger
.
error
(
"最外层异常捕获"
)
logger
.
error
(
es
)
def
perform
(
inc
,
dispatcher
):
...
...
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