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
d151bae2
Commit
d151bae2
authored
Jul 11, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
7-11更新 1.添加日志 2.异常修复
parent
8c155ed9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
42 deletions
+80
-42
dispatcher.py
core/dispatcher.py
+18
-6
group.py
core/group.py
+54
-28
truck.py
equipment/truck.py
+2
-2
realtime_dispatch.py
realtime_dispatch.py
+6
-6
No files found.
core/dispatcher.py
View file @
d151bae2
...
...
@@ -24,7 +24,7 @@ class Dispatcher:
class for group dispatch program.
"""
def
__init__
(
self
,
truck
:
TruckInfo
,
dump
:
DumpInfo
,
excavator
:
ExcavatorInfo
,
pre_sch
:
PreSchedule
,
request_mode
=
False
):
self
.
group_list
=
[]
self
.
group_list
=
{}
self
.
truck
=
truck
self
.
dump
=
dump
self
.
excavator
=
excavator
...
...
@@ -51,18 +51,19 @@ class Dispatcher:
Generate and initialize dispatch groups.
:return: None
"""
self
.
group_list
=
{}
groups
=
DispatchInfo
.
get_all_group
()
for
group_id
in
groups
:
if
group_id
not
in
self
.
group_list
:
group
=
Group
(
group_id
,
self
.
truck
,
self
.
pre_sch
)
self
.
group_list
.
append
(
group
)
self
.
group_list
[
group_id
]
=
group
def
group_info_update
(
self
):
"""
Update group information.
:return: None
"""
for
group
in
self
.
group_list
:
for
group
in
self
.
group_list
.
values
()
:
group
.
info_update
()
def
group_dispatch
(
self
):
...
...
@@ -72,9 +73,16 @@ class Dispatcher:
"""
a
=
len
(
self
.
group_list
)
aa
=
self
.
group_list
for
group
in
self
.
group_list
:
for
group
in
self
.
group_list
.
values
():
try
:
truck_dispatch_plan_dict
=
group
.
group_dispatch
(
ExpectedTime
)
except
Exception
as
es
:
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
f
'分组{group.group_id} 调度异常'
)
truck_dispatch_plan_dict
=
group
.
group_dispatch
(
ExpectedTime
)
self
.
logger
.
info
(
f
'调度分组: {group.group_id} {DispatchInfo.group_name[group.group_id]}'
)
self
.
submission
.
group_dispatch_to_redis
(
group
,
truck_dispatch_plan_dict
)
...
...
@@ -88,7 +96,7 @@ class DispatchSubmission:
"""
def
__init__
(
self
,
dump
,
excavator
,
truck
):
self
.
logger
=
self
.
logger
=
get_logger
(
"zxt.submission"
)
self
.
logger
=
get_logger
(
"zxt.submission"
)
self
.
dump
=
dump
self
.
excavator
=
excavator
self
.
truck
=
truck
...
...
@@ -144,6 +152,8 @@ class DispatchSubmission:
record
[
"haulFlag"
]
=
-
1
record
[
"groupName"
]
=
DispatchInfo
.
group_name
[
group_id
]
self
.
logger
.
info
(
f
'redis 注入 {record}'
)
redis5
.
set
(
truck_id
,
str
(
json
.
dumps
(
record
)))
except
Exception
as
es
:
self
.
logger
.
error
(
"调度结果写入异常-矿卡空载"
)
...
...
@@ -179,6 +189,8 @@ class DispatchSubmission:
record
[
"haulFlag"
]
=
-
1
record
[
"groupName"
]
=
DispatchInfo
.
group_name
[
group_id
]
self
.
logger
.
info
(
f
'redis 注入 {record}'
)
redis5
.
set
(
truck_id
,
str
(
json
.
dumps
(
record
)))
except
Exception
as
es
:
self
.
logger
.
error
(
"调度结果写入异常-矿卡重载"
)
...
...
core/group.py
View file @
d151bae2
...
...
@@ -195,42 +195,68 @@ class Group:
# 全智能模式
if
self
.
group_mode
==
1
:
if
truck_task
in
[
-
2
,
3
,
4
]:
next_excavator_value
=
s
.
solve
(
truck_info
)
# next_excavator_value = s.solve(i, truck_task, truck_trip)
# min_index = next_excavator_list.index(min(next_excavator_list))
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"
else
:
next_unload_area_id
=
self
.
unload_area_uuid_index_dict
.
inverse
[
truck_trip
[
-
1
]]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
try
:
next_excavator_value
=
s
.
solve
(
truck_info
)
# next_excavator_value = s.solve(i, truck_task, truck_trip)
# min_index = next_excavator_list.index(min(next_excavator_list))
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"
else
:
next_unload_area_id
=
self
.
unload_area_uuid_index_dict
.
inverse
[
truck_trip
[
-
1
]]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
except
Exception
as
es
:
self
.
logger
.
error
(
"重载车辆全智能模式-计算异常"
)
self
.
logger
.
error
(
es
)
if
truck_task
in
[
0
,
1
]:
bb
=
truck_task
next_unload_area_value
=
s
.
solve
(
truck_info
)
min_index
=
np
.
argmin
(
next_unload_area_value
)
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
]
try
:
bb
=
truck_task
next_unload_area_value
=
s
.
solve
(
truck_info
)
min_index
=
np
.
argmin
(
next_unload_area_value
)
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
]
except
Exception
as
es
:
self
.
logger
.
error
(
"空载车辆全智能模式-计算异常"
)
self
.
logger
.
error
(
es
)
# 空车智能模式
elif
self
.
group_mode
==
2
:
if
truck_task
in
[
-
2
,
3
,
4
]:
next_excavator_value
=
s
.
solve
(
truck_info
)
# min_index = next_excavator_list.index(min(next_excavator_list))
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"
else
:
next_unload_area_id
=
self
.
unload_area_uuid_index_dict
.
inverse
[
truck_trip
[
-
1
]]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
try
:
next_excavator_value
=
s
.
solve
(
truck_info
)
# min_index = next_excavator_list.index(min(next_excavator_list))
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"
else
:
next_unload_area_id
=
self
.
unload_area_uuid_index_dict
.
inverse
[
truck_trip
[
-
1
]]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
except
Exception
as
es
:
self
.
logger
.
error
(
"重载车辆空车智能模式-计算异常"
)
self
.
logger
.
error
(
es
)
if
truck_task
in
[
0
,
1
]:
truck_dispatch
[
i
]
=
DispatchInfo
.
get_truck_match
(
i
)
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
:
truck_dispatch
[
i
]
=
DispatchInfo
.
get_truck_match
(
i
)
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
:
pass
...
...
equipment/truck.py
View file @
d151bae2
...
...
@@ -378,8 +378,8 @@ class TruckInfo(WalkManage):
# print(self.excavator_hold_truck_num)
self
.
truck_current_trip
.
flatten
()
print
(
"当前矿卡行程:"
)
print
(
self
.
truck_current_trip
)
self
.
logger
.
info
(
"当前矿卡行程:"
)
self
.
logger
.
info
(
self
.
truck_current_trip
)
def
update_eqp_hold_truck
(
self
):
...
...
realtime_dispatch.py
View file @
d151bae2
...
...
@@ -68,12 +68,12 @@ def process(dispatcher):
global_period_para_update
()
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
()
...
...
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