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
f3862cae
Commit
f3862cae
authored
Sep 13, 2021
by
Allvey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Light Schedule
parent
2c77ecd3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
102 additions
and
265 deletions
+102
-265
integrated-scheduling.iml
.idea/integrated-scheduling.iml
+0
-1
dump.py
equipment/dump.py
+9
-49
excavator.py
equipment/excavator.py
+9
-65
truck.py
equipment/truck.py
+6
-82
path_plannner.py
path_plan/path_plannner.py
+50
-41
priority_control.py
path_plan/priority_control.py
+11
-7
realtime_dispatch.py
realtime_dispatch.py
+0
-0
settings.py
settings.py
+4
-4
tables.py
tables.py
+4
-2
traffic_flow_info.py
traffic_flow/traffic_flow_info.py
+5
-6
traffic_flow_planner.py
traffic_flow/traffic_flow_planner.py
+4
-8
wato_dispatch.py
wato_dispatch.py
+0
-0
No files found.
.idea/integrated-scheduling.iml
View file @
f3862cae
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"PYTHON_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$/../WatoDisp-master"
/>
<content
url=
"file://$MODULE_DIR$"
/>
<orderEntry
type=
"jdk"
jdkName=
"Python 3.7 (waytous)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
...
...
equipment/dump.py
View file @
f3862cae
...
...
@@ -6,30 +6,14 @@
# @File : dump.py
# @Software: PyCharm
from
traffic_flow.traffic_flow_planner
import
*
from
static_data_process
import
*
from
para_config
import
*
from
settings
import
*
# 卸载设备类
class
DumpInfo
(
WalkManage
):
def
__init__
(
self
):
# # 卸载设备集合
# self.dynamic_dump_set = set(update_autodisp_dump())
# 卸载设备数量
self
.
dynamic_dump_num
=
len
(
dynamic_dump_set
)
# 目标产量
self
.
dump_target_mass
=
np
.
zeros
(
self
.
dynamic_dump_num
)
# 实际真实产量
self
.
cur_dump_real_mass
=
np
.
zeros
(
self
.
dynamic_dump_num
)
# # 预计产量(包含正在驶往目的地的矿卡载重)
# self.pre_dump_real_mass = copy.deepcopy(self.cur_dump_real_mass)
# # 模拟实际产量(防止调度修改真实产量)
# self.sim_dump_real_mass = np.zeros(self.dynamic_dump_num)
# # 真实设备可用时间
# self.cur_dump_ava_time = np.zeros(self.dynamic_dump_num)
# # 模拟各设备可用时间(防止调度修改真实产量)
# self.sim_dump_ava_time = np.zeros(self.dynamic_dump_num)
# 用于动态调度的卸载设备集合
self
.
dynamic_dump_set
=
[]
# 开始时间
...
...
@@ -58,12 +42,6 @@ class DumpInfo(WalkManage):
def
get_dump_num
(
self
):
return
self
.
dynamic_dump_num
def
get_dump_target_mass
(
self
):
return
self
.
dump_target_mass
def
get_dump_actual_mass
(
self
):
return
self
.
cur_dump_real_mass
def
get_dynamic_dump_set
(
self
):
return
self
.
dynamic_dump_set
...
...
@@ -132,37 +110,22 @@ class DumpInfo(WalkManage):
logger
.
error
(
f
"卸载设备 {dump_id} 出入场时间信息缺失, 已设为默认值(1min)"
)
logger
.
error
(
es
)
self
.
entrance_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
0.50
self
.
exit_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
0.50
# 更新卸载设备实际卸载量
def
update_actual_unload_thoughout
(
self
):
self
.
cur_dump_real_mass
=
np
.
zeros
(
self
.
dynamic_dump_num
)
now
=
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d"
)
for
dump_id
in
self
.
dump_uuid_to_index_dict
.
keys
():
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
()
):
# print("time:", query.time)
# print("load_weight:", )
self
.
cur_dump_real_mass
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
(
self
.
cur_dump_real_mass
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+
query
.
load_weight
)
self
.
exit_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
0.50
def
update_dump_material
(
self
):
self
.
dump_material
=
{}
for
dump_id
in
dynamic_dump_set
:
unload_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
)
.
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
self
.
dump_material
[
dump_id
]
=
dump_material_id
\
self
.
dump_material
[
dump_id
]
=
dump_material_id
def
update_dump_priority
(
self
):
self
.
dump_priority_coefficient
=
np
.
ones
(
self
.
dynamic_dump_num
)
for
dump_id
in
dynamic_dump_set
:
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
dump_id
)
.
first
()
self
.
dump_priority_coefficient
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
item
.
priority
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
]
item
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
self
.
dump_priority_coefficient
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
item
.
Priority
def
para_period_update
(
self
):
...
...
@@ -186,9 +149,6 @@ class DumpInfo(WalkManage):
# 计算平均进出场时间
self
.
update_dump_entrance_exit_time
()
# 计算实时卸载量
self
.
update_actual_unload_thoughout
()
# 更新卸点物料
self
.
update_dump_material
()
...
...
equipment/excavator.py
View file @
f3862cae
...
...
@@ -6,8 +6,6 @@
# @File : excavator.py
# @Software: PyCharm
from
traffic_flow.traffic_flow_planner
import
*
from
static_data_process
import
*
from
para_config
import
*
from
settings
import
*
...
...
@@ -18,18 +16,6 @@ class ExcavatorInfo(WalkManage):
# self.dynamic_excavator_set = set(update_autodisp_excavator())
# 装载设备数量
self
.
dynamic_excavator_num
=
len
(
dynamic_excavator_set
)
# 目标产量
self
.
excavator_target_mass
=
np
.
zeros
(
self
.
dynamic_excavator_num
)
# 真实实际产量
self
.
cur_excavator_real_mass
=
np
.
zeros
(
self
.
dynamic_excavator_num
)
# # 预计产量(包含正在驶往目的地的矿卡载重)
# self.pre_excavator_real_mass = copy.deepcopy(self.cur_excavator_real_mass)
# # 模拟实际产量(防止调度修改真实产量)
# self.sim_excavator_real_mass = np.zeros(self.dynamic_excavator_num)
# # 真实设备可用时间
# self.cur_excavator_ava_time = np.zeros(self.dynamic_excavator_num)
# # 模拟各设备可用时间(防止调度修改真实产量)
# self.sim_excavator_ava_time = np.zeros(self.dynamic_excavator_num)
# 用于动态调度的卸载设备集合
self
.
dynamic_excavator_set
=
[]
# 开始时间
...
...
@@ -60,17 +46,12 @@ class ExcavatorInfo(WalkManage):
def
get_excavator_num
(
self
):
return
self
.
dynamic_excavator_num
def
get_excavator_target_mass
(
self
):
return
self
.
excavator_target_mass
def
get_excavator_actual_mass
(
self
):
return
self
.
cur_excavator_real_mass
def
get_dynamic_excavator_set
(
self
):
return
self
.
dynamic_excavator_set
# 更新挖机装载时间
def
update_excavator_loadtime
(
self
):
self
.
loading_time
=
np
.
zeros
(
self
.
dynamic_excavator_num
)
for
excavator_id
in
self
.
excavator_uuid_to_index_dict
.
keys
():
...
...
@@ -95,9 +76,7 @@ class ExcavatorInfo(WalkManage):
except
Exception
as
es
:
logger
.
error
(
f
"挖机 {excavator_id} 装载时间信息缺失, 已设为默认值(1min)"
)
logger
.
error
(
es
)
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
# 更新挖机设备出入时间
def
update_excavator_entrance_exit_time
(
self
):
...
...
@@ -141,37 +120,16 @@ class ExcavatorInfo(WalkManage):
return
loading_task_time
# 更新挖机实际装载量
def
update_actual_load_throughout
(
self
):
self
.
cur_excavator_real_mass
=
np
.
zeros
(
self
.
dynamic_excavator_num
)
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
()
):
# print("time:", query.time)
# print("load_weight:", )
self
.
cur_excavator_real_mass
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]
]
=
(
self
.
cur_excavator_real_mass
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]
]
+
query
.
load_weight
)
def
update_excavator_material
(
self
):
for
excavator_id
in
dynamic_excavator_set
:
load_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator_id
)
.
first
()
.
load_area_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
def
update_excavator_priority
(
self
):
self
.
excavator_material_priority
=
np
.
ones
(
dynamic_excavator_num
)
for
excavator_id
in
dynamic_excavator_set
:
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
excavator_id
)
.
first
()
self
.
excavator_priority_coefficient
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
item
.
priority
+
1
...
...
@@ -184,17 +142,15 @@ class ExcavatorInfo(WalkManage):
rule
=
rule7
.
rule_weight
if
rule
==
3
:
if
se
ssion_mysql
.
query
(
Material
)
.
filter_by
(
id
=
self
.
excavator_material
[
excavator_id
])
.
first
()
.
name
==
'土
'
:
if
se
lf
.
excavator_material
[
excavator_id
]
==
'c8092d59-7597-44d7-a731-5a568b46060e
'
:
self
.
excavator_material_priority
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5
elif
rule
==
1
:
if
se
ssion_mysql
.
query
(
Material
)
.
filter_by
(
id
=
self
.
excavator_material
[
excavator_id
])
.
first
()
.
name
==
'煤
'
:
if
se
lf
.
excavator_material
[
excavator_id
]
==
'c481794b-6ced-45b9-a9c4-c4a388f44418
'
:
self
.
excavator_material_priority
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5
def
para_period_update
(
self
):
# print("Excavator update!")
logger
.
info
(
"Excavator update!"
)
# 装载周期参数
...
...
@@ -202,11 +158,6 @@ class ExcavatorInfo(WalkManage):
self
.
period_walk_para_load
()
# # 初始化挖机可用时间
# self.cur_excavator_ava_time = np.full(self.dynamic_excavator_num,
# (datetime.now() - self.start_time) / timedelta(hours=0, minutes=1,
# seconds=0))
# 用于动态调度的挖机设备
self
.
dynamic_excavator_set
=
set
(
update_autodisp_excavator
())
...
...
@@ -215,15 +166,8 @@ class ExcavatorInfo(WalkManage):
# 计算平均装载时间
self
.
update_excavator_loadtime
()
# 计算实时装载量
self
.
update_actual_load_throughout
()
# 更新挖机物料
self
.
update_excavator_material
()
# 更新挖机优先级
# 挖机目标产量
self
.
excavator_target_mass
=
np
.
full
(
self
.
dynamic_excavator_num
,
excavator_target_mass
)
self
.
update_excavator_priority
()
equipment/truck.py
View file @
f3862cae
...
...
@@ -6,8 +6,6 @@
# @File : truck.py
# @Software: PyCharm
from
traffic_flow.traffic_flow_planner
import
*
from
static_data_process
import
*
from
para_config
import
*
from
settings
import
*
from
equipment.dump
import
DumpInfo
...
...
@@ -37,9 +35,6 @@ class TruckInfo(WalkManage):
self
.
truck_current_task
=
{}
# 调度开始时间
self
.
start_time
=
datetime
.
now
()
# # 卡车完成装载及卸载时间
# self.cur_truck_ava_time = np.zeros(self.dynamic_truck_num)
# self.sim_truck_ava_time = np.zeros(self.dynamic_truck_num)
# 矿卡有效载重
self
.
payload
=
np
.
zeros
(
self
.
dynamic_truck_num
)
# 矿卡时速
...
...
@@ -61,14 +56,14 @@ class TruckInfo(WalkManage):
# 矿卡卸点排斥关系
self
.
truck_dump_exclude
=
{}
# 排斥关系modify
self
.
excavator_exclude_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
excavator_exclude_modify
=
np
.
full
((
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
# 矿卡优先级
self
.
truck_priority
=
np
.
ones
(
self
.
dynamic_truck_num
)
# 矿卡绑定物料
self
.
truck_material_bind
=
{}
# 矿卡绑定物料modify
self
.
dump_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
excavator_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
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
.
dump
=
DumpInfo
()
self
.
excavator
=
ExcavatorInfo
()
...
...
@@ -100,7 +95,7 @@ class TruckInfo(WalkManage):
return
self
.
relative_last_load_time
def
get_realative_last_unload_time
(
self
):
return
self
.
relative_
unlast_
load_time
return
self
.
relative_
last_un
load_time
def
get_payload
(
self
):
return
self
.
payload
...
...
@@ -250,10 +245,6 @@ class TruckInfo(WalkManage):
self
.
dump_uuid_to_index_dict
[
item
.
dump_id
],
self
.
excavator_uuid_to_index_dict
[
item
.
exactor_id
],
]
# if truck_uuid_to_name_dict[self.truck_index_to_uuid_dict[i]] in tmp_set:
# self.cur_truck_reach_excavator[i] = last_unload_time + 10 * self.walk_time_to_load_area[start_area_index][
# end_area_index]
# else:
self
.
cur_truck_reach_excavator
[
i
]
=
(
last_unload_time
+
walk_time_to_load_area
[
start_area_index
][
end_area_index
]
...
...
@@ -336,9 +327,6 @@ class TruckInfo(WalkManage):
elif
item
.
priority
==
3
:
self
.
truck_priority
[
truck_index
]
=
10
logger
.
info
(
"矿卡优先级:"
)
logger
.
info
(
self
.
truck_priority
)
def
update_truck_dump_area_bind
(
self
):
try
:
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
...
...
@@ -354,10 +342,6 @@ class TruckInfo(WalkManage):
logger
.
error
(
"矿卡-卸载区域绑定关系读取异常"
)
logger
.
error
(
es
)
logger
.
info
(
"矿卡-卸载点绑定关系"
)
logger
.
info
(
self
.
truck_dump_bind
)
def
update_truck_excavator_bind
(
self
):
try
:
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
...
...
@@ -374,9 +358,6 @@ class TruckInfo(WalkManage):
logger
.
error
(
"矿卡-挖机绑定关系读取异常"
)
logger
.
error
(
es
)
logger
.
info
(
"矿卡-挖机绑定关系"
)
logger
.
info
(
self
.
truck_excavator_bind
)
def
update_truck_excavator_exclude
(
self
):
self
.
truck_excavator_exclude
=
{}
...
...
@@ -407,10 +388,6 @@ class TruckInfo(WalkManage):
logger
.
error
(
"矿卡-挖机禁止关系读取异常"
)
logger
.
error
(
es
)
logger
.
info
(
"矿卡-挖机禁止关系"
)
logger
.
info
(
self
.
truck_excavator_exclude
)
logger
.
info
(
self
.
excavator_exclude_modify
)
def
update_truck_dump_exclude
(
self
):
pass
...
...
@@ -437,9 +414,11 @@ class TruckInfo(WalkManage):
if
truck_id
in
self
.
truck_excavator_bind
:
excavator_id
=
self
.
truck_excavator_bind
[
truck_id
]
# print(self.excavator.excavator_material)
excavator_material_id
=
self
.
excavator
.
excavator_material
[
excavator_id
]
self
.
truck_material_bind
[
truck_id
]
=
excavator_material_id
for
truck_id
in
dynamic_truck_set
:
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
...
...
@@ -460,9 +439,6 @@ class TruckInfo(WalkManage):
if
dump_material_id
!=
material
:
self
.
dump_material_bind_modify
[
truck_index
][
dump_index
]
=
1000000
logger
.
info
(
"矿卡-物料类型"
)
logger
.
info
(
self
.
truck_material_bind
)
def
update_truck_spec
(
self
):
for
truck_id
in
dynamic_truck_set
:
self
.
size
[
truck_id
]
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
truck_id
)
.
first
()
.
equipment_spec
...
...
@@ -485,8 +461,6 @@ class TruckInfo(WalkManage):
def
para_period_update
(
self
):
# print("Para truck update!")
# 设备优先级启用
rule6
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
6
)
.
first
()
.
disabled
...
...
@@ -546,53 +520,3 @@ class TruckInfo(WalkManage):
# 矿卡速度更新
self
.
update_truck_speed
()
# def period_update(self):
#
# print("Truck update!")
#
# # # 更新行走队形
# # self.walker.update_walk_time()
#
# # 装载周期参数
# self.period_map_para_load()
#
# self.period_walk_para_load()
#
# # 更新全部矿卡设备集合
# truck_set = set(update_total_truck())
#
# # 更新固定派车矿卡集合
# fixed_truck_set = set(update_fixdisp_truck())
#
# # 更新动态派车矿卡集合
# self.dynamic_truck_set = truck_set.difference(fixed_truck_set)
#
# # 更新矿卡数量
# self.dynamic_truck_num = len(self.dynamic_truck_set)
#
# # 更新卡车当前任务
# self.update_truck_current_task()
#
# # 更新有效载重
# self.update_truck_payload()
#
# # 更新卡车最后一次装载/卸载时间
# self.update_truck_last_leave_time()
#
# # 更新卡车当前行程
# self.update_truck_trip()
#
# # 更新绑定关系
# self.update_truck_dump_area_bind()
#
# self.update_truck_excavator_bind()
#
# # 更新禁止关系
# self.update_truck_excavator_exclude()
#
# # 更新矿卡调度优先级
# self.update_truck_priority()
#
# # 更新矿卡物料类型
# self.update_truck_material()
path_plan/path_plannner.py
View file @
f3862cae
...
...
@@ -13,7 +13,6 @@ from tables import *
M
=
1000000
class
PathPlanner
(
WalkManage
):
def
__init__
(
self
):
# 路线行驶成本
...
...
@@ -53,21 +52,28 @@ class PathPlanner(WalkManage):
weighted_distance
=
weighted_walk_cost
()
# 修正因子
weight
=
100
00
weight
=
100
# 阻塞成本权重
alpha
=
1
*
weight
alpha
=
0
# 距离成本权重
beta
=
1
session_mysql
.
commit
()
# 距离成本启用
rule1
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
1
)
.
first
()
if
rule1
.
disabled
==
0
:
alpha
=
alpha
*
rule1
.
rule_weight
beta
=
rule1
.
rule_weight
# 拥堵成本启用
rule2
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
2
)
.
first
()
if
rule2
.
disabled
==
0
:
beta
=
beta
*
rule2
.
rule_weight
alpha
=
rule2
.
rule_weight
beta
/=
beta
alpha
=
alpha
/
beta
*
weight
try
:
# 备停区处理
...
...
@@ -130,40 +136,39 @@ class PathPlanner(WalkManage):
self
.
period_map_para_load
()
# try:
# 读取路网成本
for
walk_time
in
session_postgre
.
query
(
WalkTime
)
.
all
():
# print(str(walk_time.load_area_id),str(walk_time.unload_area_id))
# print(walk_time.load_area_name, walk_time.unload_area_name)
load_area_id
,
unload_area_id
=
str
(
walk_time
.
load_area_id
),
str
(
walk_time
.
unload_area_id
)
unload_area_index
=
unload_area_uuid_to_index_dict
[
unload_area_id
]
load_area_index
=
load_area_uuid_to_index_dict
[
load_area_id
]
self
.
cost_to_load_area
[
unload_area_index
][
load_area_index
],
\
self
.
cost_to_unload_area
[
unload_area_index
][
load_area_index
]
=
\
self
.
path_cost_generate
(
load_area_id
,
unload_area_id
,
False
)
# 读取备停区路网成本
for
walk_time_park
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
park_area_index
=
park_uuid_to_index_dict
[
str
(
walk_time_park
.
park_area_id
)]
load_area_index
=
load_area_uuid_to_index_dict
[
str
(
walk_time_park
.
load_area_id
)]
_
,
self
.
cost_park_to_load_area
[
park_area_index
][
load_area_index
]
=
\
self
.
path_cost_generate
(
str
(
walk_time_park
.
load_area_id
),
str
(
walk_time_park
.
park_area_id
),
True
)
# except Exception as es:
# logger.error('路网信息计成本计算异常')
# logger.error(es)
try
:
# 读取路网成本
for
walk_time
in
session_postgre
.
query
(
WalkTime
)
.
all
():
load_area_id
,
unload_area_id
=
str
(
walk_time
.
load_area_id
),
str
(
walk_time
.
unload_area_id
)
unload_area_index
=
unload_area_uuid_to_index_dict
[
unload_area_id
]
load_area_index
=
load_area_uuid_to_index_dict
[
load_area_id
]
self
.
cost_to_load_area
[
unload_area_index
][
load_area_index
],
\
self
.
cost_to_unload_area
[
unload_area_index
][
load_area_index
]
=
\
self
.
path_cost_generate
(
load_area_id
,
unload_area_id
,
False
)
# 读取备停区路网成本
for
walk_time_park
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
park_area_index
=
park_uuid_to_index_dict
[
str
(
walk_time_park
.
park_area_id
)]
load_area_index
=
load_area_uuid_to_index_dict
[
str
(
walk_time_park
.
load_area_id
)]
self
.
cost_park_to_load_area
[
park_area_index
][
load_area_index
],
_
=
\
self
.
path_cost_generate
(
str
(
walk_time_park
.
load_area_id
),
str
(
walk_time_park
.
park_area_id
),
True
)
except
Exception
as
es
:
logger
.
error
(
'路网信息计成本计算异常'
)
logger
.
error
(
es
)
cost_to_excavator
=
np
.
zeros_like
(
self
.
distance_to_excavator
)
cost_to_dump
=
np
.
zeros_like
(
self
.
distance_to_dump
)
cost_park_to_excavator
=
np
.
zeros_like
(
self
.
distance_park_to_excavator
)
# 路网优先级
walk_weight
=
weighted_walk_cost
()
walk_weight
=
walk_weight
/
walk_weight
.
min
()
# 路网权重
walk_weight
,
park_walk_weight
=
weighted_walk_cost
()
# 路网禁用关系
walk_available
=
available_walk
()
logger
.
info
(
"walk_weight"
,
walk_weight
)
print
(
"path_weight"
,
walk_weight
)
print
(
"walk_avail"
,
walk_available
)
for
i
in
range
(
dynamic_dump_num
):
for
j
in
range
(
dynamic_excavator_num
):
...
...
@@ -172,19 +177,29 @@ class PathPlanner(WalkManage):
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
]
for
j
in
range
(
dynamic_excavator_num
):
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
]
logger
.
info
(
"真实路网距离-驶往挖机:"
)
logger
.
info
(
self
.
distance_to_excavator
)
logger
.
info
(
"真实路网距离-驶往卸点:"
)
logger
.
info
(
self
.
distance_to_dump
)
logger
.
info
(
"加权-阻塞路网距离-驶往挖机:"
)
logger
.
info
(
"真实备停区路网距离-驶往挖机:"
)
logger
.
info
(
self
.
distance_park_to_excavator
)
logger
.
info
(
"阻塞路网距离-驶往挖机:"
)
logger
.
info
(
cost_to_excavator
)
logger
.
info
(
"
加权-
阻塞路网距离-驶往卸点:"
)
logger
.
info
(
"阻塞路网距离-驶往卸点:"
)
logger
.
info
(
cost_to_dump
)
return
cost_to_excavator
,
cost_to_dump
,
walk_weight
,
walk_available
logger
.
info
(
"阻塞备停区路网距离-驶往挖机:"
)
logger
.
info
(
cost_park_to_excavator
)
return
cost_to_excavator
,
cost_to_dump
,
cost_park_to_excavator
class
LaneInfo
:
...
...
@@ -232,18 +247,12 @@ class LaneInfo:
# truck -> lane
truck_locate_dict
=
self
.
update_truck_loacate
()
# print("truck -> lane")
# print(truck_locate_dict)
logger
.
info
(
"矿卡位于路段:"
)
logger
.
info
(
truck_locate_dict
)
# truck -> speed
truck_speed_dict
=
self
.
update_truck_speed
()
# print("truck -> speed")
# print(truck_speed_dict)
logger
.
info
(
"矿卡当前速度:"
)
logger
.
info
(
truck_speed_dict
)
...
...
path_plan/priority_control.py
View file @
f3862cae
...
...
@@ -3,7 +3,7 @@
# @Time : 2021/9/3 14:44
# @Author : Opfer
# @Site :
# @File : priority_control.py
# @File : priority_control.py
# @Software: PyCharm
from
equipment.truck
import
*
...
...
@@ -15,6 +15,7 @@ truck = TruckInfo()
excavator
=
ExcavatorInfo
()
dump
=
DumpInfo
()
def
weighted_walk_cost
():
excavator
.
update_excavator_priority
()
dump
.
update_dump_priority
()
...
...
@@ -23,8 +24,10 @@ def weighted_walk_cost():
excavator_material_priority
=
excavator
.
excavator_material_priority
dump_priority
=
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
:
...
...
@@ -32,8 +35,10 @@ def weighted_walk_cost():
excavator_inedx
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
walk_weight
[
dump_index
][
excavator_inedx
]
+=
dump_priority
[
dump_index
]
*
\
excavator_priority
[
excavator_inedx
]
park_walk_weight
=
park_walk_weight
*
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
:
...
...
@@ -41,11 +46,13 @@ def weighted_walk_cost():
excavator_inedx
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
walk_weight
[
dump_index
][
excavator_inedx
]
+=
dump_material_priority
[
dump_index
]
*
\
excavator_material_priority
[
excavator_inedx
]
park_walk_weight
=
park_walk_weight
*
excavator
.
excavator_material_priority
logger
.
info
(
"路网优先级"
)
logger
.
info
(
walk_weight
)
walk_weight
=
walk_weight
-
(
walk_weight
.
min
()
-
1
)
return
walk_weight
park_walk_weight
=
park_walk_weight
-
(
park_walk_weight
.
min
()
-
1
)
return
walk_weight
,
park_walk_weight
def
available_walk
():
...
...
@@ -60,8 +67,5 @@ def available_walk():
if
excavator
.
excavator_material
[
excavator_id
]
!=
dump
.
dump_material
[
dump_id
]:
walk_weight
[
dump_index
][
excavator_inedx
]
+=
1000
logger
.
info
(
"路网禁用关系"
)
logger
.
info
(
walk_weight
)
return
walk_weight
realtime_dispatch.py
View file @
f3862cae
This diff is collapsed.
Click to expand it.
settings.py
View file @
f3862cae
...
...
@@ -28,8 +28,8 @@ import time
log_path
=
"/usr/local/fleet-log/dispatch"
# 创建日志目录
if
not
os
.
path
.
exists
(
log_path
):
os
.
mkdir
(
log_path
)
#
if not os.path.exists(log_path):
#
os.mkdir(log_path)
# logging初始化工作
logging
.
basicConfig
()
...
...
@@ -39,8 +39,8 @@ logger.setLevel(logging.INFO)
# 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("./Logs/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
)
# 设置后缀名称,跟strftime的格式一样
filehandler
.
suffix
=
"
%
Y-
%
m-
%
d_
%
H-
%
M.log"
...
...
tables.py
View file @
f3862cae
...
...
@@ -390,13 +390,15 @@ class DumpArea(Base):
UnloadAbililty
=
Column
(
Float
)
Disabled
=
Column
(
Integer
)
Material
=
Column
(
VARCHAR
(
36
))
Priority
=
Column
(
Integer
)
def
__init__
(
self
,
Id
,
BindList
,
UnloadAbililty
,
Disabled
,
Material
):
def
__init__
(
self
,
Id
,
BindList
,
UnloadAbililty
,
Disabled
,
Material
,
Priority
):
self
.
Id
=
Id
self
.
BindList
=
BindList
self
.
UnloadAbililty
=
UnloadAbililty
self
.
Disabled
=
Disabled
self
.
Material
=
Material
self
.
Priority
=
Priority
class
DiggingWorkArea
(
Base
):
...
...
@@ -424,7 +426,7 @@ class DispatchRule(Base):
class
Material
(
Base
):
__tablename__
=
'resource_m
ate
rials'
__tablename__
=
'resource_m
eta
rials'
id
=
Column
(
VARCHAR
(
40
),
primary_key
=
True
)
name
=
Column
(
VARCHAR
(
40
))
...
...
traffic_flow/traffic_flow_info.py
View file @
f3862cae
...
...
@@ -7,9 +7,8 @@
# @Software: PyCharm
# import
from
path_plan.path_plannner
import
*
from
traffic_flow.traffic_flow_planner
import
*
from
path_plan.path_plannner
import
*
from
para_config
import
*
from
equipment.excavator
import
ExcavatorInfo
from
equipment.dump
import
DumpInfo
...
...
@@ -194,6 +193,7 @@ class Traffic_para(WalkManage):
#
# if rule == 0:
# if self.excavator.excavator_material[excavator_id] == 'c8092d59-7597-44d7-a731-5a568b46060e':
# print("here111")
# self.excavator_material_priority[self.excavator_uuid_to_index_dict[excavator_id]] = 5
# elif rule == 2:
# if self.excavator.excavator_material[excavator_id] == 'c481794b-6ced-45b9-a9c4-c4a388f44418':
...
...
@@ -338,6 +338,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# # 设备优先级
# if not device_priority_use:
# print("here1")
# # 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
# tra_para.priority_coefficient_goto_dump[i][j] = tra_para.excavator_priority_coefficient[i] \
# * tra_para.dump_priority_coefficient[j]
...
...
@@ -347,6 +348,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# * tra_para.dump_priority_coefficient[j]
# # 物料优先级
# if not material_priority_use:
# print("here2")
# # # 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
# # tra_para.priority_coefficient_goto_dump[i][j] += tra_para.excavator_material_priority[i] \
# # * tra_para.dump_material_priority[j]
...
...
@@ -364,10 +366,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# tra_para.walk_time_to_dump[i][j] = \
# tra_para.walk_time_to_unload_area[load_area_index][unload_area_index]
logger
.
info
(
"priority_coefficient_goto_dump"
)
logger
.
info
(
tra_para
.
priority_coefficient_goto_dump
)
logger
.
info
(
"priority_coefficient_goto_excavator"
)
logger
.
info
(
tra_para
.
priority_coefficient_goto_excavator
)
print
(
"cout"
,
tra_para
.
priority_coefficient_goto_dump
,
tra_para
.
priority_coefficient_goto_excavator
)
# except Exception as es:
# logger.error(es)
...
...
traffic_flow/traffic_flow_planner.py
View file @
f3862cae
...
...
@@ -39,7 +39,7 @@ def transportation_problem_slove(coefficient_goto_dump, coefficient_goto_excavat
if
max_unload_weigh_alg_flag
==
True
:
prob
=
pulp
.
LpProblem
(
'Transportation Problem'
,
sense
=
pulp
.
LpMaximize
)
# 得到目标函数,目标函数是使得系统的运输量最大
prob
+=
(
pulp
.
lpDot
(
flatten
(
var_
y
),
coefficient_goto_excavator
.
flatten
()))
prob
+=
(
pulp
.
lpDot
(
flatten
(
var_
x
),
coefficient_goto_dump
.
flatten
()))
else
:
prob
=
pulp
.
LpProblem
(
'Transportation Problem'
,
sense
=
pulp
.
LpMinimize
)
goto_excavator_cost
=
var_x
*
walk_time_to_excavator
...
...
@@ -168,7 +168,7 @@ def traffic_flow_plan():
walk_time_to_dump
=
traffic_programme_para
.
walk_time_to_dump
truck_total_num
=
traffic_programme_para
.
truck_total_num
#
print(w_ij, s_ij, b_excavator, b_dump)
print
(
w_ij
,
s_ij
,
b_excavator
,
b_dump
)
res
=
transportation_problem_slove
(
coefficient_goto_dump
,
coefficient_goto_excavator
,
w_ij
,
s_ij
,
b_excavator
,
b_dump
,
grade_loading_array
,
max_unload_weigh_alg_flag
,
truck_total_num
,
...
...
@@ -184,16 +184,12 @@ def traffic_flow_plan():
print
(
'各变量的取值为:'
)
logger
.
info
(
'各变量取值:'
)
logger
.
info
(
dynamic_excavator_set
)
logger
.
info
(
dynamic_dump_set
)
print
(
dynamic_excavator_set
)
print
(
dynamic_dump_set
)
print
(
dynamic_excavator_set
)
print
(
np
.
array
(
res
[
'var_x'
])
.
round
(
3
))
logger
.
info
(
f
'重运车流:{res["var_x"]} 单位: 吨/时'
)
logger
.
info
(
dynamic_dump_set
)
logger
.
info
(
dynamic_excavator_set
)
print
(
dynamic_dump_set
)
print
(
dynamic_excavator_set
)
print
(
dynamic_dump_set
)
print
(
np
.
array
(
res
[
'var_y'
])
.
round
(
3
))
logger
.
info
(
f
'空运车流:{res["var_y"]} 单位: 吨/时'
)
...
...
wato_dispatch.py
deleted
100644 → 0
View file @
2c77ecd3
This diff is collapsed.
Click to expand it.
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