Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
integrated-scheduling
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
0
Merge Requests
0
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
Commits
1529bf4c
Commit
1529bf4c
authored
Oct 11, 2021
by
Allvey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复派车计划变动BUG
parent
d950f451
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
404 additions
and
330 deletions
+404
-330
dump.py
equipment/dump.py
+24
-9
excavator.py
equipment/excavator.py
+35
-6
truck.py
equipment/truck.py
+44
-39
para_config.py
para_config.py
+59
-1
path_plannner.py
path_plan/path_plannner.py
+19
-15
priority_control.py
path_plan/priority_control.py
+12
-4
realtime_dispatch.py
realtime_dispatch.py
+193
-250
settings.py
settings.py
+4
-4
traffic_flow_info.py
traffic_flow/traffic_flow_info.py
+14
-2
No files found.
equipment/dump.py
View file @
1529bf4c
...
@@ -14,9 +14,9 @@ from settings import *
...
@@ -14,9 +14,9 @@ from settings import *
class
DumpInfo
(
WalkManage
):
class
DumpInfo
(
WalkManage
):
def
__init__
(
self
):
def
__init__
(
self
):
# 卸载设备数量
# 卸载设备数量
self
.
dynamic_dump_num
=
len
(
dynamic_dump_set
)
self
.
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
# 用于动态调度的卸载设备集合
# 用于动态调度的卸载设备集合
self
.
dynamic_dump_set
=
[]
self
.
dynamic_dump_set
=
get_value
(
"dynamic_dump_set"
)
# 开始时间
# 开始时间
self
.
start_time
=
datetime
.
now
()
self
.
start_time
=
datetime
.
now
()
# 卸载时间
# 卸载时间
...
@@ -115,17 +115,18 @@ class DumpInfo(WalkManage):
...
@@ -115,17 +115,18 @@ class DumpInfo(WalkManage):
def
update_dump_material
(
self
):
def
update_dump_material
(
self
):
self
.
dump_material
=
{}
self
.
dump_material
=
{}
for
dump_id
in
dynamic_dump_set
:
for
dump_id
in
self
.
dynamic_dump_set
:
try
:
try
:
unload_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
.
unload_area_id
unload_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
.
unload_area_id
dump_material_id
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
Material
dump_material_id
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
Material
self
.
dump_material
[
dump_id
]
=
dump_material_id
self
.
dump_material
[
dump_id
]
=
dump_material_id
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
error
(
"无动态派车计划可用"
)
logger
.
error
(
"无动态派车计划可用"
)
logger
.
error
(
es
)
def
update_dump_priority
(
self
):
def
update_dump_priority
(
self
):
self
.
dump_priority_coefficient
=
np
.
ones
(
self
.
dynamic_dump_num
)
self
.
dump_priority_coefficient
=
np
.
ones
(
self
.
dynamic_dump_num
)
for
dump_id
in
dynamic_dump_set
:
for
dump_id
in
self
.
dynamic_dump_set
:
try
:
try
:
unload_area_index
=
self
.
dump_index_to_unload_area_index_dict
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
unload_area_index
=
self
.
dump_index_to_unload_area_index_dict
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
unload_area_id
=
unload_area_index_to_uuid_dict
[
unload_area_index
]
unload_area_id
=
unload_area_index_to_uuid_dict
[
unload_area_index
]
...
@@ -133,9 +134,28 @@ class DumpInfo(WalkManage):
...
@@ -133,9 +134,28 @@ class DumpInfo(WalkManage):
self
.
dump_priority_coefficient
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
item
.
Priority
self
.
dump_priority_coefficient
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
item
.
Priority
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
error
(
"无动态派车计划可用"
)
logger
.
error
(
"无动态派车计划可用"
)
logger
.
error
(
es
)
def
reset
(
self
):
# 卸载设备数量
self
.
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
# 用于动态调度的卸载设备集合
self
.
dynamic_dump_set
=
get_value
(
"dynamic_dump_set"
)
# 卸载时间
self
.
unloading_time
=
np
.
zeros
(
self
.
dynamic_dump_num
)
# 入场时间
self
.
entrance_time
=
np
.
zeros
(
self
.
dynamic_dump_num
)
# 出场时间
self
.
exit_time
=
np
.
zeros
(
self
.
dynamic_dump_num
)
# 卸载点物料类型
self
.
dump_material
=
{}
# 卸点优先级
self
.
dump_priority_coefficient
=
np
.
ones
(
self
.
dynamic_dump_num
)
def
para_period_update
(
self
):
def
para_period_update
(
self
):
self
.
reset
()
# print("Dump update!")
# print("Dump update!")
logger
.
info
(
"Dump update!"
)
logger
.
info
(
"Dump update!"
)
...
@@ -145,11 +165,6 @@ class DumpInfo(WalkManage):
...
@@ -145,11 +165,6 @@ class DumpInfo(WalkManage):
self
.
period_walk_para_load
()
self
.
period_walk_para_load
()
# 用于动态调度的卸载设备
self
.
dynamic_dump_set
=
set
(
update_autodisp_dump
())
self
.
dynamic_dump_num
=
len
(
self
.
dynamic_dump_set
)
# 计算平均卸载时间
# 计算平均卸载时间
self
.
update_dump_unloadtime
()
self
.
update_dump_unloadtime
()
...
...
equipment/excavator.py
View file @
1529bf4c
...
@@ -77,6 +77,8 @@ class ExcavatorInfo(WalkManage):
...
@@ -77,6 +77,8 @@ class ExcavatorInfo(WalkManage):
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
error
(
f
"挖机 {excavator_id} 装载时间信息缺失, 已设为默认值(1min)"
)
logger
.
error
(
f
"挖机 {excavator_id} 装载时间信息缺失, 已设为默认值(1min)"
)
logger
.
error
(
es
)
logger
.
error
(
es
)
print
(
"loading_time"
,
self
.
loading_time
)
print
(
"excavator_uuid_to_index_dict"
,
self
.
excavator_uuid_to_index_dict
)
self
.
loading_time
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5.00
self
.
loading_time
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5.00
# 更新挖机设备出入时间
# 更新挖机设备出入时间
...
@@ -122,17 +124,23 @@ class ExcavatorInfo(WalkManage):
...
@@ -122,17 +124,23 @@ class ExcavatorInfo(WalkManage):
return
loading_task_time
return
loading_task_time
def
update_excavator_material
(
self
):
def
update_excavator_material
(
self
):
for
excavator_id
in
dynamic_excavator_set
:
print
(
"here"
,
self
.
dynamic_excavator_set
)
load_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator_id
,
isdeleted
=
0
,
isauto
=
1
)
.
first
()
.
load_area_id
for
excavator_id
in
self
.
dynamic_excavator_set
:
excavator_material_id
=
session_postgre
.
query
(
DiggingWorkArea
)
.
filter_by
(
Id
=
load_area_id
)
.
first
()
.
Material
try
:
self
.
excavator_material
[
excavator_id
]
=
excavator_material_id
load_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator_id
,
isdeleted
=
0
,
isauto
=
1
)
.
first
()
.
load_area_id
excavator_material_id
=
session_postgre
.
query
(
DiggingWorkArea
)
.
filter_by
(
Id
=
load_area_id
)
.
first
()
.
Material
self
.
excavator_material
[
excavator_id
]
=
excavator_material_id
except
Exception
as
es
:
logger
.
warning
(
es
)
def
update_excavator_priority
(
self
):
def
update_excavator_priority
(
self
):
self
.
excavator_material_priority
=
np
.
ones
(
dynamic_excavator_num
)
print
(
"dynamic_excavator_set"
,
self
.
dynamic_excavator_set
)
for
excavator_id
in
dynamic_excavator_set
:
for
excavator_id
in
self
.
dynamic_excavator_set
:
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
excavator_id
)
.
first
()
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
excavator_id
)
.
first
()
print
(
"excavator_priority_coefficient"
,
self
.
excavator_priority_coefficient
)
print
(
self
.
excavator_uuid_to_index_dict
)
self
.
excavator_priority_coefficient
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
item
.
priority
+
1
self
.
excavator_priority_coefficient
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
item
.
priority
+
1
# 物料优先级控制
# 物料优先级控制
...
@@ -149,9 +157,30 @@ class ExcavatorInfo(WalkManage):
...
@@ -149,9 +157,30 @@ class ExcavatorInfo(WalkManage):
if
self
.
excavator_material
[
excavator_id
]
==
'c481794b-6ced-45b9-a9c4-c4a388f44418'
:
if
self
.
excavator_material
[
excavator_id
]
==
'c481794b-6ced-45b9-a9c4-c4a388f44418'
:
self
.
excavator_material_priority
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5
self
.
excavator_material_priority
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5
def
reset
(
self
):
# 装载设备数量
self
.
dynamic_excavator_num
=
get_value
(
"dynamic_excavator_num"
)
# 用于动态调度的卸载设备集合
self
.
dynamic_excavator_set
=
get_value
(
"dynamic_excavator_set"
)
# 装载时间
self
.
loading_time
=
np
.
zeros
(
self
.
dynamic_excavator_num
)
# 入场时间
self
.
entrance_time
=
np
.
zeros
(
self
.
dynamic_excavator_num
)
# 出场时间
self
.
exit_time
=
np
.
zeros
(
self
.
dynamic_excavator_num
)
# 挖机对应物料类型
self
.
excavator_material
=
{}
# 挖机设备优先级
self
.
excavator_priority_coefficient
=
np
.
ones
(
self
.
dynamic_excavator_num
)
# 挖机物料优先级
self
.
excavator_material_priority
=
np
.
ones
(
self
.
dynamic_excavator_num
)
def
para_period_update
(
self
):
def
para_period_update
(
self
):
self
.
reset
()
logger
.
info
(
"Excavator update!"
)
logger
.
info
(
"Excavator update!"
)
# 装载周期参数
# 装载周期参数
...
...
equipment/truck.py
View file @
1529bf4c
...
@@ -66,7 +66,8 @@ class TruckInfo(WalkManage):
...
@@ -66,7 +66,8 @@ class TruckInfo(WalkManage):
self
.
truck_material_bind
=
{}
self
.
truck_material_bind
=
{}
# 矿卡绑定物料modify
# 矿卡绑定物料modify
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_dump_num
),
0
)
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_dump_num
),
0
)
self
.
excavator_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
# self.excavator_material_bind_modify =np.zeros(self.dynamic_truck_num)
self
.
excavator_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
# 初始化读取映射及路网
# 初始化读取映射及路网
self
.
period_map_para_load
()
self
.
period_map_para_load
()
self
.
period_walk_para_load
()
self
.
period_walk_para_load
()
...
@@ -289,33 +290,34 @@ class TruckInfo(WalkManage):
...
@@ -289,33 +290,34 @@ class TruckInfo(WalkManage):
# 更新矿卡实际容量
# 更新矿卡实际容量
def
update_truck_payload
(
self
):
def
update_truck_payload
(
self
):
try
:
self
.
payload
=
np
.
full
(
self
.
dynamic_truck_num
,
220
);
self
.
payload
=
np
.
zeros
(
self
.
dynamic_truck_num
)
# try:
for
truck_id
in
self
.
dynamic_truck_set
:
# self.payload = np.zeros(self.dynamic_truck_num)
trcuk_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
# for truck_id in self.dynamic_truck_set:
truck_spec
=
(
# trcuk_index = self.truck_uuid_to_index_dict[truck_id]
session_mysql
.
query
(
Equipment
)
# truck_spec = (
.
filter_by
(
id
=
truck_id
)
# session_mysql.query(Equipment)
.
first
()
# .filter_by(id=truck_id)
.
equipment_spec
# .first()
)
# .equipment_spec
# truck_spec = query.equipment_spec
# )
self
.
payload
[
trcuk_index
]
=
(
# # truck_spec = query.equipment_spec
session_mysql
.
query
(
EquipmentSpec
)
# self.payload[trcuk_index] = (
.
filter_by
(
id
=
truck_spec
)
# session_mysql.query(EquipmentSpec)
.
first
()
# .filter_by(id=truck_spec)
.
capacity
# .first()
)
# .capacity
except
Exception
as
es
:
# )
logger
.
error
(
"读取矿卡有效载重异常-矿卡型号信息缺失"
)
# except Exception as es:
logger
.
error
(
es
)
# logger.error("读取矿卡有效载重异常-矿卡型号信息缺失")
# logger.error(es)
def
update_truck_priority
(
self
):
def
update_truck_priority
(
self
):
self
.
truck_priority
=
np
.
full
(
self
.
dynamic_truck_num
,
0
)
self
.
truck_priority
=
np
.
full
(
self
.
dynamic_truck_num
,
0
)
rule6
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
6
)
.
first
()
rule6
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
6
)
.
first
()
if
rule6
.
disabled
==
0
:
if
rule6
.
disabled
==
0
:
for
truck_id
in
dynamic_truck_set
:
for
truck_id
in
self
.
dynamic_truck_set
:
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
truck_id
)
.
first
()
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
truck_id
)
.
first
()
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
if
item
.
priority
==
0
:
if
item
.
priority
==
0
:
...
@@ -347,7 +349,7 @@ class TruckInfo(WalkManage):
...
@@ -347,7 +349,7 @@ class TruckInfo(WalkManage):
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
if
rule5
.
disabled
==
0
:
if
rule5
.
disabled
==
0
:
self
.
truck_excavator_bind
=
{}
self
.
truck_excavator_bind
=
{}
for
excavator_id
in
dynamic_excavator_set
:
for
excavator_id
in
get_value
(
"dynamic_excavator_set"
)
:
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
excavator_id
)
.
first
()
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
excavator_id
)
.
first
()
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
):
...
@@ -369,14 +371,14 @@ class TruckInfo(WalkManage):
...
@@ -369,14 +371,14 @@ class TruckInfo(WalkManage):
try
:
try
:
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
if
rule5
.
disabled
==
0
:
if
rule5
.
disabled
==
0
:
for
excavator_id
in
dynamic_excavator_set
:
for
excavator_id
in
get_value
(
"dynamic_excavator_set"
)
:
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
()
)
)
if
item
is
not
None
:
if
item
is
not
None
:
for
truck_id
in
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
self
.
truck_excavator_exclude
[
truck_id
]
=
excavator_id
self
.
excavator_exclude_modify
[
self
.
excavator_exclude_modify
[
...
@@ -393,17 +395,14 @@ class TruckInfo(WalkManage):
...
@@ -393,17 +395,14 @@ class TruckInfo(WalkManage):
def
update_truck_material
(
self
):
def
update_truck_material
(
self
):
excavator
.
update_excavator_material
()
dump
.
update_dump_material
()
self
.
truck_material_bind
=
{}
self
.
truck_material_bind
=
{}
self
.
update_truck_excavator_bind
()
self
.
update_truck_excavator_bind
()
self
.
update_truck_dump_area_bind
()
self
.
update_truck_dump_area_bind
()
self
.
excavator_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
self
.
excavator_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
get_value
(
"dynamic_excavator_num"
)
),
0
)
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_dump_num
),
0
)
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
get_value
(
"dynamic_dump_num"
)
),
0
)
for
truck_id
in
dynamic_truck_set
:
for
truck_id
in
self
.
dynamic_truck_set
:
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
...
@@ -418,40 +417,42 @@ class TruckInfo(WalkManage):
...
@@ -418,40 +417,42 @@ class TruckInfo(WalkManage):
excavator_material_id
=
excavator
.
excavator_material
[
excavator_id
]
excavator_material_id
=
excavator
.
excavator_material
[
excavator_id
]
self
.
truck_material_bind
[
truck_id
]
=
excavator_material_id
self
.
truck_material_bind
[
truck_id
]
=
excavator_material_id
for
truck_id
in
self
.
dynamic_truck_set
:
for
truck_id
in
dynamic_truck_set
:
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
print
(
"excavator_material_bind_modify"
,
self
.
excavator_material_bind_modify
)
if
truck_id
in
self
.
truck_material_bind
:
if
truck_id
in
self
.
truck_material_bind
:
material
=
self
.
truck_material_bind
[
truck_id
]
material
=
self
.
truck_material_bind
[
truck_id
]
for
excavator_id
in
dynamic_excavator_set
:
for
excavator_id
in
get_value
(
"dynamic_excavator_set"
)
:
excavator_material_id
=
excavator
.
excavator_material
[
excavator_id
]
excavator_material_id
=
excavator
.
excavator_material
[
excavator_id
]
excavator_index
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
excavator_index
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
print
(
truck_index
,
excavator_index
)
if
excavator_material_id
!=
material
:
if
excavator_material_id
!=
material
:
self
.
excavator_material_bind_modify
[
truck_index
][
excavator_index
]
=
1000000
self
.
excavator_material_bind_modify
[
truck_index
][
excavator_index
]
=
1000000
for
dump_id
in
dynamic_dump_set
:
for
dump_id
in
get_value
(
"dynamic_dump_set"
)
:
dump_material_id
=
dump
.
dump_material
[
dump_id
]
dump_material_id
=
dump
.
dump_material
[
dump_id
]
dump_index
=
dump
.
dump_uuid_to_index_dict
[
dump_id
]
dump_index
=
dump
.
dump_uuid_to_index_dict
[
dump_id
]
if
dump_material_id
!=
material
:
if
dump_material_id
!=
material
:
self
.
dump_material_bind_modify
[
truck_index
][
dump_index
]
=
1000000
self
.
dump_material_bind_modify
[
truck_index
][
dump_index
]
=
1000000
def
update_truck_spec
(
self
):
def
update_truck_spec
(
self
):
for
truck_id
in
dynamic_truck_set
:
for
truck_id
in
self
.
dynamic_truck_set
:
self
.
size
[
truck_id
]
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
truck_id
)
.
first
()
.
equipment_spec
self
.
size
[
truck_id
]
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
truck_id
)
.
first
()
.
equipment_spec
def
update_truck_size
(
self
):
def
update_truck_size
(
self
):
self
.
update_truck_spec
()
self
.
update_truck_spec
()
for
truck_id
in
dynamic_truck_set
:
for
truck_id
in
self
.
dynamic_truck_set
:
truck_spec_id
=
self
.
size
[
truck_id
]
truck_spec_id
=
self
.
size
[
truck_id
]
self
.
geo_length
[
truck_id
]
=
session_mysql
.
query
(
EquipmentSpec
)
.
filter_by
(
id
=
truck_spec_id
)
.
first
()
.
length
self
.
geo_length
[
truck_id
]
=
session_mysql
.
query
(
EquipmentSpec
)
.
filter_by
(
id
=
truck_spec_id
)
.
first
()
.
length
self
.
geo_width
[
truck_spec_id
]
=
session_mysql
.
query
(
EquipmentSpec
)
.
filter_by
(
id
=
truck_spec_id
)
.
first
()
.
width
self
.
geo_width
[
truck_spec_id
]
=
session_mysql
.
query
(
EquipmentSpec
)
.
filter_by
(
id
=
truck_spec_id
)
.
first
()
.
width
def
update_truck_speed
(
self
):
def
update_truck_speed
(
self
):
for
truck_id
in
dynamic_truck_set
:
for
truck_id
in
self
.
dynamic_truck_set
:
self
.
empty_speed
[
truck_id
]
=
session_mysql
.
query
(
EquipmentSpec
)
.
\
self
.
empty_speed
[
truck_id
]
=
session_mysql
.
query
(
EquipmentSpec
)
.
\
join
(
Equipment
,
EquipmentSpec
.
id
==
Equipment
.
equipment_spec
)
.
\
join
(
Equipment
,
EquipmentSpec
.
id
==
Equipment
.
equipment_spec
)
.
\
filter
(
Equipment
.
id
==
truck_id
)
.
first
()
.
max_speed
filter
(
Equipment
.
id
==
truck_id
)
.
first
()
.
max_speed
...
@@ -480,10 +481,14 @@ class TruckInfo(WalkManage):
...
@@ -480,10 +481,14 @@ class TruckInfo(WalkManage):
self
.
truck_material_bind
=
{}
self
.
truck_material_bind
=
{}
# 矿卡绑定物料modify
# 矿卡绑定物料modify
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
self
.
excavator_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
# self.excavator_material_bind_modify =np.zeros(self.dynamic_truck_num)
self
.
excavator_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
def
para_period_update
(
self
):
def
para_period_update
(
self
):
excavator
.
para_period_update
()
dump
.
para_period_update
()
# 初始化参数
# 初始化参数
self
.
reset
()
self
.
reset
()
...
...
para_config.py
View file @
1529bf4c
...
@@ -144,7 +144,24 @@ class DeviceMap:
...
@@ -144,7 +144,24 @@ class DeviceMap:
def
get_truck_index_to_uuid_dict
(
self
):
def
get_truck_index_to_uuid_dict
(
self
):
return
self
.
truck_index_to_uuid_dict
return
self
.
truck_index_to_uuid_dict
def
reset
(
self
):
self
.
excavator_uuid_to_index_dict
=
{}
self
.
dump_uuid_to_index_dict
=
{}
self
.
excavator_index_to_uuid_dict
=
{}
self
.
dump_index_to_uuid_dict
=
{}
self
.
dump_uuid_to_unload_area_uuid_dict
=
{}
self
.
excavator_uuid_to_load_area_uuid_dict
=
{}
self
.
excavator_index_to_load_area_index_dict
=
{}
self
.
dump_index_to_unload_area_index_dict
=
{}
self
.
truck_uuid_to_index_dict
=
{}
self
.
truck_index_to_uuid_dict
=
{}
def
period_map_para_update
(
self
):
def
period_map_para_update
(
self
):
self
.
reset
()
device_map_dict
=
update_deveices_map
(
device_map_dict
=
update_deveices_map
(
unload_area_uuid_to_index_dict
,
load_area_uuid_to_index_dict
unload_area_uuid_to_index_dict
,
load_area_uuid_to_index_dict
)
)
...
@@ -261,9 +278,32 @@ class WalkManage(DeviceMap):
...
@@ -261,9 +278,32 @@ class WalkManage(DeviceMap):
def
get_distance_park_to_excavator
(
self
):
def
get_distance_park_to_excavator
(
self
):
return
self
.
distance_park_to_excavator
return
self
.
distance_park_to_excavator
def
reset
(
self
):
# 路网真实距离
self
.
walk_time_to_excavator
=
np
.
full
(
(
dynamic_dump_num
,
dynamic_excavator_num
),
M
)
self
.
walk_time_to_dump
=
np
.
full
((
dynamic_dump_num
,
dynamic_excavator_num
),
M
)
self
.
walk_time_park_to_excavator
=
np
.
full
((
park_num
,
dynamic_excavator_num
),
M
)
self
.
walk_time_park_to_load_area
=
np
.
full
((
park_num
,
load_area_num
),
M
)
self
.
walk_time_to_load_area
=
np
.
full
((
unload_area_num
,
load_area_num
),
M
)
self
.
walk_time_to_unload_area
=
np
.
full
((
unload_area_num
,
load_area_num
),
M
)
# 路网行驶时间
self
.
distance_to_excavator
=
np
.
full
(
(
dynamic_dump_num
,
dynamic_excavator_num
),
M
)
self
.
distance_to_dump
=
np
.
full
((
dynamic_dump_num
,
dynamic_excavator_num
),
M
)
self
.
distance_park_to_excavator
=
np
.
full
((
park_num
,
dynamic_excavator_num
),
M
)
self
.
distance_park_to_load_area
=
np
.
full
((
park_num
,
load_area_num
),
M
)
self
.
distance_to_load_area
=
np
.
full
((
unload_area_num
,
load_area_num
),
M
)
self
.
distance_to_unload_area
=
np
.
full
((
unload_area_num
,
load_area_num
),
M
)
def
period_walk_para_update
(
self
):
def
period_walk_para_update
(
self
):
self
.
period_map_para_load
()
self
.
reset
()
self
.
period_map_para_update
()
# 计算路网距离及行走时间
# 计算路网距离及行走时间
try
:
try
:
...
@@ -364,6 +404,8 @@ walk_manage = WalkManage()
...
@@ -364,6 +404,8 @@ walk_manage = WalkManage()
device_map
.
period_map_para_update
()
device_map
.
period_map_para_update
()
walk_manage
.
period_map_para_load
()
walk_manage
.
period_walk_para_update
()
walk_manage
.
period_walk_para_update
()
...
@@ -431,6 +473,22 @@ def period_para_update():
...
@@ -431,6 +473,22 @@ def period_para_update():
global_dict
[
"dynamic_dump_set"
]
=
dynamic_dump_set
global_dict
[
"dynamic_dump_set"
]
=
dynamic_dump_set
global_dict
[
"dynamic_dump_num"
]
=
dynamic_dump_num
global_dict
[
"dynamic_dump_num"
]
=
dynamic_dump_num
global_dict
[
"distance_to_excavator"
]
=
walk_manage
.
distance_to_excavator
global_dict
[
"distance_park_to_excavator"
]
=
walk_manage
.
distance_park_to_excavator
global_dict
[
"distance_to_dump"
]
=
walk_manage
.
distance_to_dump
print
(
"walk_manage_para"
)
print
(
"distance_to_excavator"
,
walk_manage
.
distance_to_excavator
)
print
(
"distance_park_to_excavator"
,
walk_manage
.
distance_park_to_excavator
)
print
(
"distance_to_dump"
,
walk_manage
.
distance_to_dump
)
print
(
"excavator_uuid_to_index_dict"
,
walk_manage
.
excavator_uuid_to_index_dict
)
print
(
"dump_uuid_to_index_dict"
,
walk_manage
.
dump_uuid_to_index_dict
)
print
(
"here5"
,
walk_manage
.
distance_park_to_excavator
)
def
get_value
(
name
):
def
get_value
(
name
):
return
global_dict
[
name
]
return
global_dict
[
name
]
path_plan/path_plannner.py
View file @
1529bf4c
...
@@ -166,32 +166,36 @@ class PathPlanner(WalkManage):
...
@@ -166,32 +166,36 @@ class PathPlanner(WalkManage):
logger
.
error
(
'路网信息计成本计算异常'
)
logger
.
error
(
'路网信息计成本计算异常'
)
logger
.
error
(
es
)
logger
.
error
(
es
)
cost_to_excavator
=
np
.
zeros_like
(
self
.
distance_to_excavator
)
cost_to_excavator
=
np
.
zeros_like
(
get_value
(
"distance_to_excavator"
)
)
cost_to_dump
=
np
.
zeros_like
(
self
.
distance_to_dump
)
cost_to_dump
=
np
.
zeros_like
(
get_value
(
"distance_to_dump"
)
)
cost_park_to_excavator
=
np
.
zeros_like
(
self
.
distance_park_to_excavator
)
cost_park_to_excavator
=
np
.
zeros_like
(
get_value
(
"distance_park_to_excavator"
)
)
try
:
print
(
"here4"
,
self
.
distance_park_to_excavator
)
# 路网权重
walk_weight
,
park_walk_weight
=
weighted_walk_cost
()
# 路网禁用关系
# try:
walk_available
=
available_walk
()
# 路网权重
walk_weight
,
park_walk_weight
=
weighted_walk_cost
()
print
(
"path_weight"
,
walk_weight
)
# 路网禁用关系
walk_available
=
available_walk
()
print
(
"walk_avail"
,
walk_available
)
print
(
"path_weight"
,
walk_weight
)
except
Exception
as
es
:
print
(
"walk_avail"
,
walk_available
)
logger
.
error
(
"无派车计划可用"
)
# except Exception as es:
# logger.error("无派车计划可用")
for
i
in
range
(
dynamic_dump_num
):
for
i
in
range
(
get_value
(
"dynamic_dump_num"
)
):
for
j
in
range
(
dynamic_excavator_num
):
for
j
in
range
(
get_value
(
"dynamic_excavator_num"
)
):
load_area_index
=
self
.
excavator_index_to_load_area_index_dict
[
j
]
load_area_index
=
self
.
excavator_index_to_load_area_index_dict
[
j
]
unload_area_index
=
self
.
dump_index_to_unload_area_index_dict
[
i
]
unload_area_index
=
self
.
dump_index_to_unload_area_index_dict
[
i
]
print
(
"here6"
,
cost_to_excavator
)
print
(
"here7"
,
self
.
cost_to_load_area
)
cost_to_excavator
[
i
][
j
]
=
self
.
cost_to_load_area
[
unload_area_index
][
load_area_index
]
/
walk_weight
[
i
][
j
]
cost_to_excavator
[
i
][
j
]
=
self
.
cost_to_load_area
[
unload_area_index
][
load_area_index
]
/
walk_weight
[
i
][
j
]
cost_to_dump
[
i
][
j
]
=
self
.
cost_to_unload_area
[
unload_area_index
][
load_area_index
]
/
walk_weight
[
i
][
j
]
*
walk_available
[
i
][
j
]
cost_to_dump
[
i
][
j
]
=
self
.
cost_to_unload_area
[
unload_area_index
][
load_area_index
]
/
walk_weight
[
i
][
j
]
*
walk_available
[
i
][
j
]
for
j
in
range
(
dynamic_excavator_num
):
for
j
in
range
(
get_value
(
"dynamic_excavator_num"
)
):
load_area_index
=
self
.
excavator_index_to_load_area_index_dict
[
j
]
load_area_index
=
self
.
excavator_index_to_load_area_index_dict
[
j
]
cost_park_to_excavator
[
0
][
j
]
=
self
.
cost_park_to_load_area
[
0
][
load_area_index
]
/
park_walk_weight
[
0
][
j
]
cost_park_to_excavator
[
0
][
j
]
=
self
.
cost_park_to_load_area
[
0
][
load_area_index
]
/
park_walk_weight
[
0
][
j
]
...
...
path_plan/priority_control.py
View file @
1529bf4c
...
@@ -17,8 +17,12 @@ dump = DumpInfo()
...
@@ -17,8 +17,12 @@ dump = DumpInfo()
def
weighted_walk_cost
():
def
weighted_walk_cost
():
excavator
.
update_excavator_priority
()
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
dump
.
update_dump_priority
()
dynamic_excavator_num
=
get_value
(
"dynamic_excavator_num"
)
dynamic_dump_set
=
get_value
(
"dynamic_dump_set"
)
dynamic_excavator_set
=
get_value
(
"dynamic_excavator_set"
)
excavator
.
para_period_update
()
dump
.
para_period_update
()
walk_weight
=
np
.
ones
((
dynamic_dump_num
,
dynamic_excavator_num
))
walk_weight
=
np
.
ones
((
dynamic_dump_num
,
dynamic_excavator_num
))
excavator_priority
=
excavator
.
excavator_priority_coefficient
excavator_priority
=
excavator
.
excavator_priority_coefficient
excavator_material_priority
=
excavator
.
excavator_material_priority
excavator_material_priority
=
excavator
.
excavator_material_priority
...
@@ -56,8 +60,12 @@ def weighted_walk_cost():
...
@@ -56,8 +60,12 @@ def weighted_walk_cost():
def
available_walk
():
def
available_walk
():
excavator
.
update_excavator_material
()
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
dump
.
update_dump_material
()
dynamic_excavator_num
=
get_value
(
"dynamic_excavator_num"
)
dynamic_dump_set
=
get_value
(
"dynamic_dump_set"
)
dynamic_excavator_set
=
get_value
(
"dynamic_excavator_set"
)
excavator
.
para_period_update
()
dump
.
para_period_update
()
walk_weight
=
np
.
ones
((
dynamic_dump_num
,
dynamic_excavator_num
))
walk_weight
=
np
.
ones
((
dynamic_dump_num
,
dynamic_excavator_num
))
for
dump_id
in
dynamic_dump_set
:
for
dump_id
in
dynamic_dump_set
:
...
...
realtime_dispatch.py
View file @
1529bf4c
...
@@ -236,121 +236,61 @@ class Dispatcher(WalkManage):
...
@@ -236,121 +236,61 @@ class Dispatcher(WalkManage):
(
dynamic_dump_num
,
dynamic_excavator_num
)
(
dynamic_dump_num
,
dynamic_excavator_num
)
)
)
try
:
#
try:
for
i
in
range
(
dynamic_truck_num
):
for
i
in
range
(
dynamic_truck_num
):
task
=
truck_current_task
[
truck
.
truck_index_to_uuid_dict
[
i
]]
task
=
truck_current_task
[
truck
.
truck_index_to_uuid_dict
[
i
]]
end_area_index
=
truck_current_trip
[
i
][
1
]
end_area_index
=
truck_current_trip
[
i
][
1
]
start_area_index
=
truck_current_trip
[
i
][
0
]
start_area_index
=
truck_current_trip
[
i
][
0
]
if
task
in
heavy_task_set
:
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
])
#
# logger.info("debug2")
# logger.info("debug1")
# logger.info("end_area")
# logger.info(end_area_index)
# logger.info("start_area")
# logger.info(start_area_index)
if
task
in
heav
y_task_set
:
if
task
in
empt
y_task_set
:
self
.
goto_dump
_truck_num
[
start_area_index
][
end_area_index
]
+=
1
self
.
goto_excavator
_truck_num
[
start_area_index
][
end_area_index
]
+=
1
self
.
actual_goto_dump
_traffic_flow
[
start_area_index
][
end_area_index
]
+=
float
(
payload
[
i
])
self
.
actual_goto_excavator
_traffic_flow
[
start_area_index
][
end_area_index
]
+=
float
(
payload
[
i
])
# logger.info("debug2")
if
task
in
empty_task_set
:
self
.
actual_goto_dump_traffic_flow
=
self
.
actual_goto_dump_traffic_flow
/
(
self
.
goto_excavator_truck_num
[
start_area_index
][
end_area_index
]
+=
1
self
.
distance_to_dump
.
reshape
(
dynamic_excavator_num
,
dynamic_dump_num
)
self
.
actual_goto_excavator_traffic_flow
[
start_area_index
][
end_area_index
]
+=
float
(
payload
[
i
])
/
(
1000
*
empty_speed
)
+
np
.
expand_dims
(
unloading_task_time
,
axis
=
0
)
.
repeat
(
dynamic_excavator_num
,
axis
=
0
# logger.info("debug1")
# 若矿卡正常行驶,需要将该部分载重计入实时产量
# if task in heavy_task_set:
# logger.info("更新不及时debug")
# logger.info("end_area")
# logger.info(end_area_index)
# logger.info("start_area")
# logger.info(start_area_index)
#
# self.goto_dump_truck_num[end_area_index][start_area_index] = (
# self.goto_dump_truck_num[end_area_index][start_area_index] + 1
# )
# self.actual_goto_dump_traffic_flow[end_area_index][
# start_area_index
# ] = self.actual_goto_dump_traffic_flow[end_area_index][
# start_area_index
# ] + float(
# payload[i]
# )
# logger.info("debug2")
# if task in empty_task_set:
# self.goto_excavator_truck_num[start_area_index][end_area_index] = (
# self.goto_excavator_truck_num[start_area_index][end_area_index]
# + 1
# )
# self.actual_goto_excavator_traffic_flow[start_area_index][
# end_area_index
# ] = self.actual_goto_excavator_traffic_flow[start_area_index][
# end_area_index
# ] + float(
# payload[i]
# )
#
# print(np.expand_dims(unloading_time,axis=0).repeat(dynamic_excavator_num, axis=0))
# logger.info("self.goto_dump_truck_num")
# logger.info(self.goto_dump_truck_num)
#
# logger.info("self.actual_goto_dump_traffic_flow")
# logger.info(self.actual_goto_dump_traffic_flow)
#
# logger.info("self.goto_excavator_truck_num")
# logger.info(self.goto_excavator_truck_num)
#
# logger.info("self.actual_goto_excavator_traffic_flow")
# logger.info(self.actual_goto_excavator_traffic_flow)
self
.
actual_goto_dump_traffic_flow
=
self
.
actual_goto_dump_traffic_flow
/
(
self
.
distance_to_dump
.
reshape
(
dynamic_excavator_num
,
dynamic_dump_num
)
/
(
1000
*
empty_speed
)
+
np
.
expand_dims
(
unloading_task_time
,
axis
=
0
)
.
repeat
(
dynamic_excavator_num
,
axis
=
0
)
)
)
)
self
.
actual_goto_excavator_traffic_flow
=
(
self
.
actual_goto_excavator_traffic_flow
=
(
self
.
actual_goto_excavator_traffic_flow
self
.
actual_goto_excavator_traffic_flow
/
(
/
(
self
.
distance_to_excavator
.
reshape
(
self
.
distance_to_excavator
.
reshape
(
dynamic_dump_num
,
dynamic_excavator_num
dynamic_dump_num
,
dynamic_excavator_num
)
)
/
(
1000
*
heavy_speed
)
/
(
1000
*
heavy_speed
)
+
np
.
expand_dims
(
loading_task_time
,
axis
=
0
)
.
repeat
(
+
np
.
expand_dims
(
loading_task_time
,
axis
=
0
)
.
repeat
(
dynamic_dump_num
,
axis
=
0
dynamic_dump_num
,
axis
=
0
)
)
)
)
)
)
logger
.
info
(
"self.goto_dump_truck_num"
)
logger
.
info
(
"self.goto_dump_truck_num"
)
logger
.
info
(
self
.
goto_dump_truck_num
)
logger
.
info
(
self
.
goto_dump_truck_num
)
logger
.
info
(
"self.actual_goto_dump_traffic_flow"
)
logger
.
info
(
"self.actual_goto_dump_traffic_flow"
)
logger
.
info
(
self
.
actual_goto_dump_traffic_flow
)
logger
.
info
(
self
.
actual_goto_dump_traffic_flow
)
logger
.
info
(
"self.goto_excavator_truck_num"
)
logger
.
info
(
"self.goto_excavator_truck_num"
)
logger
.
info
(
self
.
goto_excavator_truck_num
)
logger
.
info
(
self
.
goto_excavator_truck_num
)
logger
.
info
(
"self.actual_goto_excavator_traffic_flow"
)
logger
.
info
(
"self.actual_goto_excavator_traffic_flow"
)
logger
.
info
(
self
.
actual_goto_excavator_traffic_flow
)
logger
.
info
(
self
.
actual_goto_excavator_traffic_flow
)
except
Exception
as
es
:
#
except Exception as es:
logger
.
error
(
"更新不及时
"
)
# logger.error("更新不及时1
")
logger
.
error
(
es
)
#
logger.error(es)
# print("驶往卸点实际载重")
# print("驶往卸点实际载重")
# print(self.actual_goto_dump_traffic_flow)
# print(self.actual_goto_dump_traffic_flow)
...
@@ -426,30 +366,30 @@ class Dispatcher(WalkManage):
...
@@ -426,30 +366,30 @@ class Dispatcher(WalkManage):
truck
.
para_period_update
()
truck
.
para_period_update
()
def
state_period_update
(
self
):
def
state_period_update
(
self
):
try
:
#
try:
truck
.
state_period_update
()
truck
.
state_period_update
()
# 更新实时车流
# 更新实时车流
self
.
update_actual_traffic_flow
()
self
.
update_actual_traffic_flow
()
# 计算理想车流
# 计算理想车流
(
self
.
opt_goto_dump_traffic_flow
,
self
.
opt_goto_excavator_traffic_flow
,)
=
traffic_flow_plan
()
(
self
.
opt_goto_dump_traffic_flow
,
self
.
opt_goto_excavator_traffic_flow
,)
=
traffic_flow_plan
()
# 矿卡抵达时间
# 矿卡抵达时间
excavator_reach_list
,
dump_reach_list
=
self
.
update_truck_reach_time
()
excavator_reach_list
,
dump_reach_list
=
self
.
update_truck_reach_time
()
# 挖机可用时间
# 挖机可用时间
self
.
update_excavator_ava_time
(
excavator_reach_list
)
self
.
update_excavator_ava_time
(
excavator_reach_list
)
# 卸载设备可用时间
# 卸载设备可用时间
self
.
update_dump_ava_time
(
dump_reach_list
)
self
.
update_dump_ava_time
(
dump_reach_list
)
self
.
cost_to_excavator
,
self
.
cost_to_dump
,
self
.
cost_park_to_excavator
=
self
.
path
.
walk_cost
()
self
.
cost_to_excavator
,
self
.
cost_to_dump
,
self
.
cost_park_to_excavator
=
self
.
path
.
walk_cost
()
except
Exception
as
es
:
#
except Exception as es:
logger
.
error
(
"周期更新异常"
)
#
logger.error("周期更新异常")
logger
.
error
(
es
)
#
logger.error(es)
def
sim_para_reset
(
self
):
def
sim_para_reset
(
self
):
...
@@ -572,6 +512,8 @@ class Dispatcher(WalkManage):
...
@@ -572,6 +512,8 @@ class Dispatcher(WalkManage):
else
:
else
:
transport_value
=
self
.
cost_park_to_excavator
transport_value
=
self
.
cost_park_to_excavator
print
(
"here3"
,
self
.
cost_park_to_excavator
)
logger
.
info
(
"transport_value"
)
logger
.
info
(
"transport_value"
)
logger
.
info
(
transport_value
)
logger
.
info
(
transport_value
)
target
=
np
.
argmin
(
target
=
np
.
argmin
(
...
@@ -579,6 +521,7 @@ class Dispatcher(WalkManage):
...
@@ -579,6 +521,7 @@ class Dispatcher(WalkManage):
+
truck
.
excavator_exclude_modify
[
truck_index
]
+
truck
.
excavator_exclude_modify
[
truck_index
]
+
truck
.
excavator_material_bind_modify
[
truck_index
])
+
truck
.
excavator_material_bind_modify
[
truck_index
])
print
(
"excavator.excavator_index_to_uuid_dict"
,
excavator
.
excavator_index_to_uuid_dict
)
logger
.
info
(
f
"目的地:{excavator.excavator_index_to_uuid_dict[target]}"
)
logger
.
info
(
f
"目的地:{excavator.excavator_index_to_uuid_dict[target]}"
)
if
task
in
[
0
,
1
,
2
]:
if
task
in
[
0
,
1
,
2
]:
...
@@ -773,157 +716,157 @@ class Dispatcher(WalkManage):
...
@@ -773,157 +716,157 @@ class Dispatcher(WalkManage):
print
(
"here2"
,
self
.
cur_truck_ava_time
)
print
(
"here2"
,
self
.
cur_truck_ava_time
)
# try:
# 读取所需信息
trucks
=
truck
.
get_truck_num
()
truck_current_trip
=
truck
.
get_truck_current_trip
()
truck_current_task
=
truck
.
get_truck_current_task
()
payload
=
truck
.
get_payload
()
unloading_time
=
dump
.
get_unloading_time
()
loading_time
=
excavator
.
get_loading_time
()
# 出入场时间
loading_task_time
=
excavator
.
get_loading_task_time
()
unloading_task_time
=
dump
.
get_unloading_task_time
()
walk_time_to_unload_area
=
walk_manage
.
get_walk_time_to_unload_area
()
walk_time_to_load_area
=
walk_manage
.
get_walk_time_to_load_area
()
# Seq初始化
Seq
=
[[
truck_current_trip
[
i
][
1
],
-
1
]
for
i
in
range
(
trucks
)]
# 根据矿卡最早可用时间顺序进行规划
print
(
self
.
cur_truck_ava_time
)
print
(
truck
.
truck_priority
)
temp
=
copy
.
deepcopy
(
self
.
cur_truck_ava_time
)
-
truck
.
truck_priority
try
:
try
:
# 没有启动的矿卡加上一个很大的值,降低其优先级
for
i
in
range
(
trucks
):
task
=
truck_current_task
[
truck
.
truck_index_to_uuid_dict
[
i
]]
if
task
==
-
2
:
temp
[
i
]
=
temp
[
i
]
+
M
except
Exception
as
es
:
logger
.
info
(
"矿卡排序启动异常"
)
logger
.
error
(
es
)
# 读取所需信息
index
=
np
.
argsort
(
temp
.
reshape
(
1
,
-
1
))
trucks
=
truck
.
get_truck_num
()
index
=
index
.
flatten
()
truck_current_trip
=
truck
.
get_truck_current_trip
()
truck_current_task
=
truck
.
get_truck_current_task
()
payload
=
truck
.
get_payload
()
unloading_time
=
dump
.
get_unloading_time
()
loading_time
=
excavator
.
get_loading_time
()
# 出入场时间
# 对于在线矿卡已经赋予新的派车计划,更新其最早可用时间,及相关设备时间参数
loading_task_time
=
excavator
.
get_loading_task_time
()
for
truck_index
in
index
:
unloading_task_time
=
dump
.
get_unloading_task_time
()
if
len
(
Seq
[
truck_index
])
>
0
:
walk_time_to_unload_area
=
walk_manage
.
get_walk_time_to_unload_area
()
# try:
walk_time_to_load_area
=
walk_manage
.
get_walk_time_to_load_area
()
# Seq初始化
task
=
truck_current_task
[
truck
.
truck_index_to_uuid_dict
[
truck_index
]]
Seq
=
[[
truck_current_trip
[
i
][
1
],
-
1
]
for
i
in
range
(
trucks
)]
# 根据矿卡最早可用时间顺序进行规划
# 矿卡结束当前派车计划后的目的地
print
(
self
.
cur_truck_ava_time
)
end_eq_index
=
truck_current_trip
[
truck_index
][
1
]
print
(
truck
.
truck_priority
)
temp
=
copy
.
deepcopy
(
self
.
cur_truck_ava_time
)
-
truck
.
truck_priority
try
:
# 调用调度函数,得到最优目的地序号
# 没有启动的矿卡加上一个很大的值,降低其优先级
target_eq_index
=
self
.
truck_schedule
(
truck
.
truck_index_to_uuid_dict
[
truck_index
])
for
i
in
range
(
trucks
):
task
=
truck_current_task
[
truck
.
truck_index_to_uuid_dict
[
i
]]
# 写入Seq序列
if
task
==
-
2
:
Seq
[
truck_index
][
1
]
=
target_eq_index
temp
[
i
]
=
temp
[
i
]
+
M
except
Exception
as
es
:
#
except Exception as es:
logger
.
info
(
"矿卡排序启动异常"
)
# logger.error(f'矿卡 {truck_uuid_to_name_dict[truck_index_to_uuid_dict[truck]]} 派车计划计算异常'
)
logger
.
error
(
es
)
#
logger.error(es)
index
=
np
.
argsort
(
temp
.
reshape
(
1
,
-
1
))
index
=
index
.
flatten
()
# 对于在线矿卡已经赋予新的派车计划,更新其最早可用时间,及相关设备时间参数
for
truck_index
in
index
:
if
len
(
Seq
[
truck_index
])
>
0
:
# try:
task
=
truck_current_task
[
truck
.
truck_index_to_uuid_dict
[
truck_index
]]
# 矿卡结束当前派车计划后的目的地
end_eq_index
=
truck_current_trip
[
truck_index
][
1
]
# 调用调度函数,得到最优目的地序号
target_eq_index
=
self
.
truck_schedule
(
truck
.
truck_index_to_uuid_dict
[
truck_index
])
# 写入Seq序列
Seq
[
truck_index
][
1
]
=
target_eq_index
# except Exception as es:
# logger.error(f'矿卡 {truck_uuid_to_name_dict[truck_index_to_uuid_dict[truck]]} 派车计划计算异常')
# logger.error(es)
try
:
if
task
in
empty_task_set
:
target_area_index
=
dump
.
dump_index_to_unload_area_index_dict
[
target_eq_index
]
end_area_index
=
excavator
.
excavator_index_to_load_area_index_dict
[
end_eq_index
]
# 更新变量,预计产量更新
self
.
sim_dump_real_mass
[
target_eq_index
]
=
\
(
self
.
sim_dump_real_mass
[
target_eq_index
]
+
payload
[
truck_index
])
# 预计卸载设备可用时间更新
self
.
sim_dump_ava_time
[
target_eq_index
]
=
(
max
(
self
.
sim_dump_ava_time
[
target_eq_index
],
self
.
sim_truck_ava_time
[
truck_index
]
+
\
walk_time_to_unload_area
[
target_area_index
][
end_area_index
],)
+
unloading_task_time
[
target_eq_index
]
)
elif
task
in
heavy_task_set
:
target_area_index
=
(
excavator
.
excavator_index_to_load_area_index_dict
[
target_eq_index
])
end_area_index
=
dump
.
dump_index_to_unload_area_index_dict
[
end_eq_index
]
# 更新变量,预计产量更新
self
.
sim_excavator_real_mass
[
target_eq_index
]
=
(
self
.
sim_excavator_real_mass
[
target_eq_index
]
+
payload
[
truck_index
])
# 预计装载点可用时间更新
self
.
sim_excavator_ava_time
[
target_eq_index
]
=
(
max
(
self
.
sim_excavator_ava_time
[
target_eq_index
],
self
.
sim_truck_ava_time
[
truck_index
]
+
walk_time_to_unload_area
[
end_area_index
][
target_area_index
],)
\
+
loading_task_time
[
target_eq_index
])
else
:
pass
except
Exception
as
es
:
logger
.
error
(
f
"矿卡 {truck_uuid_to_name_dict[truck.truck_index_to_uuid_dict[truck_index]]} 调度状态更新异常"
)
logger
.
error
(
es
)
for
i
in
range
(
len
(
Seq
)):
try
:
try
:
record
=
{
"truckId"
:
truck
.
truck_index_to_uuid_dict
[
i
]}
task
=
truck
.
get_truck_current_task
()[
truck
.
truck_index_to_uuid_dict
[
i
]]
if
task
in
empty_task_set
:
if
task
in
empty_task_set
:
item
=
(
target_area_index
=
dump
.
dump_index_to_unload_area_index_dict
[
target_eq_index
]
session_mysql
.
query
(
Dispatch
)
end_area_index
=
excavator
.
excavator_index_to_load_area_index_dict
[
end_eq_index
]
.
filter_by
(
dump_id
=
dump
.
dump_index_to_uuid_dict
[
Seq
[
i
][
1
]],
isauto
=
1
,
isdeleted
=
0
,)
.
first
())
# 更新变量,预计产量更新
record
[
"exactorId"
]
=
item
.
exactor_id
self
.
sim_dump_real_mass
[
target_eq_index
]
=
\
record
[
"dumpId"
]
=
item
.
dump_id
(
self
.
sim_dump_real_mass
[
target_eq_index
]
+
payload
[
truck_index
])
record
[
"loadAreaId"
]
=
item
.
load_area_id
# 预计卸载设备可用时间更新
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
self
.
sim_dump_ava_time
[
target_eq_index
]
=
(
record
[
"dispatchId"
]
=
item
.
id
max
(
record
[
"isdeleted"
]
=
False
self
.
sim_dump_ava_time
[
target_eq_index
],
record
[
"creator"
]
=
item
.
creator
self
.
sim_truck_ava_time
[
truck_index
]
+
\
record
[
"createtime"
]
=
item
.
createtime
.
strftime
(
walk_time_to_unload_area
[
target_area_index
][
end_area_index
],)
"
%
b
%
d,
%
Y
%#
I:
%#
M:
%#
S
%
p"
)
+
unloading_task_time
[
target_eq_index
]
)
elif
task
in
heavy_task_set
:
elif
task
in
heavy_task_set
:
item
=
(
target_area_index
=
(
excavator
.
excavator_index_to_load_area_index_dict
[
target_eq_index
])
session_mysql
.
query
(
Dispatch
)
end_area_index
=
dump
.
dump_index_to_unload_area_index_dict
[
end_eq_index
]
.
filter_by
(
exactor_id
=
excavator
.
excavator_index_to_uuid_dict
[
Seq
[
i
][
1
]],
isauto
=
1
,
isdeleted
=
0
,)
.
first
())
# 更新变量,预计产量更新
record
[
"exactorId"
]
=
excavator
.
excavator_index_to_uuid_dict
[
Seq
[
i
][
1
]]
self
.
sim_excavator_real_mass
[
target_eq_index
]
=
(
self
.
sim_excavator_real_mass
[
target_eq_index
]
record
[
"dumpId"
]
=
item
.
dump_id
+
payload
[
truck_index
])
record
[
"loadAreaId"
]
=
item
.
load_area_id
# 预计装载点可用时间更新
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
self
.
sim_excavator_ava_time
[
target_eq_index
]
=
(
record
[
"dispatchId"
]
=
item
.
id
max
(
self
.
sim_excavator_ava_time
[
target_eq_index
],
self
.
sim_truck_ava_time
[
truck_index
]
record
[
"isdeleted"
]
=
False
+
walk_time_to_unload_area
[
end_area_index
][
target_area_index
],)
\
record
[
"creator"
]
=
item
.
creator
+
loading_task_time
[
target_eq_index
])
record
[
"createtime"
]
=
item
.
createtime
.
strftime
(
"
%
b
%
d,
%
Y
%#
I:
%#
M:
%#
S
%
p"
)
elif
task
==
-
2
:
item
=
(
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator
.
excavator_index_to_uuid_dict
[
Seq
[
i
][
1
]],
isauto
=
1
,
isdeleted
=
0
,)
.
first
())
record
[
"exactorId"
]
=
item
.
exactor_id
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
record
[
"dispatchId"
]
=
item
.
id
record
[
"isdeleted"
]
=
False
record
[
"creator"
]
=
item
.
creator
record
[
"createtime"
]
=
item
.
createtime
.
strftime
(
"
%
b
%
d,
%
Y
%#
I:
%#
M:
%#
S
%
p"
)
else
:
else
:
pass
pass
redis5
.
set
(
truck
.
truck_index_to_uuid_dict
[
i
],
str
(
json
.
dumps
(
record
)))
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
error
(
"调度结果写入异常-redis写入异常"
)
logger
.
error
(
f
"矿卡 {truck_uuid_to_name_dict[truck.truck_index_to_uuid_dict[truck_index]]} 调度状态更新异常"
)
logger
.
error
(
f
"调度结果:{Seq}"
)
logger
.
error
(
es
)
logger
.
error
(
es
)
for
i
in
range
(
trucks
):
for
i
in
range
(
len
(
Seq
)):
print
(
"dispatch_setting:"
)
try
:
print
(
redis5
.
get
(
truck
.
truck_index_to_uuid_dict
[
i
]))
except
Exception
as
es
:
record
=
{
"truckId"
:
truck
.
truck_index_to_uuid_dict
[
i
]}
logger
.
error
(
"更新不及时"
)
task
=
truck
.
get_truck_current_task
()[
truck
.
truck_index_to_uuid_dict
[
i
]]
logger
.
error
(
es
)
if
task
in
empty_task_set
:
item
=
(
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump
.
dump_index_to_uuid_dict
[
Seq
[
i
][
1
]],
isauto
=
1
,
isdeleted
=
0
,)
.
first
())
record
[
"exactorId"
]
=
item
.
exactor_id
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
record
[
"dispatchId"
]
=
item
.
id
record
[
"isdeleted"
]
=
False
record
[
"creator"
]
=
item
.
creator
record
[
"createtime"
]
=
item
.
createtime
.
strftime
(
"
%
b
%
d,
%
Y
%#
I:
%#
M:
%#
S
%
p"
)
elif
task
in
heavy_task_set
:
item
=
(
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator
.
excavator_index_to_uuid_dict
[
Seq
[
i
][
1
]],
isauto
=
1
,
isdeleted
=
0
,)
.
first
())
record
[
"exactorId"
]
=
excavator
.
excavator_index_to_uuid_dict
[
Seq
[
i
][
1
]]
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
record
[
"dispatchId"
]
=
item
.
id
record
[
"isdeleted"
]
=
False
record
[
"creator"
]
=
item
.
creator
record
[
"createtime"
]
=
item
.
createtime
.
strftime
(
"
%
b
%
d,
%
Y
%#
I:
%#
M:
%#
S
%
p"
)
elif
task
==
-
2
:
item
=
(
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator
.
excavator_index_to_uuid_dict
[
Seq
[
i
][
1
]],
isauto
=
1
,
isdeleted
=
0
,)
.
first
())
record
[
"exactorId"
]
=
item
.
exactor_id
record
[
"dumpId"
]
=
item
.
dump_id
record
[
"loadAreaId"
]
=
item
.
load_area_id
record
[
"unloadAreaId"
]
=
item
.
unload_area_id
record
[
"dispatchId"
]
=
item
.
id
record
[
"isdeleted"
]
=
False
record
[
"creator"
]
=
item
.
creator
record
[
"createtime"
]
=
item
.
createtime
.
strftime
(
"
%
b
%
d,
%
Y
%#
I:
%#
M:
%#
S
%
p"
)
else
:
pass
redis5
.
set
(
truck
.
truck_index_to_uuid_dict
[
i
],
str
(
json
.
dumps
(
record
)))
except
Exception
as
es
:
logger
.
error
(
"调度结果写入异常-redis写入异常"
)
logger
.
error
(
f
"调度结果:{Seq}"
)
logger
.
error
(
es
)
for
i
in
range
(
trucks
):
print
(
"dispatch_setting:"
)
print
(
redis5
.
get
(
truck
.
truck_index_to_uuid_dict
[
i
]))
# except Exception as es:
# logger.error("更新不及时")
# logger.error(es)
logger
.
info
(
"#####################################周期更新结束#####################################"
)
logger
.
info
(
"#####################################周期更新结束#####################################"
)
...
@@ -992,7 +935,7 @@ def process(dispatcher):
...
@@ -992,7 +935,7 @@ def process(dispatcher):
# except Exception as es:
# except Exception as es:
# logger.warning(es)
# logger.warning(es)
# logger.warning("
无动态派车计划可用
")
# logger.warning("
外层异常捕获
")
scheduler
=
sched
.
scheduler
(
time
.
time
,
time
.
sleep
)
scheduler
=
sched
.
scheduler
(
time
.
time
,
time
.
sleep
)
...
...
settings.py
View file @
1529bf4c
...
@@ -27,8 +27,8 @@ import time
...
@@ -27,8 +27,8 @@ import time
log_path
=
"/usr/local/fleet-log/dispatch"
log_path
=
"/usr/local/fleet-log/dispatch"
# 创建日志目录
# 创建日志目录
if
not
os
.
path
.
exists
(
log_path
):
#
if not os.path.exists(log_path):
os
.
mkdir
(
log_path
)
#
os.mkdir(log_path)
# logging初始化工作
# logging初始化工作
logging
.
basicConfig
()
logging
.
basicConfig
()
...
@@ -38,8 +38,8 @@ logger.setLevel(logging.INFO)
...
@@ -38,8 +38,8 @@ logger.setLevel(logging.INFO)
# timefilehandler = logging.handlers.TimedRotatingFileHandler(log_path + "/dispatch.log", when='M', interval=1, backupCount=60)
# 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(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
(
"./Logs/dispatch.log"
,
maxBytes
=
3
*
1024
*
1024
,
backupCount
=
10
)
# 设置后缀名称,跟strftime的格式一样
# 设置后缀名称,跟strftime的格式一样
filehandler
.
suffix
=
"
%
Y-
%
m-
%
d_
%
H-
%
M.log"
filehandler
.
suffix
=
"
%
Y-
%
m-
%
d_
%
H-
%
M.log"
...
...
traffic_flow/traffic_flow_info.py
View file @
1529bf4c
...
@@ -40,8 +40,14 @@ class Traffic_para(WalkManage):
...
@@ -40,8 +40,14 @@ class Traffic_para(WalkManage):
# self.payload = 200 # 有效载重(不同型号矿卡载重不同,这里暂时认为车队是同质的)
# self.payload = 200 # 有效载重(不同型号矿卡载重不同,这里暂时认为车队是同质的)
self
.
payload
=
np
.
mean
(
truck
.
get_payload
())
self
.
payload
=
np
.
mean
(
truck
.
get_payload
())
self
.
empty_speed
=
sum
(
truck
.
empty_speed
.
values
())
/
truck
.
get_truck_num
()
# 空载矿卡平均时速
try
:
self
.
heavy_speed
=
sum
(
truck
.
heavy_speed
.
values
())
/
truck
.
get_truck_num
()
# 重载矿卡平均时速
self
.
empty_speed
=
sum
(
truck
.
empty_speed
.
values
())
/
truck
.
get_truck_num
()
# 空载矿卡平均时速
self
.
heavy_speed
=
sum
(
truck
.
heavy_speed
.
values
())
/
truck
.
get_truck_num
()
# 重载矿卡平均时速
except
Exception
as
es
:
self
.
empty_speed
=
25
self
.
heavy_speed
=
22
logger
.
warning
(
"矿卡速度设置为默认值"
)
logger
.
warning
(
es
)
self
.
min_throughout
=
1000
# 最小产量约束
self
.
min_throughout
=
1000
# 最小产量约束
self
.
truck_total_num
=
0
self
.
truck_total_num
=
0
...
@@ -139,6 +145,12 @@ class Traffic_para(WalkManage):
...
@@ -139,6 +145,12 @@ class Traffic_para(WalkManage):
self
.
goto_unload_area_factor
[
load_area_index
][
unload_area_index
]
=
\
self
.
goto_unload_area_factor
[
load_area_index
][
unload_area_index
]
=
\
(
cost_to_unload_area
[
unload_area_index
][
load_area_index
]
/
(
heavy_speed
*
1000
))
/
self
.
payload
(
cost_to_unload_area
[
unload_area_index
][
load_area_index
]
/
(
heavy_speed
*
1000
))
/
self
.
payload
print
((
cost_to_unload_area
[
unload_area_index
][
load_area_index
]
/
(
heavy_speed
*
1000
)))
print
(
self
.
payload
)
print
(
"goto_unload_area_factor"
,
self
.
goto_unload_area_factor
)
print
(
"cost_to_unload_area"
,
cost_to_unload_area
)
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
error
(
es
)
logger
.
error
(
es
)
logger
.
error
(
"车流规划信息计算异常"
)
logger
.
error
(
"车流规划信息计算异常"
)
...
...
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