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
2927681e
Commit
2927681e
authored
Apr 03, 2024
by
Allvey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分流配比改进
parent
e3f3cb42
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
99 additions
and
72 deletions
+99
-72
algorithm.py
alg/algorithm.py
+21
-11
dispatcher.py
core/dispatcher.py
+5
-5
group.py
core/group.py
+54
-50
tables.py
tables.py
+19
-6
No files found.
alg/algorithm.py
View file @
2927681e
...
@@ -392,12 +392,18 @@ class DistributionRatio(object):
...
@@ -392,12 +392,18 @@ class DistributionRatio(object):
recent_unload_area_output
=
self
.
get_cumulative_production
()
recent_unload_area_output
=
self
.
get_cumulative_production
()
# 获取当前正在前往卸载车辆情况
# 获取当前正在前往卸载车辆情况
current_heading_to_unload_area_trucks
=
self
.
get_current_heading_to_unload_area_truck
()
current_heading_to_unload_area_trucks
=
self
.
get_current_heading_to_unload_area_truck
()
self
.
logger
.
info
(
"current_heading_to_unload_area_trucks"
)
self
.
logger
.
info
(
current_heading_to_unload_area_trucks
)
# 计算逻辑累计产量
# 计算逻辑累计产量
logic_cumulative_output
=
{
k
:
recent_unload_area_output
[
k
]
+
current_heading_to_unload_area_trucks
[
k
]
logic_cumulative_output
=
{
k
:
recent_unload_area_output
[
k
]
+
current_heading_to_unload_area_trucks
[
k
]
for
k
in
recent_unload_area_output
}
for
k
in
recent_unload_area_output
}
self
.
logger
.
info
(
"logic_cumulative_output"
)
self
.
logger
.
info
(
logic_cumulative_output
)
# 获取分流比例
# 获取分流比例
DispatchInfo
.
get_exactor_unload_match
(
self
.
excavator_id
)
DispatchInfo
.
get_exactor_unload_match
(
self
.
excavator_id
)
...
@@ -406,6 +412,9 @@ class DistributionRatio(object):
...
@@ -406,6 +412,9 @@ class DistributionRatio(object):
for
item
in
self
.
group
.
group_unload_areas
:
for
item
in
self
.
group
.
group_unload_areas
:
unload_ratio
[
item
]
=
DispatchInfo
.
unload_rate_dict
[
item
]
unload_ratio
[
item
]
=
DispatchInfo
.
unload_rate_dict
[
item
]
self
.
logger
.
info
(
"unload_ratio"
)
self
.
logger
.
info
(
unload_ratio
)
# 逻辑累计产量与分流比例比值
# 逻辑累计产量与分流比例比值
logic_cumulative_output
=
{
k
:
float
(
logic_cumulative_output
[
k
])
/
unload_ratio
[
k
]
for
k
in
logic_cumulative_output
}
logic_cumulative_output
=
{
k
:
float
(
logic_cumulative_output
[
k
])
/
unload_ratio
[
k
]
for
k
in
logic_cumulative_output
}
...
@@ -414,7 +423,6 @@ class DistributionRatio(object):
...
@@ -414,7 +423,6 @@ class DistributionRatio(object):
return
target_unload_area
return
target_unload_area
def
get_cumulative_production
(
self
):
def
get_cumulative_production
(
self
):
"""
"""
Get unloading point yield in the past hour.
Get unloading point yield in the past hour.
...
@@ -424,8 +432,11 @@ class DistributionRatio(object):
...
@@ -424,8 +432,11 @@ class DistributionRatio(object):
recent_unload_area_output
=
{}
recent_unload_area_output
=
{}
recent_duration
=
datetime
.
now
()
-
timedelta
(
hours
=
1
)
recent_duration
=
datetime
.
now
()
-
timedelta
(
hours
=
1
)
for
unload_area_id
in
self
.
group
.
group_unload_areas
:
for
unload_area_id
in
self
.
group
.
group_unload_areas
:
recent_unload_area_output
[
unload_area_id
]
=
\
len
(
session_mysql
.
query
(
RecordTruckOutput
)
.
filter_by
(
unload_area_id
=
unload_area_id
)
.
all
())
recent_unload_area_output
[
unload_area_id
]
=
len
(
session_mysql
.
query
(
RecordTruckOutput
)
.
filter
(
RecordTruckOutput
.
end_time
>
recent_duration
,
RecordTruckOutput
.
unload_area_id
==
unload_area_id
)
.
all
())
return
recent_unload_area_output
return
recent_unload_area_output
def
get_current_heading_to_unload_area_truck
(
self
):
def
get_current_heading_to_unload_area_truck
(
self
):
...
@@ -435,18 +446,17 @@ class DistributionRatio(object):
...
@@ -435,18 +446,17 @@ class DistributionRatio(object):
current_heading_to_unload_area_trucks
=
{}
current_heading_to_unload_area_trucks
=
{}
for
truck_info
in
self
.
group
.
truck_info_list
:
for
unload_area_id
in
self
.
group
.
group_unload_areas
:
trip
=
truck_info
.
get_trip
()
current_heading_to_unload_area_trucks
[
unload_area_id
]
=
0
if
trip
in
[
3
,
4
]:
for
truck_info
in
self
.
group
.
truck_info_list
.
values
():
task
=
truck_info
.
get_task
()
if
task
in
[
3
,
4
]:
heading_unload_area
=
truck_info
.
get_combined_unload_area
()
heading_unload_area
=
truck_info
.
get_combined_unload_area
()
current_heading_to_unload_area_trucks
[
heading_unload_area
]
+=
1
current_heading_to_unload_area_trucks
[
heading_unload_area
]
+=
1
return
current_heading_to_unload_area_trucks
return
current_heading_to_unload_area_trucks
def
get_unload_ratio
(
self
):
def
get_unload_ratio
(
self
):
"""
"""
@date:2022/7/19 15:21
@date:2022/7/19 15:21
...
...
core/dispatcher.py
View file @
2927681e
...
@@ -31,11 +31,11 @@ class Dispatcher:
...
@@ -31,11 +31,11 @@ class Dispatcher:
self
.
request_mode
=
request_mode
self
.
request_mode
=
request_mode
self
.
logger
=
get_logger
(
"zxt.dispatcher"
)
self
.
logger
=
get_logger
(
"zxt.dispatcher"
)
self
.
redispatch_active
=
active
self
.
redispatch_active
=
active
#
if self.redispatch_active:
if
self
.
redispatch_active
:
#
self.topo = Topo()
self
.
topo
=
Topo
()
#
self.topo.generate_topo_graph()
self
.
topo
.
generate_topo_graph
()
#
else:
else
:
self
.
topo
=
None
self
.
topo
=
None
self
.
submission
=
DispatchSubmission
(
dump
,
excavator
,
truck
,
self
.
topo
)
self
.
submission
=
DispatchSubmission
(
dump
,
excavator
,
truck
,
self
.
topo
)
def
period_update
(
self
):
def
period_update
(
self
):
...
...
core/group.py
View file @
2927681e
...
@@ -419,41 +419,41 @@ class GroupDispatcher:
...
@@ -419,41 +419,41 @@ class GroupDispatcher:
for
truck_id
in
list
(
self
.
group
.
group_trucks
):
for
truck_id
in
list
(
self
.
group
.
group_trucks
):
try
:
# try:
# construct CurrentTruck obj.
current_truck
=
self
.
truck_construct
(
truck_id
)
self
.
logger
.
info
(
f
'============================= 车辆调度开始 {current_truck.get_name()} ============================='
)
# 全智能模式
if
self
.
group
.
group_mode
==
1
:
self
.
logger
.
info
(
"调度模式:全智能模式调度"
)
self
.
full_dynamic_mode
(
truck_id
,
solver
,
truck_dispatch
,
current_truck
)
# 空车智能模式
elif
self
.
group
.
group_mode
==
2
:
self
.
logger
.
info
(
"调度模式:空车智能模式调度"
)
self
.
semi_dynamic_mode
(
truck_id
,
solver
,
truck_dispatch
,
current_truck
)
# 定铲派车
elif
self
.
group
.
group_mode
==
3
:
self
.
logger
.
info
(
"调度模式:固定模式调度"
)
try
:
truck_dispatch
[
truck_id
]
=
DispatchInfo
.
get_truck_match
(
truck_id
)
except
Exception
as
es
:
self
.
logger
.
error
(
"固定派车-计算异常"
)
self
.
logger
.
error
(
es
)
# 分流配比模式
elif
self
.
group
.
group_mode
==
4
:
self
.
logger
.
info
(
"调度模式:分流配比模式调度"
)
self
.
ratio_mode
(
truck_id
,
truck_dispatch
,
current_truck
)
self
.
logger
.
info
(
# construct CurrentTruck obj.
f
'============================= 车辆调度结束 {current_truck.get_name()} ============================='
)
current_truck
=
self
.
truck_construct
(
truck_id
)
self
.
logger
.
info
(
f
'============================= 车辆调度开始 {current_truck.get_name()} ============================='
)
# 全智能模式
if
self
.
group
.
group_mode
==
1
:
self
.
logger
.
info
(
"调度模式:全智能模式调度"
)
self
.
full_dynamic_mode
(
truck_id
,
solver
,
truck_dispatch
,
current_truck
)
# 空车智能模式
elif
self
.
group
.
group_mode
==
2
:
self
.
logger
.
info
(
"调度模式:空车智能模式调度"
)
self
.
semi_dynamic_mode
(
truck_id
,
solver
,
truck_dispatch
,
current_truck
)
# 定铲派车
elif
self
.
group
.
group_mode
==
3
:
self
.
logger
.
info
(
"调度模式:固定模式调度"
)
try
:
truck_dispatch
[
truck_id
]
=
DispatchInfo
.
get_truck_match
(
truck_id
)
except
Exception
as
es
:
self
.
logger
.
error
(
"固定派车-计算异常"
)
self
.
logger
.
error
(
es
)
# 分流配比模式
elif
self
.
group
.
group_mode
==
4
:
self
.
logger
.
info
(
"调度模式:分流配比模式调度"
)
self
.
ratio_mode
(
truck_id
,
truck_dispatch
,
current_truck
)
self
.
logger
.
info
(
f
'============================= 车辆调度结束 {current_truck.get_name()} ============================='
)
except
Exception
as
es
:
#
except Exception as es:
self
.
logger
.
error
(
"调度调用异常"
)
#
self.logger.error("调度调用异常")
self
.
logger
.
error
(
es
)
#
self.logger.error(es)
self
.
logger
.
info
(
self
.
logger
.
info
(
f
'================================== 分组调度结束 {self.group.group_name} =================================='
)
f
'================================== 分组调度结束 {self.group.group_name} =================================='
)
...
@@ -462,15 +462,16 @@ class GroupDispatcher:
...
@@ -462,15 +462,16 @@ class GroupDispatcher:
def
ratio_mode
(
self
,
i
,
truck_dispatch
,
truck_info
):
def
ratio_mode
(
self
,
i
,
truck_dispatch
,
truck_info
):
solver
=
DistributionRatio
(
self
.
group
,
truck_info
,
truck_info
.
get_combined_excavator
())
# next_excavator_id = truck_info.get_combined_excavator()
next_excavator_id
=
DispatchInfo
.
get_truck_exactor
(
i
)
# 获取该卡车对应的 excavator_id
solver
=
DistributionRatio
(
self
.
group
,
truck_info
,
next_excavator_id
)
next_exactor_id
=
truck_info
.
get_combined_excavator
()
# 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_ex
ac
tor_id}"
)
self
.
logger
.
info
(
f
"矿卡对应的铲车:{next_ex
cava
tor_id}"
)
next_unload_area_id
=
None
next_unload_area_id
=
None
truck_task
=
truck_info
.
get_t
rip
()
truck_task
=
truck_info
.
get_t
ask
()
if
truck_task
==
-
2
:
if
truck_task
==
-
2
:
...
@@ -479,21 +480,21 @@ class GroupDispatcher:
...
@@ -479,21 +480,21 @@ class GroupDispatcher:
# 空载模式下,计算下一次卸载区的位置,按照分流配比的模式进行计算
# 空载模式下,计算下一次卸载区的位置,按照分流配比的模式进行计算
elif
truck_task
in
[
0
,
1
,
2
]:
elif
truck_task
in
[
0
,
1
,
2
]:
try
:
# try:
if
i
in
self
.
group
.
truck
.
truck_dump_bind
:
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
.
group
.
truck
.
truck_dump_bind
[
i
]]
else
:
# next_unload_area_id = DistributionRatio(next_exactor_id, self.group.truck).ratio_main()
if
i
in
self
.
group
.
truck
.
truck_dump_bind
:
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
.
group
.
truck
.
truck_dump_bind
[
i
]]
else
:
next_unload_area_id
=
solver
.
solve
()
# next_unload_area_id = DistributionRatio(next_exactor_id, self.group.truck).ratio_main
()
except
Exception
as
es
:
next_unload_area_id
=
solver
.
solve
()
self
.
logger
.
error
(
"分流配比模式-->>空载车辆计算异常"
)
# except Exception as es:
self
.
logger
.
error
(
es
)
#
# self.logger.error("分流配比模式-->>空载车辆计算异常")
# self.logger.error(es)
# 重载模式下,按照固定派车进行计算
# 重载模式下,按照固定派车进行计算
elif
truck_task
in
[
3
,
4
,
5
]:
elif
truck_task
in
[
3
,
4
,
5
]:
...
@@ -508,7 +509,10 @@ class GroupDispatcher:
...
@@ -508,7 +509,10 @@ class GroupDispatcher:
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
truck_dispatch
[
i
]
=
[
next_exactor_id
,
next_unload_area_id
]
truck_dispatch
[
i
]
=
[
next_excavator_id
,
next_unload_area_id
]
self
.
logger
.
info
(
f
'调度结果 next_excavator_id: '
f
'{next_excavator_id} next_unload_area_id: {next_unload_area_id}'
)
def
semi_dynamic_mode
(
self
,
i
,
s
,
truck_dispatch
,
truck_info
):
def
semi_dynamic_mode
(
self
,
i
,
s
,
truck_dispatch
,
truck_info
):
# TODO:和全智能调度很像,是否可以合并合;
# TODO:和全智能调度很像,是否可以合并合;
...
...
tables.py
View file @
2927681e
...
@@ -504,15 +504,28 @@ class DispatchEquipment(Base):
...
@@ -504,15 +504,28 @@ class DispatchEquipment(Base):
self
.
equipment_id
=
equipment_id
self
.
equipment_id
=
equipment_id
# class RecordTruckOutput(Base):
# __tablename__ = 'record_truck_output'
# end_time = Column(DateTime)
# id = Column(Integer, primary_key=True)
# unload_area_id = Column(VARCHAR(36))
# equipment_id = Column(VARCHAR(36))
#
# def __init__(self, id, unload_area_id, equipment_id, end_time):
# self.id = id
# self.end_time = end_time
# self.unload_area_id = unload_area_id
# self.equipment_id = equipment_id
class
RecordTruckOutput
(
Base
):
class
RecordTruckOutput
(
Base
):
__tablename__
=
'record_truck_output'
__tablename__
=
'record_truck_output'
end_dump_time
=
Column
(
DateTime
)
id
=
Column
(
Integer
,
primary_key
=
True
)
id
=
Column
(
VARCHAR
(
36
)
,
primary_key
=
True
)
unload_area_id
=
Column
(
VARCHAR
(
36
))
unload_area_id
=
Column
(
VARCHAR
(
36
))
e
quipment_id
=
Column
(
VARCHAR
(
36
)
)
e
nd_time
=
Column
(
DateTime
)
def
__init__
(
self
,
id
,
unload_area_id
,
equipment_id
,
end_dump_time
):
def
__init__
(
self
,
id
,
unload_area_id
,
end_time
):
self
.
id
=
id
self
.
id
=
id
self
.
end_dump_time
=
end_dump_time
self
.
unload_area_id
=
unload_area_id
self
.
unload_area_id
=
unload_area_id
self
.
e
quipment_id
=
equipment_id
self
.
e
nd_time
=
end_time
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