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
28c1a28b
Commit
28c1a28b
authored
Oct 29, 2021
by
Allvey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增饱和度控制
parent
b196bd44
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
33 deletions
+116
-33
dump.py
equipment/dump.py
+1
-2
realtime_dispatch.py
realtime_dispatch.py
+102
-27
traffic_flow_info.py
traffic_flow/traffic_flow_info.py
+12
-3
traffic_flow_planner.py
traffic_flow/traffic_flow_planner.py
+1
-1
No files found.
equipment/dump.py
View file @
28c1a28b
...
@@ -178,4 +178,4 @@ class DumpInfo(WalkManage):
...
@@ -178,4 +178,4 @@ class DumpInfo(WalkManage):
self
.
update_dump_priority
()
self
.
update_dump_priority
()
# 卸载目标产量
# 卸载目标产量
self
.
dump_target_mass
=
np
.
full
(
self
.
dynamic_dump_num
,
dump_target_mass
)
# self.dump_target_mass = np.full(self.dynamic_dump_num, dump_target_mass)
\ No newline at end of file
realtime_dispatch.py
View file @
28c1a28b
...
@@ -9,15 +9,18 @@
...
@@ -9,15 +9,18 @@
# 实时调度模块
# 实时调度模块
from
traffic_flow.traffic_flow_info
import
*
from
traffic_flow.traffic_flow_planner
import
*
from
traffic_flow.traffic_flow_planner
import
*
from
path_plan.path_plannner
import
*
from
para_config
import
*
from
para_config
import
*
from
equipment.truck
import
TruckInfo
from
equipment.excavator
import
ExcavatorInfo
from
equipment.excavator
import
ExcavatorInfo
from
equipment.dump
import
DumpInfo
from
equipment.dump
import
DumpInfo
from
equipment.truck
import
TruckInfo
dump
=
DumpInfo
()
excavator
=
ExcavatorInfo
()
truck
=
TruckInfo
()
truck
=
TruckInfo
()
excavator
=
ExcavatorInfo
()
dump
=
DumpInfo
()
# 调度类
# 调度类
...
@@ -76,9 +79,30 @@ class Dispatcher(WalkManage):
...
@@ -76,9 +79,30 @@ class Dispatcher(WalkManage):
self
.
opt_goto_excavator_traffic_flow
=
np
.
zeros
(
self
.
opt_goto_excavator_traffic_flow
=
np
.
zeros
(
(
dump
.
get_dump_num
(),
excavator
.
get_excavator_num
())
(
dump
.
get_dump_num
(),
excavator
.
get_excavator_num
())
)
)
self
.
path
=
PathPlanner
()
self
.
path
=
PathPlanner
()
# 设备数量
self
.
dump
=
get_value
(
"dynamic_dump_num"
)
self
.
excavator
=
get_value
(
"dynamic_excavator_num"
)
self
.
truck
=
get_value
(
"dynamic_truck_num"
)
# 目标产量
self
.
dump_target_mass
=
np
.
zeros
(
self
.
dump
)
self
.
excavator_target_mass
=
np
.
zeros
(
self
.
excavator
)
# 真实实际产量
self
.
cur_dump_real_mass
=
np
.
zeros
(
self
.
dump
)
self
.
cur_excavator_real_mass
=
np
.
zeros
(
self
.
excavator
)
# 预计产量(包含正在驶往目的地的矿卡载重)
self
.
pre_dump_real_mass
=
copy
.
deepcopy
(
self
.
cur_dump_real_mass
)
self
.
pre_excavator_real_mass
=
copy
.
deepcopy
(
self
.
cur_excavator_real_mass
)
# 模拟实际产量(防止调度修改真实产量)
self
.
sim_dump_real_mass
=
np
.
zeros
(
self
.
dump
)
self
.
sim_excavator_real_mass
=
np
.
zeros
(
self
.
excavator
)
self
.
excavator_uuid_to_index_dict
=
excavator
.
excavator_uuid_to_index_dict
self
.
dump_uuid_to_index_dict
=
dump
.
dump_uuid_to_index_dict
# 更新矿卡预计抵达目的地时间
# 更新矿卡预计抵达目的地时间
def
update_truck_reach_time
(
self
):
def
update_truck_reach_time
(
self
):
try
:
try
:
...
@@ -346,6 +370,52 @@ class Dispatcher(WalkManage):
...
@@ -346,6 +370,52 @@ class Dispatcher(WalkManage):
logger
.
info
(
"驶往挖机实际车流"
)
logger
.
info
(
"驶往挖机实际车流"
)
logger
.
info
(
self
.
actual_goto_excavator_traffic_flow
)
logger
.
info
(
self
.
actual_goto_excavator_traffic_flow
)
def
Saturation_transport_value
(
self
):
# dump_target_mass = 5000
# excavator_target_mass = 5000
self
.
cur_excavator_real_mass
=
np
.
zeros
(
self
.
excavator
)
self
.
cur_dump_real_mass
=
np
.
zeros
(
self
.
dump
)
traf_para
=
Traffic_para
(
self
.
excavator
,
self
.
dump
,
self
.
excavator
,
self
.
dump
)
self
.
excavator_target_mass
=
traf_para
.
get_target_excavator_mass
()
self
.
dump_target_mass
=
traf_para
.
get_target_dump_mass
()
self
.
excavator_uuid_to_index_dict
=
excavator
.
excavator_uuid_to_index_dict
now
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
# 读取实时装卸量, 写入目标装卸量
for
excavator_id
in
self
.
excavator_uuid_to_index_dict
.
keys
():
# print(excavator_id)
for
query
in
session_mysql
.
query
(
LoadInfo
)
.
\
join
(
Equipment
,
LoadInfo
.
dump_id
==
Equipment
.
equipment_id
)
.
\
filter
(
Equipment
.
id
==
excavator_id
,
LoadInfo
.
time
>
now
)
.
\
order_by
(
LoadInfo
.
time
.
desc
())
.
all
():
self
.
cur_excavator_real_mass
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
+=
query
.
load_weight
for
dump_id
in
self
.
dump_uuid_to_index_dict
.
keys
():
# print(excavator_id)
for
query
in
session_mysql
.
query
(
LoadInfo
)
.
\
join
(
Equipment
,
LoadInfo
.
dump_id
==
Equipment
.
equipment_id
)
.
\
filter
(
Equipment
.
id
==
dump_id
,
LoadInfo
.
time
>
now
)
.
\
order_by
(
LoadInfo
.
time
.
desc
())
.
all
():
self
.
cur_dump_real_mass
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
query
.
load_weight
# # 卸载目标产量
# # self.dump_target_mass = (np.array(session_mysql.query(Dump.target_mass).all())).flatten()
# self.dump_target_mass = np.full(self.dump, dump_target_mass)
#
# # 挖机目标产量
# # self.excavator_target_mass = (np.array(session_mysql.query(Excavator.target_mass).all())).flatten()
# self.excavator_target_mass = np.full(self.excavator, excavator_target_mass)
# logger.info(f'卸点饱和度:{(1 - self.sim_dump_real_mass / self.dump_target_mass)}')
# logger.info(f'电铲饱和度:{(1 - self.sim_excavator_real_mass / self.excavator_target_mass)}')
return
self
.
sim_dump_real_mass
,
self
.
sim_dump_real_mass
,
\
self
.
dump_target_mass
,
self
.
excavator_target_mass
def
para_period_update
(
self
):
def
para_period_update
(
self
):
logger
.
info
(
"#####################################周期更新开始#####################################"
)
logger
.
info
(
"#####################################周期更新开始#####################################"
)
...
@@ -374,7 +444,8 @@ class Dispatcher(WalkManage):
...
@@ -374,7 +444,8 @@ class Dispatcher(WalkManage):
# 计算理想车流
# 计算理想车流
(
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
()
print
(
"输出理想车流"
)
print
(
self
.
opt_goto_dump_traffic_flow
,
self
.
opt_goto_excavator_traffic_flow
,)
# 矿卡抵达时间
# 矿卡抵达时间
excavator_reach_list
,
dump_reach_list
=
self
.
update_truck_reach_time
()
excavator_reach_list
,
dump_reach_list
=
self
.
update_truck_reach_time
()
...
@@ -484,6 +555,11 @@ class Dispatcher(WalkManage):
...
@@ -484,6 +555,11 @@ class Dispatcher(WalkManage):
target
=
0
target
=
0
(
cur_dump_mass
,
cur_excavator_mass
,
\
target_dump_mass
,
target_excavator_mass
)
=
self
.
Saturation_transport_value
()
# self.sim_dump_real_mass, self.sim_dump_real_mass, \
# self.excavator_target_mass, self.dump_target_mass
if
task
==
-
2
:
if
task
==
-
2
:
try
:
try
:
logger
.
info
(
"矿卡状态:矿卡启动或故障恢复"
)
logger
.
info
(
"矿卡状态:矿卡启动或故障恢复"
)
...
@@ -585,17 +661,18 @@ class Dispatcher(WalkManage):
...
@@ -585,17 +661,18 @@ class Dispatcher(WalkManage):
else
:
else
:
if
rule3
and
rule4
:
if
rule3
and
rule4
:
transport_value
=
self
.
cost_to_dump
[:,
int
(
trip
[
1
])]
transport_value
=
self
.
cost_to_dump
[:,
int
(
trip
[
1
])]
else
:
else
:
transport_value
=
(
self
.
actual_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
)
\
# transport_value = (self.actual_goto_dump_traffic_flow[int(trip[1]), :] + 0.001) \
/
(
self
.
opt_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
)
# / (self.opt_goto_dump_traffic_flow[int(trip[1]), :] + 0.001)
transport_value
=
cur_dump_mass
/
target_dump_mass
logger
.
info
(
"transport_value"
)
logger
.
info
(
"transport_value"
)
logger
.
info
(
transport_value
)
logger
.
info
(
transport_value
)
logger
.
info
(
"dump_material_bind_modify"
)
logger
.
info
(
"dump_material_bind_modify"
)
logger
.
info
(
truck
.
dump_material_bind_modify
[
truck_index
])
logger
.
info
(
truck
.
dump_material_bind_modify
[
truck_index
])
target
=
np
.
argmin
(
transport_value
+
truck
.
dump_material_bind_modify
[
truck_index
])
target
=
np
.
argmin
(
transport_value
+
truck
.
dump_material_bind_modify
[
truck_index
])
logger
.
info
(
"车流比:"
)
logger
.
info
(
"车流比:"
)
logger
.
info
((
self
.
actual_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
)
\
logger
.
info
((
self
.
actual_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
)
\
/
(
self
.
opt_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
))
/
(
self
.
opt_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
))
...
@@ -641,7 +718,6 @@ class Dispatcher(WalkManage):
...
@@ -641,7 +718,6 @@ class Dispatcher(WalkManage):
logger
.
info
(
"重载trip"
)
logger
.
info
(
"重载trip"
)
logger
.
info
(
trip
)
logger
.
info
(
trip
)
try
:
try
:
logger
.
info
(
"挖机实际车流_行"
)
logger
.
info
(
"挖机实际车流_行"
)
logger
.
info
(
self
.
actual_goto_excavator_traffic_flow
[
trip
[
1
],
:])
logger
.
info
(
self
.
actual_goto_excavator_traffic_flow
[
trip
[
1
],
:])
...
@@ -675,19 +751,20 @@ class Dispatcher(WalkManage):
...
@@ -675,19 +751,20 @@ class Dispatcher(WalkManage):
if
rule3
and
rule4
:
if
rule3
and
rule4
:
transport_value
=
self
.
cost_to_excavator
[
int
(
trip
[
1
]),
:]
transport_value
=
self
.
cost_to_excavator
[
int
(
trip
[
1
]),
:]
else
:
else
:
transport_value
=
(
self
.
actual_goto_excavator_traffic_flow
[
trip
[
1
],
:]
+
0.001
)
\
# transport_value = (self.actual_goto_excavator_traffic_flow[trip[1], :] + 0.001) \
/
(
self
.
opt_goto_excavator_traffic_flow
[
trip
[
1
],
:]
+
0.001
)
# / (self.opt_goto_excavator_traffic_flow[trip[1], :] + 0.001)
transport_value
=
cur_excavator_mass
/
target_excavator_mass
logger
.
info
(
"transport_value"
)
logger
.
info
(
"transport_value"
)
logger
.
info
(
transport_value
)
logger
.
info
(
transport_value
)
target
=
np
.
argmin
(
transport_value
target
=
np
.
argmin
(
transport_value
+
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
])
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
info
(
"trip出错1"
)
logger
.
info
(
"trip出错1"
)
logger
.
info
(
es
)
logger
.
info
(
es
)
try
:
try
:
logger
.
info
(
"车流比:"
)
logger
.
info
(
"车流比:"
)
logger
.
info
(
logger
.
info
(
...
@@ -755,22 +832,20 @@ class Dispatcher(WalkManage):
...
@@ -755,22 +832,20 @@ class Dispatcher(WalkManage):
for
truck_index
in
index
:
for
truck_index
in
index
:
if
len
(
Seq
[
truck_index
])
>
0
:
if
len
(
Seq
[
truck_index
])
>
0
:
try
:
# try:
task
=
truck_current_task
[
truck
.
truck_index_to_uuid_dict
[
truck_index
]]
task
=
truck_current_task
[
truck
.
truck_index_to_uuid_dict
[
truck_index
]]
# 矿卡结束当前派车计划后的目的地
end_eq_index
=
truck_current_trip
[
truck_index
][
1
]
# 矿卡结束当前派车计划后的目的地
end_eq_index
=
truck_current_trip
[
truck_index
][
1
]
# 调用调度函数,得到最优目的地序号
# 调用调度函数,得到最优目的地序号
target_eq_index
=
self
.
truck_schedule
(
truck
.
truck_index_to_uuid_dict
[
truck_index
])
target_eq_index
=
self
.
truck_schedule
(
truck
.
truck_index_to_uuid_dict
[
truck_index
])
# 写入Seq序列
# 写入Seq序列
Seq
[
truck_index
][
1
]
=
target_eq_index
Seq
[
truck_index
][
1
]
=
target_eq_index
# except Exception as es:
# logger.error(f'矿卡 {truck_uuid_to_name_dict[self.truck_index_to_uuid_dict[truck_index]]} 派车计划计算异常')
except
Exception
as
es
:
# logger.error(es)
logger
.
error
(
f
'矿卡 {truck_uuid_to_name_dict[self.truck_index_to_uuid_dict[truck_index]]} 派车计划计算异常'
)
logger
.
error
(
es
)
try
:
try
:
...
...
traffic_flow/traffic_flow_info.py
View file @
28c1a28b
...
@@ -78,6 +78,15 @@ class Traffic_para(WalkManage):
...
@@ -78,6 +78,15 @@ class Traffic_para(WalkManage):
self
.
load_area_material_type
=
{}
self
.
load_area_material_type
=
{}
self
.
unload_area_material_type
=
{}
self
.
unload_area_material_type
=
{}
self
.
excavator_target_mass
=
np
.
zeros
(
self
.
num_of_excavator
)
self
.
dump_target_mass
=
np
.
zeros
(
self
.
num_of_dump
)
def
get_target_excavator_mass
(
self
):
return
self
.
excavator_target_mass
def
get_target_dump_mass
(
self
):
return
self
.
dump_target_mass
# 设置卸载点信息
# 设置卸载点信息
def
extract_dump_info
(
self
):
def
extract_dump_info
(
self
):
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
dynamic_dump_num
=
get_value
(
"dynamic_dump_num"
)
...
@@ -89,7 +98,7 @@ class Traffic_para(WalkManage):
...
@@ -89,7 +98,7 @@ class Traffic_para(WalkManage):
unload_ability
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
UnloadAbililty
unload_ability
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
UnloadAbililty
self
.
dump_strength
[
dump_index
]
=
unload_ability
# 卸载设备最大卸载能力,单位吨/小时
self
.
dump_strength
[
dump_index
]
=
unload_ability
# 卸载设备最大卸载能力,单位吨/小时
self
.
dump_target_mass
[
dump_index
]
=
8
*
unload_ability
if
unload_ability
<
200
:
if
unload_ability
<
200
:
raise
Exception
(
"卸载点卸载能力异常"
)
raise
Exception
(
"卸载点卸载能力异常"
)
else
:
else
:
...
@@ -105,7 +114,7 @@ class Traffic_para(WalkManage):
...
@@ -105,7 +114,7 @@ class Traffic_para(WalkManage):
logger
.
error
(
es
)
logger
.
error
(
es
)
logger
.
error
(
"卸载点信息设置异常"
)
logger
.
error
(
"卸载点信息设置异常"
)
# 设置挖信息
# 设置挖
机
信息
def
extract_excavator_info
(
self
):
def
extract_excavator_info
(
self
):
try
:
try
:
rule4
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
4
)
.
first
()
rule4
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
4
)
.
first
()
...
@@ -115,7 +124,7 @@ class Traffic_para(WalkManage):
...
@@ -115,7 +124,7 @@ class Traffic_para(WalkManage):
join
(
Equipment
,
Equipment
.
equipment_spec
==
EquipmentSpec
.
id
)
.
\
join
(
Equipment
,
Equipment
.
equipment_spec
==
EquipmentSpec
.
id
)
.
\
filter
(
Equipment
.
id
==
self
.
excavator_index_to_uuid_dict
[
excavator_index
])
.
first
()
filter
(
Equipment
.
id
==
self
.
excavator_index_to_uuid_dict
[
excavator_index
])
.
first
()
self
.
excavator_strength
[
excavator_index
]
=
load_ability
.
mining_abililty
self
.
excavator_strength
[
excavator_index
]
=
load_ability
.
mining_abililty
self
.
excavator_target_mass
[
excavator_index
]
=
8
*
load_ability
.
mining_abililty
if
load_ability
.
mining_abililty
<
200
:
if
load_ability
.
mining_abililty
<
200
:
raise
Exception
(
"挖机装载能力异常"
)
raise
Exception
(
"挖机装载能力异常"
)
else
:
else
:
...
...
traffic_flow/traffic_flow_planner.py
View file @
28c1a28b
...
@@ -210,7 +210,7 @@ def traffic_flow_plan():
...
@@ -210,7 +210,7 @@ def traffic_flow_plan():
# logger.error("车流规划参数异常")
# logger.error("车流规划参数异常")
# logger.error(es)
# logger.error(es)
return
None
#
return None
# end = time.time()
# end = time.time()
# print("used {:.5}s".format(end-start))
# print("used {:.5}s".format(end-start))
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