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
9e292917
Commit
9e292917
authored
Aug 03, 2021
by
Allvey
Browse files
Options
Browse Files
Download
Plain Diff
test
parents
fb529f82
acc639d4
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
913 additions
and
2 deletions
+913
-2
.DS_Store
.DS_Store
+0
-0
123.txt
123.txt
+2
-0
integrated-scheduling
integrated-scheduling
+1
-0
realtime_dispatch.py
realtime_dispatch.py
+731
-0
settings.py
settings.py
+4
-0
static_data_process.py
static_data_process.py
+21
-2
tables.py
tables.py
+24
-0
traffic_flow_planner.py
traffic_flow_planner.py
+130
-0
No files found.
.DS_Store
0 → 100644
View file @
9e292917
File added
123.txt
0 → 100644
View file @
9e292917
123123123
\ No newline at end of file
integrated-scheduling
@
ce9ea011
Subproject commit ce9ea0115c095fcf55affdae3c20281d8a00aec4
realtime_dispatch.py
View file @
9e292917
...
@@ -45,11 +45,19 @@ empty_speed = 25
...
@@ -45,11 +45,19 @@ empty_speed = 25
# 重载矿卡速度,单位(km/h)
# 重载矿卡速度,单位(km/h)
heavy_speed
=
22
heavy_speed
=
22
<<<<<<<
HEAD
# 卸载设备目标卸载量
# 卸载设备目标卸载量
dump_target_mass
=
5000
dump_target_mass
=
5000
# 挖机目标装载量
# 挖机目标装载量
excavator_target_mass
=
5000
excavator_target_mass
=
5000
=======
# 卸点目标卸载量
dump_target_mass
=
5000
# 挖机目标装载量
shovel_target_mass
=
5000
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 任务集合
# 任务集合
task_set
=
[
-
2
,
0
,
1
,
2
,
3
,
4
,
5
]
task_set
=
[
-
2
,
0
,
1
,
2
,
3
,
4
,
5
]
...
@@ -70,10 +78,15 @@ park_num = len(park_uuid_to_index_dict)
...
@@ -70,10 +78,15 @@ park_num = len(park_uuid_to_index_dict)
truck_uuid_to_name_dict
,
truck_name_to_uuid_dict
=
build_truck_uuid_name_map
()
truck_uuid_to_name_dict
,
truck_name_to_uuid_dict
=
build_truck_uuid_name_map
()
<<<<<<<
HEAD
# 矿卡集合
# 矿卡集合
truck_set
=
set
(
update_total_truck
())
truck_set
=
set
(
update_total_truck
())
# 固定派车矿卡集合
# 固定派车矿卡集合
=======
truck_set
=
set
(
update_total_truck
())
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
fixed_truck_set
=
set
(
update_fixdisp_truck
())
fixed_truck_set
=
set
(
update_fixdisp_truck
())
# 动态派车矿卡集合
# 动态派车矿卡集合
...
@@ -141,13 +154,18 @@ class DumpInfo(DeviceMap):
...
@@ -141,13 +154,18 @@ class DumpInfo(DeviceMap):
# self.cur_dump_ava_time = np.zeros(self.dumps)
# self.cur_dump_ava_time = np.zeros(self.dumps)
# # 模拟各设备可用时间(防止调度修改真实产量)
# # 模拟各设备可用时间(防止调度修改真实产量)
# self.sim_dump_ava_time = np.zeros(self.dumps)
# self.sim_dump_ava_time = np.zeros(self.dumps)
<<<<<<<
HEAD
# 用于动态调度的卸载设备集合
# 用于动态调度的卸载设备集合
=======
# 用于动态调度的卸载点集合
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
dynamic_dump_set
=
[]
self
.
dynamic_dump_set
=
[]
# 开始时间
# 开始时间
self
.
start_time
=
datetime
.
now
()
self
.
start_time
=
datetime
.
now
()
# 卸载时间
# 卸载时间
self
.
unloading_time
=
np
.
zeros
(
self
.
dumps
)
self
.
unloading_time
=
np
.
zeros
(
self
.
dumps
)
<<<<<<<
HEAD
def
get_unloading_time
(
self
):
def
get_unloading_time
(
self
):
return
self
.
unloading_time
return
self
.
unloading_time
...
@@ -164,6 +182,9 @@ class DumpInfo(DeviceMap):
...
@@ -164,6 +182,9 @@ class DumpInfo(DeviceMap):
return
self
.
dynamic_dump_set
return
self
.
dynamic_dump_set
# 更新卸载设备卸载时间
# 更新卸载设备卸载时间
=======
# 更新卸点卸载时间
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
def
update_dump_unloadtime
(
self
):
def
update_dump_unloadtime
(
self
):
self
.
unloading_time
=
np
.
zeros
(
self
.
dumps
)
self
.
unloading_time
=
np
.
zeros
(
self
.
dumps
)
...
@@ -180,12 +201,20 @@ class DumpInfo(DeviceMap):
...
@@ -180,12 +201,20 @@ class DumpInfo(DeviceMap):
unload_count
=
unload_count
+
1
unload_count
=
unload_count
+
1
self
.
unloading_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
ave_unload_time
/
unload_count
self
.
unloading_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
ave_unload_time
/
unload_count
except
Exception
as
es
:
except
Exception
as
es
:
<<<<<<<
HEAD
logger
.
error
(
f
'卸载设备 {dump_id} 卸载时间信息缺失, 已设为默认值(1min)'
)
logger
.
error
(
f
'卸载设备 {dump_id} 卸载时间信息缺失, 已设为默认值(1min)'
)
=======
logger
.
error
(
f
'卸载点 {dump_id} 卸载时间信息缺失, 已设为默认值(1min)'
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
logger
.
error
(
es
)
logger
.
error
(
es
)
self
.
unloading_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
1.00
self
.
unloading_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
1.00
# print("average_unload_time: ", self.unloading_time[self.dump_uuid_to_index_dict[dump_id]])
# print("average_unload_time: ", self.unloading_time[self.dump_uuid_to_index_dict[dump_id]])
<<<<<<<
HEAD
# 更新卸载设备实际卸载量
# 更新卸载设备实际卸载量
=======
# 更新卸点实际卸载量
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
def
update_actual_unload_thoughout
(
self
):
def
update_actual_unload_thoughout
(
self
):
self
.
cur_dump_real_mass
=
np
.
zeros
(
self
.
dumps
)
self
.
cur_dump_real_mass
=
np
.
zeros
(
self
.
dumps
)
now
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
now
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
...
@@ -200,6 +229,49 @@ class DumpInfo(DeviceMap):
...
@@ -200,6 +229,49 @@ class DumpInfo(DeviceMap):
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
]]
=
\
self
.
cur_dump_real_mass
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+
query
.
load_weight
self
.
cur_dump_real_mass
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+
query
.
load_weight
<<<<<<<
HEAD
=======
# def update_pre_unload_throughout(self):
# try:
# self.pre_dump_real_mass = copy.deepcopy(self.cur_dump_real_mass)
# for i in range(self.trucktrucks):
# # task = self.truck_current_stage[i][0]
# task = self.truck_current_task[self.truck_index_to_uuid_dict[i]]
# end_area_index = self.truck_current_trip[i][1]
# # 若矿卡正常行驶,需要将该部分载重计入实时产量
# if task in heavy_task_set:
# self.pre_dump_real_mass[end_area_index] = self.pre_dump_real_mass[end_area_index] + self.payload[i]
# else:
# pass
# except Exception as es:
# logger.error("卸点预计装载量计算异常")
# logger.error(es)
# def update_dump_ava_time(self, dump_ava_ls):
# try:
#
# now = float((datetime.now() - self.start_time) / timedelta(hours=0, minutes=1, seconds=0))
#
# for reach_ls in dump_ava_ls:
# if len(reach_ls) != 0:
# reach_ls = np.array(reach_ls)
# tmp = reach_ls[np.lexsort(reach_ls[:, ::-1].T)]
# for i in range(len(tmp)):
# dump_index = int(tmp[i][2])
# self.cur_dump_ava_time[dump_index] = max(tmp[i][0], self.cur_dump_ava_time[dump_index]) + \
# self.unloading_time[dump_index]
# self.cur_truck_ava_time[int(tmp[i][1])] = self.cur_dump_ava_time[dump_index]
#
# # 若卸点可用时间严重偏离,进行修正
# if abs(self.cur_dump_ava_time[dump_index] - now) > 60:
# self.cur_dump_ava_time[dump_index] = now
# if abs(self.cur_truck_ava_time[int(tmp[i][1])] - now) > 60:
# self.cur_truck_ava_time[int(tmp[i][1])] = now
# except Exception as es:
# logger.error("卸点可用时间计算异常")
# logger.error(es)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
def
period_update
(
self
):
def
period_update
(
self
):
print
(
"Dump update!"
)
print
(
"Dump update!"
)
...
@@ -207,7 +279,11 @@ class DumpInfo(DeviceMap):
...
@@ -207,7 +279,11 @@ class DumpInfo(DeviceMap):
# 装载设备映射
# 装载设备映射
self
.
load
()
self
.
load
()
<<<<<<<
HEAD
# # 初始化卸载设备可用时间
# # 初始化卸载设备可用时间
=======
# # 初始化卸点可用时间
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# self.cur_dump_ava_time = np.full(self.dumps,
# self.cur_dump_ava_time = np.full(self.dumps,
# (datetime.now() - self.start_time) / timedelta(hours=0, minutes=1,
# (datetime.now() - self.start_time) / timedelta(hours=0, minutes=1,
# seconds=0))
# seconds=0))
...
@@ -229,15 +305,23 @@ class DumpInfo(DeviceMap):
...
@@ -229,15 +305,23 @@ class DumpInfo(DeviceMap):
# # 同步虚拟卸载量
# # 同步虚拟卸载量
# self.sim_dump_real_mass = copy.deepcopy(self.cur_dump_real_mass)
# self.sim_dump_real_mass = copy.deepcopy(self.cur_dump_real_mass)
<<<<<<<
HEAD
# # 计算卸载设备预估产量
# # 计算卸载设备预估产量
# self.update_pre_unload_throughout()
# self.update_pre_unload_throughout()
# 挖机设备类
# 挖机设备类
=======
# # 计算卸载点预估产量
# self.update_pre_unload_throughout()
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
class
ExcavatorInfo
(
DeviceMap
):
class
ExcavatorInfo
(
DeviceMap
):
def
__init__
(
self
):
def
__init__
(
self
):
super
()
.
__init__
()
super
()
.
__init__
()
# 装载设备数量
# 装载设备数量
<<<<<<<
HEAD
self
.
excavators
=
len
(
dynamic_excavator_set
)
self
.
excavators
=
len
(
dynamic_excavator_set
)
# 目标产量
# 目标产量
self
.
excavator_target_mass
=
np
.
zeros
(
self
.
excavators
)
self
.
excavator_target_mass
=
np
.
zeros
(
self
.
excavators
)
...
@@ -252,10 +336,27 @@ class ExcavatorInfo(DeviceMap):
...
@@ -252,10 +336,27 @@ class ExcavatorInfo(DeviceMap):
# # 模拟各设备可用时间(防止调度修改真实产量)
# # 模拟各设备可用时间(防止调度修改真实产量)
# self.sim_excavator_ava_time = np.zeros(self.excavators)
# self.sim_excavator_ava_time = np.zeros(self.excavators)
# 用于动态调度的卸载设备集合
# 用于动态调度的卸载设备集合
=======
self
.
shovels
=
len
(
dynamic_excavator_set
)
# 目标产量
self
.
excavator_target_mass
=
np
.
zeros
(
self
.
shovels
)
# 真实实际产量
self
.
cur_shovel_real_mass
=
np
.
zeros
(
self
.
shovels
)
# # 预计产量(包含正在驶往目的地的矿卡载重)
# self.pre_shovel_real_mass = copy.deepcopy(self.cur_shovel_real_mass)
# # 模拟实际产量(防止调度修改真实产量)
# self.sim_shovel_real_mass = np.zeros(self.shovels)
# # 真实设备可用时间
# self.cur_shovel_ava_time = np.zeros(self.shovels)
# # 模拟各设备可用时间(防止调度修改真实产量)
# self.sim_shovel_ava_time = np.zeros(self.shovels)
# 用于动态调度的卸载点集合
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
dynamic_excavator_set
=
[]
self
.
dynamic_excavator_set
=
[]
# 开始时间
# 开始时间
self
.
start_time
=
datetime
.
now
()
self
.
start_time
=
datetime
.
now
()
# 装载时间
# 装载时间
<<<<<<<
HEAD
self
.
loading_time
=
np
.
zeros
(
self
.
excavators
)
self
.
loading_time
=
np
.
zeros
(
self
.
excavators
)
def
get_loading_time
(
self
):
def
get_loading_time
(
self
):
...
@@ -276,6 +377,13 @@ class ExcavatorInfo(DeviceMap):
...
@@ -276,6 +377,13 @@ class ExcavatorInfo(DeviceMap):
# 更新挖机装载时间
# 更新挖机装载时间
def
update_excavator_loadtime
(
self
):
def
update_excavator_loadtime
(
self
):
self
.
loading_time
=
np
.
zeros
(
self
.
excavators
)
self
.
loading_time
=
np
.
zeros
(
self
.
excavators
)
=======
self
.
loading_time
=
np
.
zeros
(
self
.
shovels
)
# 更新挖机装载时间
def
update_excavator_loadtime
(
self
):
self
.
loading_time
=
np
.
zeros
(
self
.
shovels
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
for
excavator_id
in
self
.
excavator_uuid_to_index_dict
.
keys
():
for
excavator_id
in
self
.
excavator_uuid_to_index_dict
.
keys
():
ave_load_time
=
0
ave_load_time
=
0
...
@@ -296,7 +404,11 @@ class ExcavatorInfo(DeviceMap):
...
@@ -296,7 +404,11 @@ class ExcavatorInfo(DeviceMap):
# 更新挖机实际装载量
# 更新挖机实际装载量
def
update_actual_load_throughout
(
self
):
def
update_actual_load_throughout
(
self
):
<<<<<<<
HEAD
self
.
cur_excavator_real_mass
=
np
.
zeros
(
self
.
excavators
)
self
.
cur_excavator_real_mass
=
np
.
zeros
(
self
.
excavators
)
=======
self
.
cur_shovel_real_mass
=
np
.
zeros
(
self
.
shovels
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
now
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
now
=
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d'
)
for
excavator_id
in
self
.
excavator_uuid_to_index_dict
.
keys
():
for
excavator_id
in
self
.
excavator_uuid_to_index_dict
.
keys
():
# print(excavator_id)
# print(excavator_id)
...
@@ -306,25 +418,84 @@ class ExcavatorInfo(DeviceMap):
...
@@ -306,25 +418,84 @@ class ExcavatorInfo(DeviceMap):
order_by
(
LoadInfo
.
time
.
desc
())
.
all
():
order_by
(
LoadInfo
.
time
.
desc
())
.
all
():
# print("time:", query.time)
# print("time:", query.time)
# print("load_weight:", )
# print("load_weight:", )
<<<<<<<
HEAD
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
]]
=
\
self
.
cur_excavator_real_mass
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
+
query
.
load_weight
self
.
cur_excavator_real_mass
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
+
query
.
load_weight
def
period_update
(
self
):
def
period_update
(
self
):
print
(
"Excavator update!"
)
print
(
"Excavator update!"
)
=======
self
.
cur_shovel_real_mass
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
\
self
.
cur_shovel_real_mass
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
+
query
.
load_weight
# def update_pre_load_throughout(self):
# try:
# self.pre_shovel_real_mass = copy.deepcopy(self.cur_shovel_real_mass)
# for i in range(self.trucks):
# # task = self.truck_current_stage[i][0]
# task = self.truck_current_task[self.truck_index_to_uuid_dict[i]]
# end_area_index = self.truck_current_trip[i][1]
# # 若矿卡正常行驶,需要将该部分载重计入实时产量
# if task in empty_task_set:
# self.pre_shovel_real_mass[end_area_index] = self.pre_shovel_real_mass[end_area_index] + \
# self.payload[i]
# else:
# pass
# except Exception as es:
# logger.error("挖机/卸点预计装载量计算异常")
# logger.error(es)
# def update_shovel_ava_time(self, shovel_ava_ls):
# try:
#
# now = float((datetime.now() - self.start_time) / timedelta(hours=0, minutes=1, seconds=0))
#
# for reach_ls in shovel_ava_ls:
# if len(reach_ls) != 0:
# reach_ls = np.array(reach_ls)
# tmp = reach_ls[np.lexsort(reach_ls[:, ::-1].T)]
# for i in range(len(tmp)):
# shovel_index = int(tmp[i][2])
# self.cur_shovel_ava_time[shovel_index] = max(tmp[i][0],
# self.cur_shovel_ava_time[shovel_index]) + \
# self.loading_time[shovel_index]
# self.cur_truck_ava_time[int(tmp[i][1])] = self.cur_shovel_ava_time[shovel_index]
#
# # 若挖机可用时间严重偏离,进行修正
# if abs(self.cur_shovel_ava_time[shovel_index] - now) > 60:
# self.cur_truck_ava_time[int(tmp[i][1])] = now
# if abs(self.cur_shovel_ava_time[shovel_index] - now) > 60:
# self.cur_shovel_ava_time[shovel_index] = now
# except Exception as es:
# logger.error("挖机可用时间计算异常")
# logger.error(es)
def
period_update
(
self
):
print
(
"Shovel update!"
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 装载映射关系
# 装载映射关系
self
.
load
()
self
.
load
()
# # 初始化挖机可用时间
# # 初始化挖机可用时间
<<<<<<<
HEAD
# self.cur_excavator_ava_time = np.full(self.excavators,
# self.cur_excavator_ava_time = np.full(self.excavators,
=======
# self.cur_shovel_ava_time = np.full(self.shovels,
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# (datetime.now() - self.start_time) / timedelta(hours=0, minutes=1,
# (datetime.now() - self.start_time) / timedelta(hours=0, minutes=1,
# seconds=0))
# seconds=0))
# 用于动态调度的挖机设备
# 用于动态调度的挖机设备
self
.
dynamic_excavator_set
=
set
(
update_autodisp_excavator
())
self
.
dynamic_excavator_set
=
set
(
update_autodisp_excavator
())
<<<<<<<
HEAD
self
.
excavators
=
len
(
self
.
dynamic_excavator_set
)
self
.
excavators
=
len
(
self
.
dynamic_excavator_set
)
=======
self
.
shovels
=
len
(
self
.
dynamic_excavator_set
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 计算平均装载时间
# 计算平均装载时间
self
.
update_excavator_loadtime
()
self
.
update_excavator_loadtime
()
...
@@ -333,6 +504,7 @@ class ExcavatorInfo(DeviceMap):
...
@@ -333,6 +504,7 @@ class ExcavatorInfo(DeviceMap):
self
.
update_actual_load_throughout
()
self
.
update_actual_load_throughout
()
# 挖机目标产量
# 挖机目标产量
<<<<<<<
HEAD
self
.
excavator_target_mass
=
np
.
full
(
self
.
excavators
,
excavator_target_mass
)
self
.
excavator_target_mass
=
np
.
full
(
self
.
excavators
,
excavator_target_mass
)
# # 同步挖机虚拟装载量
# # 同步挖机虚拟装载量
...
@@ -460,6 +632,36 @@ class TruckInfo(DeviceMap):
...
@@ -460,6 +632,36 @@ class TruckInfo(DeviceMap):
self
.
last_load_time
=
{}
self
.
last_load_time
=
{}
self
.
last_unload_time
=
{}
self
.
last_unload_time
=
{}
# 相对矿卡最后装载/卸载时间
# 相对矿卡最后装载/卸载时间
=======
self
.
excavator_target_mass
=
np
.
full
(
self
.
shovels
,
shovel_target_mass
)
# # 同步挖机虚拟装载量
# self.sim_shovel_real_mass = copy.deepcopy(self.cur_shovel_real_mass)
# # 计算卸载点预估产量
# self.update_pre_load_throughout()
class
TruckInfo
(
DeviceMap
):
def
__init__
(
self
):
super
()
.
__init__
()
# 矿卡数量
self
.
trucks
=
len
(
dynamic_truck_set
)
# 矿卡抵达卸点时间
self
.
cur_truck_reach_dump
=
np
.
zeros
(
self
.
trucks
)
# 矿卡抵达挖机时间
self
.
cur_truck_reach_shovel
=
np
.
zeros
(
self
.
trucks
)
# 用于动态派车的矿卡集合
self
.
dynamic_truck_set
=
[]
# 用于动态派车的挖机集合
self
.
dynamic_excavator_set
=
[]
# 用于动态调度的卸载点集合
self
.
dynamic_dump_set
=
[]
# 矿卡装载/卸载时间
self
.
last_load_time
=
{}
self
.
last_unload_time
=
{}
# 相对矿卡装载/卸载时间
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
relative_last_load_time
=
{}
self
.
relative_last_load_time
=
{}
self
.
relative_last_unload_time
=
{}
self
.
relative_last_unload_time
=
{}
# 矿卡当前任务
# 矿卡当前任务
...
@@ -473,6 +675,7 @@ class TruckInfo(DeviceMap):
...
@@ -473,6 +675,7 @@ class TruckInfo(DeviceMap):
self
.
payload
=
np
.
zeros
(
self
.
trucks
)
self
.
payload
=
np
.
zeros
(
self
.
trucks
)
# 矿卡当前行程(第一列为出发地序号, 第二列为目的地序号)
# 矿卡当前行程(第一列为出发地序号, 第二列为目的地序号)
self
.
truck_current_trip
=
np
.
full
((
self
.
trucks
,
2
),
-
1
)
self
.
truck_current_trip
=
np
.
full
((
self
.
trucks
,
2
),
-
1
)
<<<<<<<
HEAD
def
get_truck_current_trip
(
self
):
def
get_truck_current_trip
(
self
):
return
self
.
truck_current_trip
return
self
.
truck_current_trip
...
@@ -501,6 +704,11 @@ class TruckInfo(DeviceMap):
...
@@ -501,6 +704,11 @@ class TruckInfo(DeviceMap):
def
get_payload
(
self
):
def
get_payload
(
self
):
return
self
.
payload
return
self
.
payload
=======
# 矿卡最后装载/卸载时间
self
.
last_load_time
=
{}
self
.
last_unload_time
=
{}
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 更新矿卡当前任务
# 更新矿卡当前任务
def
update_truck_current_task
(
self
):
def
update_truck_current_task
(
self
):
...
@@ -584,10 +792,13 @@ class TruckInfo(DeviceMap):
...
@@ -584,10 +792,13 @@ class TruckInfo(DeviceMap):
# 更新矿卡行程
# 更新矿卡行程
def
update_truck_trip
(
self
):
def
update_truck_trip
(
self
):
<<<<<<<
HEAD
com_time_area
=
self
.
walker
.
get_com_time_area
()
com_time_area
=
self
.
walker
.
get_com_time_area
()
go_time_area
=
self
.
walker
.
get_go_time_area
()
go_time_area
=
self
.
walker
.
get_go_time_area
()
=======
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 初始化矿卡行程, -1代表备停区
# 初始化矿卡行程, -1代表备停区
self
.
truck_current_trip
=
np
.
full
((
self
.
trucks
,
2
),
-
1
)
self
.
truck_current_trip
=
np
.
full
((
self
.
trucks
,
2
),
-
1
)
for
i
in
range
(
self
.
trucks
):
for
i
in
range
(
self
.
trucks
):
...
@@ -616,10 +827,17 @@ class TruckInfo(DeviceMap):
...
@@ -616,10 +827,17 @@ class TruckInfo(DeviceMap):
self
.
excavator_uuid_to_index_dict
[
item
.
exactor_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:
# if truck_uuid_to_name_dict[self.truck_index_to_uuid_dict[i]] in tmp_set:
# print("here")
# print("here")
<<<<<<<
HEAD
# self.cur_truck_reach_excavator[i] = last_unload_time + 10 * self.com_time_area[start_area_index][
# self.cur_truck_reach_excavator[i] = last_unload_time + 10 * self.com_time_area[start_area_index][
# end_area_index]
# end_area_index]
# else:
# else:
self
.
cur_truck_reach_excavator
[
i
]
=
last_unload_time
+
com_time_area
[
start_area_index
][
self
.
cur_truck_reach_excavator
[
i
]
=
last_unload_time
+
com_time_area
[
start_area_index
][
=======
# self.cur_truck_reach_shovel[i] = last_unload_time + 10 * self.com_time_area[start_area_index][
# end_area_index]
# else:
self
.
cur_truck_reach_shovel
[
i
]
=
last_unload_time
+
self
.
com_time_area
[
start_area_index
][
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
end_area_index
]
end_area_index
]
# 若矿卡状态为重载
# 若矿卡状态为重载
elif
task
in
heavy_task_set
:
elif
task
in
heavy_task_set
:
...
@@ -636,7 +854,11 @@ class TruckInfo(DeviceMap):
...
@@ -636,7 +854,11 @@ class TruckInfo(DeviceMap):
end_area_index
=
unload_area_uuid_to_index_dict
[
end_area_id
]
end_area_index
=
unload_area_uuid_to_index_dict
[
end_area_id
]
self
.
truck_current_trip
[
i
]
=
[
self
.
excavator_uuid_to_index_dict
[
item
.
exactor_id
],
self
.
truck_current_trip
[
i
]
=
[
self
.
excavator_uuid_to_index_dict
[
item
.
exactor_id
],
self
.
dump_uuid_to_index_dict
[
item
.
dump_id
]]
self
.
dump_uuid_to_index_dict
[
item
.
dump_id
]]
<<<<<<<
HEAD
self
.
cur_truck_reach_dump
[
i
]
=
last_load_time
+
go_time_area
[
end_area_index
][
start_area_index
]
self
.
cur_truck_reach_dump
[
i
]
=
last_load_time
+
go_time_area
[
end_area_index
][
start_area_index
]
=======
self
.
cur_truck_reach_dump
[
i
]
=
last_load_time
+
self
.
go_time_area
[
end_area_index
][
start_area_index
]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 其他状态,矿卡状态为-2,equipment_pair表不存在该矿卡
# 其他状态,矿卡状态为-2,equipment_pair表不存在该矿卡
else
:
else
:
pass
pass
...
@@ -648,13 +870,43 @@ class TruckInfo(DeviceMap):
...
@@ -648,13 +870,43 @@ class TruckInfo(DeviceMap):
# print("当前矿卡行程:")
# print("当前矿卡行程:")
# print(self.truck_current_trip)
# print(self.truck_current_trip)
<<<<<<<
HEAD
=======
# 更新矿卡预计抵达目的地时间
def
update_truck_reach_time
(
self
):
try
:
shovel_ava_ls
=
[[]
for
_
in
range
(
self
.
shovels
)]
dump_ava_ls
=
[[]
for
_
in
range
(
self
.
dumps
)]
for
i
in
range
(
self
.
trucks
):
task
=
self
.
truck_current_task
[
self
.
truck_index_to_uuid_dict
[
i
]]
end_area_index
=
self
.
truck_current_trip
[
i
][
1
]
if
task
in
empty_task_set
:
reach_time
=
self
.
cur_truck_reach_shovel
[
i
]
shovel_ava_ls
[
end_area_index
]
.
append
([
reach_time
,
i
,
end_area_index
])
elif
task
in
heavy_task_set
:
reach_time
=
self
.
cur_truck_reach_dump
[
i
]
dump_ava_ls
[
end_area_index
]
.
append
([
reach_time
,
i
,
end_area_index
])
elif
task
==
-
2
:
self
.
cur_truck_ava_time
[
i
]
=
(
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
)
except
Exception
as
es
:
logger
.
error
(
"矿卡预计抵达时间计算异常"
)
logger
.
error
(
es
)
return
shovel_ava_ls
,
dump_ava_ls
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
def
period_update
(
self
):
def
period_update
(
self
):
print
(
"Truck update!"
)
print
(
"Truck update!"
)
<<<<<<<
HEAD
# 更新行走队形
# 更新行走队形
self
.
walker
.
update_walk_time
()
self
.
walker
.
update_walk_time
()
=======
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 更新装载映射关系
# 更新装载映射关系
self
.
load
()
self
.
load
()
...
@@ -683,6 +935,7 @@ class TruckInfo(DeviceMap):
...
@@ -683,6 +935,7 @@ class TruckInfo(DeviceMap):
self
.
update_truck_trip
()
self
.
update_truck_trip
()
<<<<<<<
HEAD
# 调度类
# 调度类
class
Dispatcher
(
DeviceMap
):
class
Dispatcher
(
DeviceMap
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -713,10 +966,41 @@ class Dispatcher(DeviceMap):
...
@@ -713,10 +966,41 @@ class Dispatcher(DeviceMap):
# 维护一个矿卡调度表
# 维护一个矿卡调度表
self
.
Seq
=
[[]
for
_
in
range
(
self
.
truck
.
get_truck_num
())]
self
.
Seq
=
[[]
for
_
in
range
(
self
.
truck
.
get_truck_num
())]
=======
class
Dispatcher
(
DeviceMap
):
def
__init__
(
self
):
# 三类设备field
self
.
dump
=
DumpInfo
()
self
.
excavator
=
ExcavatorInfo
()
self
.
truck
=
TruckInfo
()
# 模拟挖机/卸点产量(防止调度修改真实产量)
self
.
sim_dump_real_mass
=
np
.
zeros
(
self
.
dump
.
dumps
)
self
.
sim_shovel_real_mass
=
np
.
zeros
(
self
.
excavator
.
shovels
)
# 真实设备可用时间
self
.
cur_truck_reach_dump
=
np
.
zeros
(
self
.
truck
.
trucks
)
self
.
cur_truck_reach_shovel
=
np
.
zeros
(
self
.
truck
.
trucks
)
self
.
cur_shovel_ava_time
=
np
.
zeros
(
self
.
excavator
.
shovels
)
self
.
cur_dump_ava_time
=
np
.
zeros
(
self
.
dump
.
dumps
)
# 卡车完成装载及卸载时间(矿卡可用时间)
self
.
cur_truck_ava_time
=
np
.
zeros
(
self
.
truck
.
trucks
)
# 模拟矿卡可用时间
self
.
sim_truck_ava_time
=
np
.
zeros
(
self
.
truck
.
trucks
)
# 模拟各设备可用时间(防止调度修改真实产量)
self
.
sim_shovel_ava_time
=
np
.
zeros
(
self
.
excavator
.
shovels
)
self
.
sim_dump_ava_time
=
np
.
zeros
(
self
.
dump
.
dumps
)
# 挖机/卸点预计产量(包含正在驶往挖机/卸点那部分矿卡的载重)
self
.
pre_dump_real_mass
=
np
.
zeros
(
self
.
dump
.
dumps
)
self
.
pre_shovel_real_mass
=
np
.
zeros
(
self
.
excavator
.
shovels
)
# 维护一个矿卡调度表
self
.
Seq
=
[[]
for
_
in
range
(
self
.
truck
.
trucks
)]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 调度开始时间
# 调度开始时间
self
.
start_time
=
datetime
.
now
()
self
.
start_time
=
datetime
.
now
()
# self.relative_now_time = datetime.now() - self.start_time
# self.relative_now_time = datetime.now() - self.start_time
<<<<<<<
HEAD
# 下面是交通流调度部分
# 下面是交通流调度部分
# 驶往挖机的实际车流
# 驶往挖机的实际车流
self
.
actual_goto_excavator_traffic_flow
=
np
.
zeros
((
self
.
dump
.
get_dump_num
(),
self
.
excavator
.
get_excavator_num
()))
self
.
actual_goto_excavator_traffic_flow
=
np
.
zeros
((
self
.
dump
.
get_dump_num
(),
self
.
excavator
.
get_excavator_num
()))
...
@@ -732,10 +1016,148 @@ class Dispatcher(DeviceMap):
...
@@ -732,10 +1016,148 @@ class Dispatcher(DeviceMap):
self
.
opt_goto_dump_traffic_flow
=
np
.
zeros
((
self
.
dump
.
get_dump_num
(),
self
.
excavator
.
get_excavator_num
()))
self
.
opt_goto_dump_traffic_flow
=
np
.
zeros
((
self
.
dump
.
get_dump_num
(),
self
.
excavator
.
get_excavator_num
()))
# 驶往卸载设备的实际车流
# 驶往卸载设备的实际车流
self
.
opt_goto_excavator_traffic_flow
=
np
.
zeros
((
self
.
dump
.
get_dump_num
(),
self
.
excavator
.
get_excavator_num
()))
self
.
opt_goto_excavator_traffic_flow
=
np
.
zeros
((
self
.
dump
.
get_dump_num
(),
self
.
excavator
.
get_excavator_num
()))
=======
# 工作区和设备不具备一一对应关系, 为方便就计算, 算法维护两套路网: 面向路网和面向设备
# 行走时间(面向路网)
self
.
com_time_area
=
np
.
full
((
unload_area_num
,
load_area_num
),
M
)
self
.
go_time_area
=
np
.
full
((
unload_area_num
,
load_area_num
),
M
)
# 行走时间(面向设备)
self
.
com_time_eq
=
np
.
full
((
self
.
dump
.
dumps
,
self
.
excavator
.
shovels
),
M
)
self
.
go_time_eq
=
np
.
full
((
self
.
dump
.
dumps
,
self
.
excavator
.
shovels
),
M
)
# 备停区行走时间(面向路网)
self
.
park_to_load_area
=
np
.
full
((
park_num
,
load_area_num
),
M
)
# 备停区行走时间(面向设备)
self
.
park_to_load_eq
=
np
.
full
((
park_num
,
self
.
excavator
.
shovels
),
M
)
# 下面是交通流调度部分
# 驶往挖机的实际车流
self
.
actual_goto_excavator_traffic_flow
=
np
.
zeros
((
self
.
dump
.
dumps
,
self
.
excavator
.
shovels
))
# 驶往卸点的实际车流
self
.
actual_goto_dump_traffic_flow
=
np
.
zeros
((
self
.
dump
.
dumps
,
self
.
excavator
.
shovels
))
# 驶往挖机的实际车次
self
.
goto_dump_truck_num
=
np
.
zeros
((
self
.
dump
.
dumps
,
self
.
excavator
.
shovels
))
# 驶往卸点的实际车次
self
.
goto_excavator_truck_num
=
np
.
zeros
((
self
.
dump
.
dumps
,
self
.
excavator
.
shovels
))
# 驶往挖机的理想车流
self
.
opt_goto_dump_traffic_flow
=
np
.
zeros
((
self
.
dump
.
dumps
,
self
.
excavator
.
shovels
))
# 驶往卸点的实际车流
self
.
opt_goto_excavator_traffic_flow
=
np
.
zeros
((
self
.
dump
.
dumps
,
self
.
excavator
.
shovels
))
# def update_deveices_map(self):
# self.excavator_uuid_to_index_dict = {} # 用于将Excavator表中的area_id映射到index
# self.dump_uuid_to_index_dict = {} # 用于将Dump表中的area_id映射到index
# self.excavator_index_to_uuid_dict = {} # 用于将index映射到Excavator表中的area_id
# self.dump_index_to_uuid_dict = {} # 用于将index映射到Dump表中的area_id
#
# 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 = {}
#
# try:
# excavator_num = 0
# dump_num = 0
# for item in session_mysql.query(Dispatch).filter_by(isdeleted=0, isauto=1).all():
# # excavator_id <-> excavator_index
# # dump_id <-> dump_index
# # excavator_id <-> load_area_id
# # dump_id <-> unload_area_id
# # excavator_index <-> load_area_index
# # dump_index <-> unload_area_index
# excavator_id = item.exactor_id
# load_area_id = item.load_area_id
# unload_area_id = item.unload_area_id
# dump_id = item.dump_id
# if dump_id not in self.dump_uuid_to_unload_area_uuid_dict:
# self.dump_uuid_to_index_dict[dump_id] = dump_num
# self.dump_index_to_uuid_dict[dump_num] = dump_id
# self.dump_uuid_to_unload_area_uuid_dict[dump_id] = unload_area_id
# self.dump_index_to_unload_area_index_dict[self.dump_uuid_to_index_dict[dump_id]] = \
# unload_area_uuid_to_index_dict[unload_area_id]
# dump_num = dump_num + 1
# if excavator_id not in self.excavator_uuid_to_index_dict:
# self.excavator_uuid_to_index_dict[excavator_id] = excavator_num
# self.excavator_index_to_uuid_dict[excavator_num] = excavator_id
# self.excavator_uuid_to_load_area_uuid_dict[excavator_id] = load_area_id
# self.excavator_index_to_load_area_index_dict[self.excavator_uuid_to_index_dict[excavator_id]] = \
# load_area_uuid_to_index_dict[load_area_id]
# excavator_num = excavator_num + 1
# if excavator_num < 1 or dump_num < 1:
# raise Exception("无动态派车计划可用-动态派车挖机/卸点映射失败")
# except Exception as es:
# logger.warning(es)
# def update_truck_uuid_index_map(self):
# self.truck_uuid_to_index_dict = {}
# self.truck_index_to_uuid_dict = {}
#
# # truck_id <-> truck_index
# truck_num = 0
# for truck_id in self.dynamic_truck_set:
# self.truck_uuid_to_index_dict[truck_id] = truck_num
# self.truck_index_to_uuid_dict[truck_num] = truck_id
# truck_num = truck_num + 1
def
update_walk_time
(
self
):
# 计算路网行走时间
try
:
# 处理距离
for
item
in
session_postgre
.
query
(
WalkTime
)
.
all
():
load_area
=
str
(
item
.
load_area_id
)
unload_area
=
str
(
item
.
unload_area_id
)
load_area_index
=
load_area_uuid_to_index_dict
[
load_area
]
unload_area_index
=
unload_area_uuid_to_index_dict
[
unload_area
]
self
.
com_time_area
[
unload_area_index
][
load_area_index
]
=
float
(
60
/
1000
*
item
.
to_load_distance
/
empty_speed
)
self
.
go_time_area
[
unload_area_index
][
load_area_index
]
=
float
(
60
/
1000
*
item
.
to_unload_distance
/
heavy_speed
)
except
Exception
as
es
:
logger
.
error
(
"路网信息异常"
)
logger
.
error
(
es
)
# 计算设备路网行走时间
try
:
for
i
in
range
(
self
.
dump
.
dumps
):
for
j
in
range
(
self
.
excavator
.
shovels
):
self
.
com_time_eq
[
i
][
j
]
=
self
.
com_time_area
[
self
.
dump_index_to_unload_area_index_dict
[
i
]]
\
[
self
.
excavator_index_to_load_area_index_dict
[
j
]]
self
.
go_time_eq
[
i
][
j
]
=
self
.
go_time_area
[
self
.
dump_index_to_unload_area_index_dict
[
i
]]
\
[
self
.
excavator_index_to_load_area_index_dict
[
j
]]
except
Exception
as
es
:
logger
.
error
(
"设备路网信息异常异常"
)
logger
.
error
(
es
)
try
:
for
item
in
session_postgre
.
query
(
WalkTimePort
)
.
all
():
load_area
=
str
(
item
.
load_area_id
)
park_area
=
str
(
item
.
park_area_id
)
load_area_index
=
load_area_uuid_to_index_dict
[
load_area
]
park_index
=
park_uuid_to_index_dict
[
park_area
]
self
.
park_to_load_area
[
park_index
][
load_area_index
]
=
60
/
1000
*
item
.
park_load_distance
/
empty_speed
except
Exception
as
es
:
logger
.
error
(
"备停区路网信息异常"
)
logger
.
error
(
es
)
try
:
for
i
in
range
(
park_num
):
for
j
in
range
(
self
.
excavator
.
shovels
):
self
.
park_to_load_eq
[
i
][
j
]
=
self
.
park_to_load_area
[
i
][
self
.
excavator_index_to_load_area_index_dict
[
j
]]
except
Exception
as
es
:
logger
.
error
(
"备停区设备路网信息异常"
)
logger
.
error
(
es
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 更新矿卡预计抵达目的地时间
# 更新矿卡预计抵达目的地时间
def
update_truck_reach_time
(
self
):
def
update_truck_reach_time
(
self
):
try
:
try
:
<<<<<<<
HEAD
excavators
=
self
.
excavator
.
get_excavator_num
()
excavators
=
self
.
excavator
.
get_excavator_num
()
dumps
=
self
.
dump
.
get_dump_num
()
dumps
=
self
.
dump
.
get_dump_num
()
trucks
=
self
.
truck
.
get_truck_num
()
trucks
=
self
.
truck
.
get_truck_num
()
...
@@ -749,13 +1171,33 @@ class Dispatcher(DeviceMap):
...
@@ -749,13 +1171,33 @@ class Dispatcher(DeviceMap):
cur_truck_reach_dump
=
self
.
truck
.
get_truck_reach_dump
()
cur_truck_reach_dump
=
self
.
truck
.
get_truck_reach_dump
()
excavator_ava_ls
=
[[]
for
_
in
range
(
excavators
)]
excavator_ava_ls
=
[[]
for
_
in
range
(
excavators
)]
=======
shovels
=
self
.
excavator
.
shovels
dumps
=
self
.
dump
.
dumps
trucks
=
self
.
truck
.
trucks
truck_current_task
=
self
.
truck
.
truck_current_task
truck_current_trip
=
self
.
truck
.
truck_current_trip
cur_truck_reach_shovel
=
self
.
truck
.
cur_truck_reach_shovel
cur_truck_reach_dump
=
self
.
truck
.
cur_truck_reach_dump
shovel_ava_ls
=
[[]
for
_
in
range
(
shovels
)]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
dump_ava_ls
=
[[]
for
_
in
range
(
dumps
)]
dump_ava_ls
=
[[]
for
_
in
range
(
dumps
)]
for
i
in
range
(
trucks
):
for
i
in
range
(
trucks
):
task
=
truck_current_task
[
self
.
truck_index_to_uuid_dict
[
i
]]
task
=
truck_current_task
[
self
.
truck_index_to_uuid_dict
[
i
]]
end_area_index
=
truck_current_trip
[
i
][
1
]
end_area_index
=
truck_current_trip
[
i
][
1
]
if
task
in
empty_task_set
:
if
task
in
empty_task_set
:
<<<<<<<
HEAD
reach_time
=
cur_truck_reach_excavator
[
i
]
reach_time
=
cur_truck_reach_excavator
[
i
]
excavator_ava_ls
[
end_area_index
]
.
append
([
reach_time
,
i
,
end_area_index
])
excavator_ava_ls
[
end_area_index
]
.
append
([
reach_time
,
i
,
end_area_index
])
=======
reach_time
=
cur_truck_reach_shovel
[
i
]
shovel_ava_ls
[
end_area_index
]
.
append
([
reach_time
,
i
,
end_area_index
])
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
elif
task
in
heavy_task_set
:
elif
task
in
heavy_task_set
:
reach_time
=
cur_truck_reach_dump
[
i
]
reach_time
=
cur_truck_reach_dump
[
i
]
dump_ava_ls
[
end_area_index
]
.
append
([
reach_time
,
i
,
end_area_index
])
dump_ava_ls
[
end_area_index
]
.
append
([
reach_time
,
i
,
end_area_index
])
...
@@ -766,6 +1208,7 @@ class Dispatcher(DeviceMap):
...
@@ -766,6 +1208,7 @@ class Dispatcher(DeviceMap):
logger
.
error
(
"矿卡预计抵达时间计算异常"
)
logger
.
error
(
"矿卡预计抵达时间计算异常"
)
logger
.
error
(
es
)
logger
.
error
(
es
)
<<<<<<<
HEAD
return
excavator_ava_ls
,
dump_ava_ls
return
excavator_ava_ls
,
dump_ava_ls
# 更新挖机预计可用时间
# 更新挖机预计可用时间
...
@@ -773,15 +1216,26 @@ class Dispatcher(DeviceMap):
...
@@ -773,15 +1216,26 @@ class Dispatcher(DeviceMap):
loading_time
=
self
.
excavator
.
get_loading_time
()
loading_time
=
self
.
excavator
.
get_loading_time
()
=======
return
shovel_ava_ls
,
dump_ava_ls
# 更新挖机预计可用时间
def
update_shovel_ava_time
(
self
,
shovel_ava_ls
):
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
try
:
try
:
now
=
float
((
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
))
now
=
float
((
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
))
<<<<<<<
HEAD
for
reach_ls
in
excavator_ava_ls
:
for
reach_ls
in
excavator_ava_ls
:
=======
for
reach_ls
in
shovel_ava_ls
:
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
if
len
(
reach_ls
)
!=
0
:
if
len
(
reach_ls
)
!=
0
:
reach_ls
=
np
.
array
(
reach_ls
)
reach_ls
=
np
.
array
(
reach_ls
)
tmp
=
reach_ls
[
np
.
lexsort
(
reach_ls
[:,
::
-
1
]
.
T
)]
tmp
=
reach_ls
[
np
.
lexsort
(
reach_ls
[:,
::
-
1
]
.
T
)]
for
i
in
range
(
len
(
tmp
)):
for
i
in
range
(
len
(
tmp
)):
<<<<<<<
HEAD
excavator_index
=
int
(
tmp
[
i
][
2
])
excavator_index
=
int
(
tmp
[
i
][
2
])
self
.
cur_excavator_ava_time
[
excavator_index
]
=
max
(
tmp
[
i
][
0
],
self
.
cur_excavator_ava_time
[
excavator_index
]
=
max
(
tmp
[
i
][
0
],
self
.
cur_excavator_ava_time
[
excavator_index
])
+
\
self
.
cur_excavator_ava_time
[
excavator_index
])
+
\
...
@@ -793,15 +1247,33 @@ class Dispatcher(DeviceMap):
...
@@ -793,15 +1247,33 @@ class Dispatcher(DeviceMap):
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
=
now
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
=
now
if
abs
(
self
.
cur_excavator_ava_time
[
excavator_index
]
-
now
)
>
60
:
if
abs
(
self
.
cur_excavator_ava_time
[
excavator_index
]
-
now
)
>
60
:
self
.
cur_excavator_ava_time
[
excavator_index
]
=
now
self
.
cur_excavator_ava_time
[
excavator_index
]
=
now
=======
shovel_index
=
int
(
tmp
[
i
][
2
])
self
.
cur_shovel_ava_time
[
shovel_index
]
=
max
(
tmp
[
i
][
0
],
self
.
cur_shovel_ava_time
[
shovel_index
])
+
\
self
.
loading_time
[
shovel_index
]
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
=
self
.
cur_shovel_ava_time
[
shovel_index
]
# 若挖机可用时间严重偏离,进行修正
if
abs
(
self
.
cur_shovel_ava_time
[
shovel_index
]
-
now
)
>
60
:
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
=
now
if
abs
(
self
.
cur_shovel_ava_time
[
shovel_index
]
-
now
)
>
60
:
self
.
cur_shovel_ava_time
[
shovel_index
]
=
now
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
error
(
"挖机可用时间计算异常"
)
logger
.
error
(
"挖机可用时间计算异常"
)
logger
.
error
(
es
)
logger
.
error
(
es
)
<<<<<<<
HEAD
# 更新卸载设备预计可用时间
# 更新卸载设备预计可用时间
def
update_dump_ava_time
(
self
,
dump_ava_ls
):
def
update_dump_ava_time
(
self
,
dump_ava_ls
):
unloading_time
=
self
.
dump
.
get_unloading_time
()
unloading_time
=
self
.
dump
.
get_unloading_time
()
=======
# 更新卸点预计可用时间
def
update_dump_ava_time
(
self
,
dump_ava_ls
):
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
try
:
try
:
now
=
float
((
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
))
now
=
float
((
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
))
...
@@ -813,20 +1285,32 @@ class Dispatcher(DeviceMap):
...
@@ -813,20 +1285,32 @@ class Dispatcher(DeviceMap):
for
i
in
range
(
len
(
tmp
)):
for
i
in
range
(
len
(
tmp
)):
dump_index
=
int
(
tmp
[
i
][
2
])
dump_index
=
int
(
tmp
[
i
][
2
])
self
.
cur_dump_ava_time
[
dump_index
]
=
max
(
tmp
[
i
][
0
],
self
.
cur_dump_ava_time
[
dump_index
])
+
\
self
.
cur_dump_ava_time
[
dump_index
]
=
max
(
tmp
[
i
][
0
],
self
.
cur_dump_ava_time
[
dump_index
])
+
\
<<<<<<<
HEAD
unloading_time
[
dump_index
]
unloading_time
[
dump_index
]
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
=
self
.
cur_dump_ava_time
[
dump_index
]
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
=
self
.
cur_dump_ava_time
[
dump_index
]
# 若卸载设备可用时间严重偏离,进行修正
# 若卸载设备可用时间严重偏离,进行修正
=======
self
.
unloading_time
[
dump_index
]
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
=
self
.
cur_dump_ava_time
[
dump_index
]
# 若卸点可用时间严重偏离,进行修正
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
if
abs
(
self
.
cur_dump_ava_time
[
dump_index
]
-
now
)
>
60
:
if
abs
(
self
.
cur_dump_ava_time
[
dump_index
]
-
now
)
>
60
:
self
.
cur_dump_ava_time
[
dump_index
]
=
now
self
.
cur_dump_ava_time
[
dump_index
]
=
now
if
abs
(
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
-
now
)
>
60
:
if
abs
(
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
-
now
)
>
60
:
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
=
now
self
.
cur_truck_ava_time
[
int
(
tmp
[
i
][
1
])]
=
now
except
Exception
as
es
:
except
Exception
as
es
:
<<<<<<<
HEAD
logger
.
error
(
"卸载设备可用时间计算异常"
)
logger
.
error
(
"卸载设备可用时间计算异常"
)
=======
logger
.
error
(
"卸点可用时间计算异常"
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
logger
.
error
(
es
)
logger
.
error
(
es
)
# 更新实际交通流
# 更新实际交通流
def
update_actual_traffic_flow
(
self
):
def
update_actual_traffic_flow
(
self
):
<<<<<<<
HEAD
truck_current_task
=
self
.
truck
.
get_truck_current_task
()
truck_current_task
=
self
.
truck
.
get_truck_current_task
()
payload
=
self
.
truck
.
get_payload
()
payload
=
self
.
truck
.
get_payload
()
...
@@ -835,17 +1319,31 @@ class Dispatcher(DeviceMap):
...
@@ -835,17 +1319,31 @@ class Dispatcher(DeviceMap):
dump_index
=
self
.
dump_uuid_to_index_dict
[
item
.
dump_id
]
dump_index
=
self
.
dump_uuid_to_index_dict
[
item
.
dump_id
]
excavator_index
=
self
.
excavator_uuid_to_index_dict
[
item
.
exactor_id
]
excavator_index
=
self
.
excavator_uuid_to_index_dict
[
item
.
exactor_id
]
task
=
truck_current_task
[
item
.
truck_id
]
task
=
truck_current_task
[
item
.
truck_id
]
=======
for
item
in
session_mysql
.
query
(
EquipmentPair
)
.
filter
(
EquipmentPair
.
createtime
>=
self
.
start_time
)
.
all
():
dump_index
=
self
.
dump_uuid_to_index_dict
[
item
.
dump_id
]
excavator_index
=
self
.
excavator_uuid_to_index_dict
[
item
.
exactor_id
]
task
=
self
.
truck_current_task
[
item
.
truck_id
]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
if
task
in
heavy_task_set
:
if
task
in
heavy_task_set
:
self
.
goto_dump_truck_num
[
dump_index
][
excavator_index
]
=
\
self
.
goto_dump_truck_num
[
dump_index
][
excavator_index
]
=
\
self
.
goto_dump_truck_num
[
dump_index
][
excavator_index
]
+
1
self
.
goto_dump_truck_num
[
dump_index
][
excavator_index
]
+
1
self
.
actual_goto_dump_traffic_flow
[
dump_index
][
excavator_index
]
=
\
self
.
actual_goto_dump_traffic_flow
[
dump_index
][
excavator_index
]
=
\
<<<<<<<
HEAD
self
.
actual_goto_dump_traffic_flow
[
dump_index
][
excavator_index
]
+
float
(
payload
[
item
.
truck_id
])
self
.
actual_goto_dump_traffic_flow
[
dump_index
][
excavator_index
]
+
float
(
payload
[
item
.
truck_id
])
=======
self
.
actual_goto_dump_traffic_flow
[
dump_index
][
excavator_index
]
+
float
(
self
.
payload
[
item
.
truck_id
])
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
if
task
in
empty_task_set
:
if
task
in
empty_task_set
:
self
.
goto_excavator_truck_num
[
dump_index
][
excavator_index
]
=
\
self
.
goto_excavator_truck_num
[
dump_index
][
excavator_index
]
=
\
self
.
goto_excavator_truck_num
[
dump_index
][
excavator_index
]
+
1
self
.
goto_excavator_truck_num
[
dump_index
][
excavator_index
]
+
1
self
.
actual_goto_excavator_traffic_flow
[
dump_index
][
excavator_index
]
=
\
self
.
actual_goto_excavator_traffic_flow
[
dump_index
][
excavator_index
]
=
\
self
.
actual_goto_excavator_traffic_flow
[
dump_index
][
excavator_index
]
+
float
(
self
.
actual_goto_excavator_traffic_flow
[
dump_index
][
excavator_index
]
+
float
(
<<<<<<<
HEAD
payload
[
item
.
truck_id
])
payload
[
item
.
truck_id
])
=======
self
.
payload
[
item
.
truck_id
])
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
actual_goto_dump_traffic_flow
=
self
.
actual_goto_dump_traffic_flow
/
\
self
.
actual_goto_dump_traffic_flow
=
self
.
actual_goto_dump_traffic_flow
/
\
((
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
((
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
...
@@ -855,6 +1353,7 @@ class Dispatcher(DeviceMap):
...
@@ -855,6 +1353,7 @@ class Dispatcher(DeviceMap):
((
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
((
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
))
seconds
=
0
))
<<<<<<<
HEAD
# 更新卸载设备预计产量
# 更新卸载设备预计产量
def
update_pre_unload_throughout
(
self
):
def
update_pre_unload_throughout
(
self
):
...
@@ -874,10 +1373,29 @@ class Dispatcher(DeviceMap):
...
@@ -874,10 +1373,29 @@ class Dispatcher(DeviceMap):
pass
pass
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
error
(
"卸载设备预计装载量计算异常"
)
logger
.
error
(
"卸载设备预计装载量计算异常"
)
=======
# 更新卸点预计产量
def
update_pre_unload_throughout
(
self
):
try
:
self
.
pre_dump_real_mass
=
copy
.
deepcopy
(
self
.
dump
.
cur_dump_real_mass
)
for
i
in
range
(
self
.
truck
.
trucks
):
# task = self.truck_current_stage[i][0]
task
=
self
.
truck
.
truck_current_task
[
self
.
truck_index_to_uuid_dict
[
i
]]
end_area_index
=
self
.
truck
.
truck_current_trip
[
i
][
1
]
# 若矿卡正常行驶,需要将该部分载重计入实时产量
if
task
in
heavy_task_set
:
self
.
pre_dump_real_mass
[
end_area_index
]
=
self
.
pre_dump_real_mass
[
end_area_index
]
+
\
self
.
truck
.
payload
[
i
]
else
:
pass
except
Exception
as
es
:
logger
.
error
(
"卸点预计装载量计算异常"
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
logger
.
error
(
es
)
logger
.
error
(
es
)
# 更新挖机预计产量
# 更新挖机预计产量
def
update_pre_load_throughout
(
self
):
def
update_pre_load_throughout
(
self
):
<<<<<<<
HEAD
truck_current_task
=
self
.
truck
.
get_truck_current_task
()
truck_current_task
=
self
.
truck
.
get_truck_current_task
()
payload
=
self
.
truck
.
get_payload
()
payload
=
self
.
truck
.
get_payload
()
...
@@ -896,6 +1414,22 @@ class Dispatcher(DeviceMap):
...
@@ -896,6 +1414,22 @@ class Dispatcher(DeviceMap):
pass
pass
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
error
(
"挖机/卸载设备预计装载量计算异常"
)
logger
.
error
(
"挖机/卸载设备预计装载量计算异常"
)
=======
try
:
self
.
pre_shovel_real_mass
=
copy
.
deepcopy
(
self
.
excavator
.
cur_shovel_real_mass
)
for
i
in
range
(
self
.
truck
.
trucks
):
# task = self.truck_current_stage[i][0]
task
=
self
.
truck
.
truck_current_task
[
self
.
truck_index_to_uuid_dict
[
i
]]
end_area_index
=
self
.
truck
.
truck_current_trip
[
i
][
1
]
# 若矿卡正常行驶,需要将该部分载重计入实时产量
if
task
in
empty_task_set
:
self
.
pre_shovel_real_mass
[
end_area_index
]
=
self
.
pre_shovel_real_mass
[
end_area_index
]
+
\
self
.
truck
.
payload
[
i
]
else
:
pass
except
Exception
as
es
:
logger
.
error
(
"挖机/卸点预计装载量计算异常"
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
logger
.
error
(
es
)
logger
.
error
(
es
)
def
period_update
(
self
):
def
period_update
(
self
):
...
@@ -904,7 +1438,11 @@ class Dispatcher(DeviceMap):
...
@@ -904,7 +1438,11 @@ class Dispatcher(DeviceMap):
self
.
load
()
self
.
load
()
<<<<<<<
HEAD
# 更新卸载设备对象
# 更新卸载设备对象
=======
# 更新卸点对象
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
dump
.
period_update
()
self
.
dump
.
period_update
()
# 更新挖机对象
# 更新挖机对象
...
@@ -913,11 +1451,16 @@ class Dispatcher(DeviceMap):
...
@@ -913,11 +1451,16 @@ class Dispatcher(DeviceMap):
# 更新矿卡对象
# 更新矿卡对象
self
.
truck
.
period_update
()
self
.
truck
.
period_update
()
<<<<<<<
HEAD
# 更新距离参量
# 更新距离参量
self
.
walker
.
update_walk_time
()
self
.
walker
.
update_walk_time
()
# # 更新设备距离(不同于工作区距离)
# # 更新设备距离(不同于工作区距离)
# self.update_walk_time()
# self.update_walk_time()
=======
# 设备距离(不同于工作区距离)
self
.
update_walk_time
()
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 更新实时车流
# 更新实时车流
self
.
update_actual_traffic_flow
()
self
.
update_actual_traffic_flow
()
...
@@ -926,35 +1469,58 @@ class Dispatcher(DeviceMap):
...
@@ -926,35 +1469,58 @@ class Dispatcher(DeviceMap):
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
()
# 矿卡抵达时间
# 矿卡抵达时间
<<<<<<<
HEAD
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
)
# 卸载设备可用时间
# 卸载设备可用时间
=======
shovel_reach_list
,
dump_reach_list
=
self
.
update_truck_reach_time
()
# 挖机可用时间
self
.
update_shovel_ava_time
(
shovel_reach_list
)
# 卸点可用时间
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
update_dump_ava_time
(
dump_reach_list
)
self
.
update_dump_ava_time
(
dump_reach_list
)
# 挖机预计装载量
# 挖机预计装载量
self
.
update_pre_load_throughout
()
self
.
update_pre_load_throughout
()
<<<<<<<
HEAD
# 卸载设备预计卸载量
# 卸载设备预计卸载量
=======
# 卸点预计卸载量
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
update_pre_unload_throughout
()
self
.
update_pre_unload_throughout
()
def
sim_para_reset
(
self
):
def
sim_para_reset
(
self
):
# 设备可用时间重置
# 设备可用时间重置
self
.
sim_truck_ava_time
=
copy
.
deepcopy
(
self
.
cur_truck_ava_time
)
self
.
sim_truck_ava_time
=
copy
.
deepcopy
(
self
.
cur_truck_ava_time
)
<<<<<<<
HEAD
self
.
sim_excavator_ava_time
=
copy
.
deepcopy
(
self
.
cur_excavator_ava_time
)
self
.
sim_excavator_ava_time
=
copy
.
deepcopy
(
self
.
cur_excavator_ava_time
)
self
.
sim_dump_ava_time
=
copy
.
deepcopy
(
self
.
cur_dump_ava_time
)
self
.
sim_dump_ava_time
=
copy
.
deepcopy
(
self
.
cur_dump_ava_time
)
# 挖机\卸载设备产量重置
# 挖机\卸载设备产量重置
self
.
sim_dump_real_mass
=
copy
.
deepcopy
(
self
.
pre_dump_real_mass
)
self
.
sim_dump_real_mass
=
copy
.
deepcopy
(
self
.
pre_dump_real_mass
)
self
.
sim_excavator_real_mass
=
copy
.
deepcopy
(
self
.
pre_excavator_real_mass
)
self
.
sim_excavator_real_mass
=
copy
.
deepcopy
(
self
.
pre_excavator_real_mass
)
=======
self
.
sim_shovel_ava_time
=
copy
.
deepcopy
(
self
.
cur_shovel_ava_time
)
self
.
sim_dump_ava_time
=
copy
.
deepcopy
(
self
.
cur_dump_ava_time
)
# 电铲\卸载点产量重置
self
.
sim_dump_real_mass
=
copy
.
deepcopy
(
self
.
pre_dump_real_mass
)
self
.
sim_shovel_real_mass
=
copy
.
deepcopy
(
self
.
pre_shovel_real_mass
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
def
truck_schedule
(
self
,
truck_id
):
def
truck_schedule
(
self
,
truck_id
):
# 矿卡对应序号
# 矿卡对应序号
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
<<<<<<<
HEAD
# 矿卡行程
# 矿卡行程
trip
=
self
.
truck
.
get_truck_current_trip
()[
truck_index
]
trip
=
self
.
truck
.
get_truck_current_trip
()[
truck_index
]
# 矿卡当前任务
# 矿卡当前任务
...
@@ -971,6 +1537,14 @@ class Dispatcher(DeviceMap):
...
@@ -971,6 +1537,14 @@ class Dispatcher(DeviceMap):
park_to_load_eq
=
self
.
walker
.
get_park_to_load_eq
()
park_to_load_eq
=
self
.
walker
.
get_park_to_load_eq
()
go_time_eq
=
self
.
walker
.
get_o_time_eq
()
go_time_eq
=
self
.
walker
.
get_o_time_eq
()
com_time_eq
=
self
.
walker
.
get_com_time_eq
()
com_time_eq
=
self
.
walker
.
get_com_time_eq
()
=======
# 矿卡行程
trip
=
self
.
truck
.
truck_current_trip
[
truck_index
]
# 矿卡当前任务
task
=
self
.
truck
.
truck_current_task
[
self
.
truck_index_to_uuid_dict
[
truck_index
]]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
now
=
float
((
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
))
now
=
float
((
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
))
...
@@ -981,6 +1555,7 @@ class Dispatcher(DeviceMap):
...
@@ -981,6 +1555,7 @@ class Dispatcher(DeviceMap):
target
=
0
target
=
0
<<<<<<<
HEAD
if
task
==
-
2
:
if
task
==
-
2
:
logger
.
info
(
"矿卡状态:矿卡启动或故障恢复"
)
logger
.
info
(
"矿卡状态:矿卡启动或故障恢复"
)
logger
.
info
(
"矿卡行程:无"
)
logger
.
info
(
"矿卡行程:无"
)
...
@@ -993,6 +1568,25 @@ class Dispatcher(DeviceMap):
...
@@ -993,6 +1568,25 @@ class Dispatcher(DeviceMap):
target
=
np
.
argmax
(
10
*
(
1
-
self
.
sim_excavator_real_mass
/
excavator_target_mass
)
/
target
=
np
.
argmax
(
10
*
(
1
-
self
.
sim_excavator_real_mass
/
excavator_target_mass
)
/
(
np
.
maximum
(
self
.
sim_excavator_ava_time
,
(
np
.
maximum
(
self
.
sim_excavator_ava_time
,
now
+
park_to_load_eq
[
0
,
:])
+
loading_time
now
+
park_to_load_eq
[
0
,
:])
+
loading_time
=======
excavator_target_mass
=
self
.
excavator
.
excavator_target_mass
loading_time
=
self
.
excavator
.
loading_time
dump_target_mass
=
self
.
dump
.
dump_target_mass
unloading_time
=
self
.
dump
.
unloading_time
if
task
==
-
2
:
logger
.
info
(
"矿卡状态:矿卡启动或故障恢复"
)
logger
.
info
(
"矿卡行程:无"
)
logger
.
info
(
f
'涉及电铲:{list(self.excavator_uuid_to_index_dict.keys())}'
)
logger
.
info
(
f
'电铲饱和度:{(1 - self.sim_shovel_real_mass / excavator_target_mass)}'
)
logger
.
info
(
f
'行程时间:{(np.maximum(self.sim_shovel_ava_time, now + self.park_to_load_eq[0, :]) + loading_time - now)}'
)
logger
.
info
(
f
'行驶时间:{self.park_to_load_eq[0, :] + loading_time}'
)
target
=
np
.
argmax
(
10
*
(
1
-
self
.
sim_shovel_real_mass
/
shovel_target_mass
)
/
(
np
.
maximum
(
self
.
sim_shovel_ava_time
,
now
+
self
.
park_to_load_eq
[
0
,
:])
+
loading_time
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
-
now
))
-
now
))
# print("目的地: ", self.excavator_index_to_uuid_dict[target])
# print("目的地: ", self.excavator_index_to_uuid_dict[target])
...
@@ -1001,6 +1595,7 @@ class Dispatcher(DeviceMap):
...
@@ -1001,6 +1595,7 @@ class Dispatcher(DeviceMap):
logger
.
info
(
"矿卡状态:矿卡空载"
)
logger
.
info
(
"矿卡状态:矿卡空载"
)
logger
.
info
(
f
'矿卡行程:{self.dump_index_to_uuid_dict[trip[0]]}-{self.excavator_index_to_uuid_dict[trip[1]]}'
)
logger
.
info
(
f
'矿卡行程:{self.dump_index_to_uuid_dict[trip[0]]}-{self.excavator_index_to_uuid_dict[trip[1]]}'
)
<<<<<<<
HEAD
logger
.
info
(
f
'涉及卸载设备:{list(self.dump_uuid_to_index_dict.keys())}'
)
logger
.
info
(
f
'涉及卸载设备:{list(self.dump_uuid_to_index_dict.keys())}'
)
logger
.
info
(
f
'卸载设备饱和度:{(1 - self.sim_dump_real_mass / dump_target_mass)}'
)
logger
.
info
(
f
'卸载设备饱和度:{(1 - self.sim_dump_real_mass / dump_target_mass)}'
)
logger
.
info
(
logger
.
info
(
...
@@ -1027,6 +1622,34 @@ class Dispatcher(DeviceMap):
...
@@ -1027,6 +1622,34 @@ class Dispatcher(DeviceMap):
target
=
np
.
argmin
(
target
=
np
.
argmin
(
self
.
actual_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
/
self
.
opt_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:])
self
.
actual_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
/
self
.
opt_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:])
=======
logger
.
info
(
f
'涉及卸点:{list(self.dump_uuid_to_index_dict.keys())}'
)
logger
.
info
(
f
'卸点饱和度:{(1 - self.sim_dump_real_mass / dump_target_mass)}'
)
logger
.
info
(
f
'行程时间:{(np.maximum(self.sim_dump_ava_time, self.sim_truck_ava_time[truck_index] + self.go_time_eq[:, trip[1]]) + unloading_time - self.sim_truck_ava_time[truck_index])}'
)
logger
.
info
(
f
'行驶时间:{self.go_time_eq[:, trip[1]] + unloading_time}'
)
# 卡车空载,计算下一次卸载点
target
=
np
.
argmax
(
10
*
(
1
-
self
.
sim_dump_real_mass
/
dump_target_mass
)
/
(
np
.
maximum
(
self
.
sim_dump_ava_time
,
# self.sim_truck_reach_shovel[truck_index] + self.loading_time[trip[1]]
self
.
sim_truck_ava_time
[
truck_index
]
+
self
.
go_time_eq
[:,
trip
[
1
]])
+
unloading_time
-
self
.
sim_truck_ava_time
[
truck_index
]))
# try:
# assert self.actual_goto_dump_traffic_flow.shape == (self.shovels, self.dumps)
# assert self.opt_goto_dump_traffic_flow.shape == (self.shovels, self.dumps)
# except Exception as es:
# logger.warning(es)
# self.actual_goto_dump_traffic_flow = \
# np.array(self.actual_goto_dump_traffic_flow).reshape((self.shovels, self.dumps))
# self.opt_goto_dump_traffic_flow = \
# np.array(self.opt_goto_dump_traffic_flow).reshape((self.shovels, self.dumps))
#
# target = np.argmin(
# self.actual_goto_dump_traffic_flow[int(trip[1]), :] / self.opt_goto_dump_traffic_flow[int(trip[1]), :])
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
logger
.
info
(
f
'目的地:{self.dump_index_to_uuid_dict[target]}'
)
logger
.
info
(
f
'目的地:{self.dump_index_to_uuid_dict[target]}'
)
...
@@ -1034,6 +1657,7 @@ class Dispatcher(DeviceMap):
...
@@ -1034,6 +1657,7 @@ class Dispatcher(DeviceMap):
logger
.
info
(
"矿卡状态:矿卡重载"
)
logger
.
info
(
"矿卡状态:矿卡重载"
)
logger
.
info
(
f
'矿卡行程:{self.excavator_index_to_uuid_dict[trip[0]]}-{self.dump_index_to_uuid_dict[trip[1]]}'
)
logger
.
info
(
f
'矿卡行程:{self.excavator_index_to_uuid_dict[trip[0]]}-{self.dump_index_to_uuid_dict[trip[1]]}'
)
<<<<<<<
HEAD
logger
.
info
(
f
'涉及卸载设备:{list(self.excavator_uuid_to_index_dict.keys())}'
)
logger
.
info
(
f
'涉及卸载设备:{list(self.excavator_uuid_to_index_dict.keys())}'
)
logger
.
info
(
f
'卸载设备饱和度:{(1 - self.sim_excavator_real_mass / excavator_target_mass)}'
)
logger
.
info
(
f
'卸载设备饱和度:{(1 - self.sim_excavator_real_mass / excavator_target_mass)}'
)
logger
.
info
(
logger
.
info
(
...
@@ -1056,6 +1680,30 @@ class Dispatcher(DeviceMap):
...
@@ -1056,6 +1680,30 @@ class Dispatcher(DeviceMap):
# np.array(self.actual_goto_excavator_traffic_flow).reshape((self.dumps, self.excavators))
# np.array(self.actual_goto_excavator_traffic_flow).reshape((self.dumps, self.excavators))
# self.opt_goto_excavator_traffic_flow = \
# self.opt_goto_excavator_traffic_flow = \
# np.array(self.opt_goto_excavator_traffic_flow).reshape((self.dumps, self.excavators))
# np.array(self.opt_goto_excavator_traffic_flow).reshape((self.dumps, self.excavators))
=======
logger
.
info
(
f
'涉及卸点:{list(self.excavator_uuid_to_index_dict.keys())}'
)
logger
.
info
(
f
'卸点饱和度:{(1 - self.sim_shovel_real_mass / shovel_target_mass)}'
)
logger
.
info
(
f
'行程时间:{(np.maximum(self.sim_shovel_ava_time, self.sim_truck_ava_time[truck_index] + self.com_time_eq[trip[1], :]) + loading_time - self.sim_truck_ava_time[truck_index])}'
)
logger
.
info
(
f
'行驶时间:{self.com_time_eq[trip[1], :] + loading_time}'
)
# 卡车重载,计算下一次装载点
target
=
np
.
argmax
(
10
*
(
1
-
self
.
sim_shovel_real_mass
/
shovel_target_mass
)
/
(
np
.
maximum
(
self
.
sim_shovel_ava_time
,
self
.
sim_truck_ava_time
[
truck_index
]
+
self
.
com_time_eq
[
trip
[
1
],
:])
+
loading_time
-
self
.
sim_truck_ava_time
[
truck_index
]))
# try:
# assert self.actual_goto_excavator_traffic_flow.shape == (self.shovels, self.dumps)
# assert self.opt_goto_excavator_traffic_flow.shape == (self.shovels, self.dumps)
# except Exception as es:
# logger.warning(es)
# self.actual_goto_excavator_traffic_flow = \
# np.array(self.actual_goto_excavator_traffic_flow).reshape((self.dumps, self.shovels))
# self.opt_goto_excavator_traffic_flow = \
# np.array(self.opt_goto_excavator_traffic_flow).reshape((self.dumps, self.shovels))
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
#
#
# target = np.argmin(
# target = np.argmin(
# self.actual_goto_excavator_traffic_flow[trip[1], :] / self.opt_goto_excavator_traffic_flow[trip[1], :])
# self.actual_goto_excavator_traffic_flow[trip[1], :] / self.opt_goto_excavator_traffic_flow[trip[1], :])
...
@@ -1067,6 +1715,7 @@ class Dispatcher(DeviceMap):
...
@@ -1067,6 +1715,7 @@ class Dispatcher(DeviceMap):
def
schedule_construct
(
self
):
def
schedule_construct
(
self
):
# 读取所需信息
# 读取所需信息
<<<<<<<
HEAD
trucks
=
self
.
truck
.
get_truck_num
()
trucks
=
self
.
truck
.
get_truck_num
()
truck_current_trip
=
self
.
truck
.
get_truck_current_trip
()
truck_current_trip
=
self
.
truck
.
get_truck_current_trip
()
truck_current_task
=
self
.
truck
.
get_truck_current_task
()
truck_current_task
=
self
.
truck
.
get_truck_current_task
()
...
@@ -1075,6 +1724,14 @@ class Dispatcher(DeviceMap):
...
@@ -1075,6 +1724,14 @@ class Dispatcher(DeviceMap):
loading_time
=
self
.
excavator
.
get_loading_time
()
loading_time
=
self
.
excavator
.
get_loading_time
()
go_time_area
=
self
.
walker
.
get_go_time_area
()
go_time_area
=
self
.
walker
.
get_go_time_area
()
com_time_area
=
self
.
walker
.
get_com_time_area
()
com_time_area
=
self
.
walker
.
get_com_time_area
()
=======
trucks
=
self
.
truck
.
trucks
truck_current_trip
=
self
.
truck
.
truck_current_trip
truck_current_task
=
self
.
truck
.
truck_current_task
payload
=
self
.
truck
.
payload
unloading_time
=
self
.
dump
.
unloading_time
loading_time
=
self
.
excavator
.
loading_time
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# Seq初始化
# Seq初始化
Seq
=
[[
truck_current_trip
[
i
][
1
],
-
1
]
for
i
in
range
(
trucks
)]
Seq
=
[[
truck_current_trip
[
i
][
1
],
-
1
]
for
i
in
range
(
trucks
)]
...
@@ -1095,6 +1752,7 @@ class Dispatcher(DeviceMap):
...
@@ -1095,6 +1752,7 @@ class Dispatcher(DeviceMap):
for
truck
in
index
:
for
truck
in
index
:
if
len
(
Seq
[
truck
])
>
0
:
if
len
(
Seq
[
truck
])
>
0
:
<<<<<<<
HEAD
try
:
try
:
task
=
truck_current_task
[
self
.
truck_index_to_uuid_dict
[
truck
]]
task
=
truck_current_task
[
self
.
truck_index_to_uuid_dict
[
truck
]]
...
@@ -1110,6 +1768,23 @@ class Dispatcher(DeviceMap):
...
@@ -1110,6 +1768,23 @@ class Dispatcher(DeviceMap):
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
error
(
f
'矿卡 {truck_uuid_to_name_dict[self.truck_index_to_uuid_dict[truck]]} 派车计划计算异常'
)
logger
.
error
(
f
'矿卡 {truck_uuid_to_name_dict[self.truck_index_to_uuid_dict[truck]]} 派车计划计算异常'
)
logger
.
error
(
es
)
logger
.
error
(
es
)
=======
# try:
task
=
truck_current_task
[
self
.
truck_index_to_uuid_dict
[
truck
]]
# 矿卡结束当前派车计划后的目的地
end_eq_index
=
truck_current_trip
[
truck
][
1
]
# 调用调度函数,得到最优目的地序号
target_eq_index
=
self
.
truck_schedule
(
self
.
truck_index_to_uuid_dict
[
truck
])
# 写入Seq序列
Seq
[
truck
][
1
]
=
target_eq_index
# except Exception as es:
# logger.error(f'矿卡 {truck_uuid_to_name_dict[self.truck_index_to_uuid_dict[truck]]} 派车计划计算异常')
# logger.error(es)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
try
:
try
:
...
@@ -1119,12 +1794,20 @@ class Dispatcher(DeviceMap):
...
@@ -1119,12 +1794,20 @@ class Dispatcher(DeviceMap):
# 更新变量,预计产量更新
# 更新变量,预计产量更新
self
.
sim_dump_real_mass
[
target_eq_index
]
=
self
.
sim_dump_real_mass
[
target_eq_index
]
+
\
self
.
sim_dump_real_mass
[
target_eq_index
]
=
self
.
sim_dump_real_mass
[
target_eq_index
]
+
\
payload
[
truck
]
payload
[
truck
]
<<<<<<<
HEAD
# 预计卸载设备可用时间更新
# 预计卸载设备可用时间更新
=======
# 预计卸点可用时间更新
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
sim_dump_ava_time
[
target_eq_index
]
=
(
self
.
sim_dump_ava_time
[
target_eq_index
]
=
(
max
(
max
(
self
.
sim_dump_ava_time
[
target_eq_index
],
self
.
sim_dump_ava_time
[
target_eq_index
],
self
.
sim_truck_ava_time
[
truck
]
self
.
sim_truck_ava_time
[
truck
]
<<<<<<<
HEAD
+
go_time_area
[
target_area_index
][
end_area_index
],
+
go_time_area
[
target_area_index
][
end_area_index
],
=======
+
self
.
go_time_area
[
target_area_index
][
end_area_index
],
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
)
)
+
unloading_time
[
target_eq_index
]
+
unloading_time
[
target_eq_index
]
)
)
...
@@ -1132,6 +1815,7 @@ class Dispatcher(DeviceMap):
...
@@ -1132,6 +1815,7 @@ class Dispatcher(DeviceMap):
target_area_index
=
self
.
excavator_index_to_load_area_index_dict
[
target_eq_index
]
target_area_index
=
self
.
excavator_index_to_load_area_index_dict
[
target_eq_index
]
end_area_index
=
self
.
dump_index_to_unload_area_index_dict
[
end_eq_index
]
end_area_index
=
self
.
dump_index_to_unload_area_index_dict
[
end_eq_index
]
# 更新变量,预计产量更新
# 更新变量,预计产量更新
<<<<<<<
HEAD
self
.
sim_excavator_real_mass
[
target_eq_index
]
=
self
.
sim_excavator_real_mass
[
target_eq_index
]
+
\
self
.
sim_excavator_real_mass
[
target_eq_index
]
=
self
.
sim_excavator_real_mass
[
target_eq_index
]
+
\
payload
[
truck
]
payload
[
truck
]
# 预计装载点可用时间更新
# 预计装载点可用时间更新
...
@@ -1140,6 +1824,16 @@ class Dispatcher(DeviceMap):
...
@@ -1140,6 +1824,16 @@ class Dispatcher(DeviceMap):
self
.
sim_excavator_ava_time
[
target_eq_index
],
self
.
sim_excavator_ava_time
[
target_eq_index
],
self
.
sim_truck_ava_time
[
truck
]
self
.
sim_truck_ava_time
[
truck
]
+
go_time_area
[
end_area_index
][
target_area_index
],
+
go_time_area
[
end_area_index
][
target_area_index
],
=======
self
.
sim_shovel_real_mass
[
target_eq_index
]
=
self
.
sim_shovel_real_mass
[
target_eq_index
]
+
\
self
.
payload
[
truck
]
# 预计装载点可用时间更新
self
.
sim_shovel_ava_time
[
target_eq_index
]
=
(
max
(
self
.
sim_shovel_ava_time
[
target_eq_index
],
self
.
sim_truck_ava_time
[
truck
]
+
self
.
go_time_area
[
end_area_index
][
target_area_index
],
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
)
)
+
loading_time
[
target_eq_index
]
+
loading_time
[
target_eq_index
]
)
)
...
@@ -1153,7 +1847,11 @@ class Dispatcher(DeviceMap):
...
@@ -1153,7 +1847,11 @@ class Dispatcher(DeviceMap):
try
:
try
:
record
=
{
"truckId"
:
self
.
truck_index_to_uuid_dict
[
i
]}
record
=
{
"truckId"
:
self
.
truck_index_to_uuid_dict
[
i
]}
<<<<<<<
HEAD
task
=
self
.
truck
.
get_truck_current_task
()[
self
.
truck_index_to_uuid_dict
[
i
]]
task
=
self
.
truck
.
get_truck_current_task
()[
self
.
truck_index_to_uuid_dict
[
i
]]
=======
task
=
self
.
truck
.
truck_current_task
[
self
.
truck_index_to_uuid_dict
[
i
]]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
if
task
in
empty_task_set
:
if
task
in
empty_task_set
:
item
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
item
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
self
.
dump_index_to_uuid_dict
[
Seq
[
i
][
1
]],
isauto
=
1
,
isdeleted
=
0
)
.
first
()
dump_id
=
self
.
dump_index_to_uuid_dict
[
Seq
[
i
][
1
]],
isauto
=
1
,
isdeleted
=
0
)
.
first
()
...
@@ -1206,13 +1904,24 @@ class Dispatcher(DeviceMap):
...
@@ -1206,13 +1904,24 @@ class Dispatcher(DeviceMap):
# 下面三个函数保证程序定期执行,不用管他
# 下面三个函数保证程序定期执行,不用管他
<<<<<<<
HEAD
def
process
(
dispatcher
):
def
process
(
dispatcher
):
=======
def
process
(
dispatcher
,
dump
,
excavator
,
truck
):
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 清空数据库缓存
# 清空数据库缓存
session_mysql
.
commit
()
session_mysql
.
commit
()
session_mysql
.
flush
()
session_mysql
.
flush
()
<<<<<<<
HEAD
# 周期更新
# 周期更新
=======
# 设备对象周期更新
dump
.
period_update
()
excavator
.
period_update
()
truck
.
period_update
()
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
dispatcher
.
period_update
()
dispatcher
.
period_update
()
# 参数重置
# 参数重置
...
@@ -1225,6 +1934,7 @@ def process(dispatcher):
...
@@ -1225,6 +1934,7 @@ def process(dispatcher):
scheduler
=
sched
.
scheduler
(
time
.
time
,
time
.
sleep
)
scheduler
=
sched
.
scheduler
(
time
.
time
,
time
.
sleep
)
<<<<<<<
HEAD
def
perform
(
inc
,
dispatcher
):
def
perform
(
inc
,
dispatcher
):
scheduler
.
enter
(
inc
,
0
,
perform
,
(
inc
,
dispatcher
))
scheduler
.
enter
(
inc
,
0
,
perform
,
(
inc
,
dispatcher
))
process
(
dispatcher
)
process
(
dispatcher
)
...
@@ -1232,6 +1942,15 @@ def perform(inc, dispatcher):
...
@@ -1232,6 +1942,15 @@ def perform(inc, dispatcher):
def
main
(
inc
,
dispatcher
):
def
main
(
inc
,
dispatcher
):
scheduler
.
enter
(
0
,
0
,
perform
,
(
inc
,
dispatcher
))
scheduler
.
enter
(
0
,
0
,
perform
,
(
inc
,
dispatcher
))
=======
def
perform
(
inc
,
dispatcher
,
dump
,
excavator
,
truck
):
scheduler
.
enter
(
inc
,
0
,
perform
,
(
inc
,
dispatcher
,
dump
,
excavator
,
truck
))
process
(
dispatcher
,
dump
,
excavator
,
truck
)
def
main
(
inc
,
odispatcher
,
dump
,
excavator
,
truck
):
scheduler
.
enter
(
0
,
0
,
perform
,
(
inc
,
dispatcher
,
dump
,
excavator
,
truck
))
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
scheduler
.
run
()
scheduler
.
run
()
...
@@ -1239,6 +1958,18 @@ if __name__ == "__main__":
...
@@ -1239,6 +1958,18 @@ if __name__ == "__main__":
logger
.
info
(
" "
)
logger
.
info
(
" "
)
logger
.
info
(
"调度系统启动"
)
logger
.
info
(
"调度系统启动"
)
<<<<<<<
HEAD
dispatcher
=
Dispatcher
()
dispatcher
=
Dispatcher
()
main
(
60
,
dispatcher
)
main
(
60
,
dispatcher
)
=======
dump
=
DumpInfo
()
excavator
=
ExcavatorInfo
()
truck
=
TruckInfo
()
dispatcher
=
Dispatcher
()
main
(
60
,
dispatcher
,
dump
,
excavator
,
truck
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
settings.py
View file @
9e292917
...
@@ -9,6 +9,10 @@
...
@@ -9,6 +9,10 @@
# 数据库设备, redis设置, 日志设置
# 数据库设备, redis设置, 日志设置
<<<<<<<
HEAD
=======
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
from
tables
import
*
from
tables
import
*
from
urllib.parse
import
quote
from
urllib.parse
import
quote
import
logging.handlers
import
logging.handlers
...
...
static_data_process.py
View file @
9e292917
...
@@ -51,7 +51,11 @@ def build_park_uuid_index_map():
...
@@ -51,7 +51,11 @@ def build_park_uuid_index_map():
park_num
=
0
park_num
=
0
try
:
try
:
<<<<<<<
HEAD
for
item
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
for
item
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
=======
for
item
in
session_postgre
.
query
(
WalkTimePort
)
.
all
():
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
park
=
str
(
item
.
park_area_id
)
park
=
str
(
item
.
park_area_id
)
if
park
not
in
park_uuid_to_index_dict
:
if
park
not
in
park_uuid_to_index_dict
:
park_uuid_to_index_dict
[
park
]
=
park_num
park_uuid_to_index_dict
[
park
]
=
park_num
...
@@ -124,7 +128,11 @@ def update_deveices_map(unload_area_uuid_to_index_dict, load_area_uuid_to_index_
...
@@ -124,7 +128,11 @@ def update_deveices_map(unload_area_uuid_to_index_dict, load_area_uuid_to_index_
load_area_uuid_to_index_dict
[
load_area_id
]
load_area_uuid_to_index_dict
[
load_area_id
]
excavator_num
=
excavator_num
+
1
excavator_num
=
excavator_num
+
1
if
excavator_num
<
1
or
dump_num
<
1
:
if
excavator_num
<
1
or
dump_num
<
1
:
<<<<<<<
HEAD
raise
Exception
(
"无动态派车计划可用-动态派车挖机/卸载设备映射失败"
)
raise
Exception
(
"无动态派车计划可用-动态派车挖机/卸载设备映射失败"
)
=======
raise
Exception
(
"无动态派车计划可用-动态派车挖机/卸点映射失败"
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
warning
(
es
)
logger
.
warning
(
es
)
...
@@ -191,7 +199,11 @@ def update_autodisp_excavator():
...
@@ -191,7 +199,11 @@ def update_autodisp_excavator():
for
item
in
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
isdeleted
=
0
,
isauto
=
1
)
.
all
():
for
item
in
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
isdeleted
=
0
,
isauto
=
1
)
.
all
():
dynamic_excavator_list
.
append
(
item
.
exactor_id
)
dynamic_excavator_list
.
append
(
item
.
exactor_id
)
if
len
(
dynamic_excavator_list
)
<
1
:
if
len
(
dynamic_excavator_list
)
<
1
:
<<<<<<<
HEAD
raise
Exception
(
"无动态派车计划可用-动态派车挖机/卸载设备集合读取异常"
)
raise
Exception
(
"无动态派车计划可用-动态派车挖机/卸载设备集合读取异常"
)
=======
raise
Exception
(
"无动态派车计划可用-动态派车挖机/卸点集合读取异常"
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
warning
(
es
)
logger
.
warning
(
es
)
...
@@ -205,7 +217,11 @@ def update_autodisp_dump():
...
@@ -205,7 +217,11 @@ def update_autodisp_dump():
for
item
in
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
isdeleted
=
0
,
isauto
=
1
)
.
all
():
for
item
in
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
isdeleted
=
0
,
isauto
=
1
)
.
all
():
dynamic_dump_list
.
append
(
item
.
dump_id
)
dynamic_dump_list
.
append
(
item
.
dump_id
)
if
len
(
dynamic_dump_list
)
<
1
:
if
len
(
dynamic_dump_list
)
<
1
:
<<<<<<<
HEAD
raise
Exception
(
"无动态派车计划可用-动态派车挖机/卸载设备集合读取异常"
)
raise
Exception
(
"无动态派车计划可用-动态派车挖机/卸载设备集合读取异常"
)
=======
raise
Exception
(
"无动态派车计划可用-动态派车挖机/卸点集合读取异常"
)
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
except
Exception
as
es
:
except
Exception
as
es
:
logger
.
warning
(
es
)
logger
.
warning
(
es
)
return
dynamic_dump_list
return
dynamic_dump_list
...
@@ -222,10 +238,14 @@ def update_unload_area():
...
@@ -222,10 +238,14 @@ def update_unload_area():
unload_area_list
=
[]
unload_area_list
=
[]
for
walk_time
in
session_postgre
.
query
(
WalkTime
)
.
all
():
for
walk_time
in
session_postgre
.
query
(
WalkTime
)
.
all
():
unload_area_list
.
append
(
walk_time
.
unload_area_id
)
unload_area_list
.
append
(
walk_time
.
unload_area_id
)
<<<<<<<
HEAD
return
unload_area_list
return
unload_area_list
def
update_park_area
():
def
update_park_area
():
park_area_list
=
[]
park_area_list
=
[]
for
walk_time_park
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
for
walk_time_park
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
park_area_list
.
append
(
walk_time_park
.
park_area_id
)
park_area_list
.
append
(
walk_time_park
.
park_area_id
)
return
park_area_list
return
park_area_list
\ No newline at end of file
=======
return
unload_area_list
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
tables.py
View file @
9e292917
...
@@ -119,19 +119,28 @@ class WalkTime(Base):
...
@@ -119,19 +119,28 @@ class WalkTime(Base):
unload_area_name
=
Column
(
VARCHAR
(
30
))
unload_area_name
=
Column
(
VARCHAR
(
30
))
to_unload_distance
=
Column
(
Float
(
10
))
to_unload_distance
=
Column
(
Float
(
10
))
to_load_distance
=
Column
(
Float
(
10
))
to_load_distance
=
Column
(
Float
(
10
))
<<<<<<<
HEAD
to_unload_lanes
=
Column
(
VARCHAR
(
100
))
to_unload_lanes
=
Column
(
VARCHAR
(
100
))
to_load_lanes
=
Column
(
VARCHAR
(
100
))
to_load_lanes
=
Column
(
VARCHAR
(
100
))
def
__init__
(
self
,
load_area_id
,
unload_area_id
,
load_area_name
,
unload_area_name
,
to_load_distance
,
def
__init__
(
self
,
load_area_id
,
unload_area_id
,
load_area_name
,
unload_area_name
,
to_load_distance
,
to_unload_distance
,
to_unload_lanes
,
to_load_lanes
):
to_unload_distance
,
to_unload_lanes
,
to_load_lanes
):
=======
def
__init__
(
self
,
load_area_id
,
unload_area_id
,
load_area_name
,
unload_area_name
,
to_load_distance
,
to_unload_distance
):
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
load_area_id
=
load_area_id
self
.
load_area_id
=
load_area_id
self
.
unload_area_id
=
unload_area_id
self
.
unload_area_id
=
unload_area_id
self
.
load_area_name
=
load_area_name
self
.
load_area_name
=
load_area_name
self
.
unload_area_name
=
unload_area_name
self
.
unload_area_name
=
unload_area_name
self
.
to_load_distance
=
to_load_distance
self
.
to_load_distance
=
to_load_distance
self
.
to_unload_distance
=
to_unload_distance
self
.
to_unload_distance
=
to_unload_distance
<<<<<<<
HEAD
self
.
to_unload_lanes
=
to_unload_lanes
self
.
to_unload_lanes
=
to_unload_lanes
self
.
to_load_lanes
=
to_load_lanes
self
.
to_load_lanes
=
to_load_lanes
=======
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# Rid = Column(VARCHAR(36), primary_key=True)
# Rid = Column(VARCHAR(36), primary_key=True)
# load_area_id = Column(VARCHAR(36))
# load_area_id = Column(VARCHAR(36))
...
@@ -213,6 +222,7 @@ class EquipmentPair(Base):
...
@@ -213,6 +222,7 @@ class EquipmentPair(Base):
self
.
isdeleted
=
isdeleted
self
.
isdeleted
=
isdeleted
self
.
createtime
=
createtime
self
.
createtime
=
createtime
<<<<<<<
HEAD
# class Lane(Base):
# class Lane(Base):
# # 表的名字
# # 表的名字
# __tablename__ = 'Geo_Node'
# __tablename__ = 'Geo_Node'
...
@@ -235,6 +245,8 @@ class Lane(Base):
...
@@ -235,6 +245,8 @@ class Lane(Base):
self
.
Length
=
Length
self
.
Length
=
Length
self
.
MaxSpeed
=
MaxSpeed
self
.
MaxSpeed
=
MaxSpeed
=======
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
class
Dispatch
(
Base
):
class
Dispatch
(
Base
):
# 表的名字:
# 表的名字:
__tablename__
=
'sys_dispatch_setting'
__tablename__
=
'sys_dispatch_setting'
...
@@ -275,7 +287,11 @@ class Dispatch(Base):
...
@@ -275,7 +287,11 @@ class Dispatch(Base):
self
.
deletor
=
deletor
self
.
deletor
=
deletor
self
.
deletetime
=
deletetime
self
.
deletetime
=
deletetime
<<<<<<<
HEAD
class
WalkTimePark
(
Base
):
class
WalkTimePark
(
Base
):
=======
class
WalkTimePort
(
Base
):
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
__tablename__
=
'park_load_distance'
__tablename__
=
'park_load_distance'
park_area_id
=
Column
(
VARCHAR
(
36
),
primary_key
=
True
)
park_area_id
=
Column
(
VARCHAR
(
36
),
primary_key
=
True
)
...
@@ -283,15 +299,23 @@ class WalkTimePark(Base):
...
@@ -283,15 +299,23 @@ class WalkTimePark(Base):
park_area_name
=
Column
(
VARCHAR
(
36
))
park_area_name
=
Column
(
VARCHAR
(
36
))
load_area_name
=
Column
(
VARCHAR
(
36
))
load_area_name
=
Column
(
VARCHAR
(
36
))
park_load_distance
=
Column
(
Float
(
10
))
park_load_distance
=
Column
(
Float
(
10
))
<<<<<<<
HEAD
park_load_lanes
=
Column
(
VARCHAR
(
100
))
park_load_lanes
=
Column
(
VARCHAR
(
100
))
def
__init__
(
self
,
park_area_id
,
load_area_id
,
park_area_name
,
load_area_name
,
park_load_distance
,
park_load_lanes
):
def
__init__
(
self
,
park_area_id
,
load_area_id
,
park_area_name
,
load_area_name
,
park_load_distance
,
park_load_lanes
):
=======
def
__init__
(
self
,
park_area_id
,
load_area_id
,
park_area_name
,
load_area_name
,
park_load_distance
):
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
park_area_id
=
park_area_id
self
.
park_area_id
=
park_area_id
self
.
load_area_id
=
load_area_id
self
.
load_area_id
=
load_area_id
self
.
park_area_name
=
park_area_name
self
.
park_area_name
=
park_area_name
self
.
load_area_name
=
load_area_name
self
.
load_area_name
=
load_area_name
self
.
park_load_distance
=
park_load_distance
self
.
park_load_distance
=
park_load_distance
<<<<<<<
HEAD
self
.
park_load_lanes
=
park_load_lanes
self
.
park_load_lanes
=
park_load_lanes
=======
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
class
Equipment
(
Base
):
class
Equipment
(
Base
):
__tablename__
=
'sys_equipment'
__tablename__
=
'sys_equipment'
...
...
traffic_flow_planner.py
View file @
9e292917
...
@@ -18,6 +18,7 @@ from settings import *
...
@@ -18,6 +18,7 @@ from settings import *
# 需要提供的值
# 需要提供的值
# traffic_programme_para.excavator_strength[excavator_index] = 200 # 挖机最大装载能力,单位吨/小时
# traffic_programme_para.excavator_strength[excavator_index] = 200 # 挖机最大装载能力,单位吨/小时
<<<<<<<
HEAD
# traffic_programme_para.dump_strength[dump_index] = 200 # 卸载设备最大卸载能力,单位吨/小时
# traffic_programme_para.dump_strength[dump_index] = 200 # 卸载设备最大卸载能力,单位吨/小时
# traffic_programme_para.grade_loading_array[excavator_index] = 100 # 挖机装载物料品位
# traffic_programme_para.grade_loading_array[excavator_index] = 100 # 挖机装载物料品位
...
@@ -28,11 +29,20 @@ from settings import *
...
@@ -28,11 +29,20 @@ from settings import *
# traffic_programme_para.grade_upper_dump_array[dump_index] = 100 # 卸点品位上限
# traffic_programme_para.grade_upper_dump_array[dump_index] = 100 # 卸点品位上限
# traffic_programme_para.grade_lower_dump_array[dump_index] = 100 # 卸点品位下限
# traffic_programme_para.grade_lower_dump_array[dump_index] = 100 # 卸点品位下限
=======
# traffic_programme_para.grade_loading_array[excavator_index] = 100 # 挖机装载物料品位
# traffic_programme_para.excavator_priority_coefficient[excavator_index] = 1 # 挖机优先级
# traffic_programme_para.dump_strength[dump_index] = 200 # 卸载设备最大卸载能力,单位吨/小时
# traffic_programme_para.grade_upper_dump_array[dump_index] = 100 # 卸点品位上限
# traffic_programme_para.grade_lower_dump_array[dump_index] = 100 # 卸点品位下限
# traffic_programme_para.dump_priority_coefficient[dump_index] = 1 # 卸载设备优先级
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
class
TrafficProgPara
(
object
):
class
TrafficProgPara
(
object
):
def
__init__
(
self
,
num_of_load_area
,
num_of_unload_area
,
num_of_excavator
,
num_of_dump
):
def
__init__
(
self
,
num_of_load_area
,
num_of_unload_area
,
num_of_excavator
,
num_of_dump
):
<<<<<<<
HEAD
self
.
load_area_uuid_to_index_dict
=
{}
# 用于保存装载点uuid到id的映射
self
.
load_area_uuid_to_index_dict
=
{}
# 用于保存装载点uuid到id的映射
self
.
load_area_index_to_uuid_dict
=
{}
# 用于保存装载点id到uuid的映射
self
.
load_area_index_to_uuid_dict
=
{}
# 用于保存装载点id到uuid的映射
self
.
unload_area_uuid_to_index_dict
=
{}
# 用于保存卸载点uuid到id的映射
self
.
unload_area_uuid_to_index_dict
=
{}
# 用于保存卸载点uuid到id的映射
...
@@ -61,6 +71,32 @@ class TrafficProgPara(object):
...
@@ -61,6 +71,32 @@ class TrafficProgPara(object):
self
.
goto_load_area_factor
=
np
.
full
((
num_of_unload_area
,
num_of_load_area
),
10
,
dtype
=
float
)
# 装载道路的运输系数
self
.
goto_load_area_factor
=
np
.
full
((
num_of_unload_area
,
num_of_load_area
),
10
,
dtype
=
float
)
# 装载道路的运输系数
self
.
goto_excavator_factor
=
np
.
full
((
num_of_dump
,
num_of_excavator
),
10
,
dtype
=
float
)
# 逻辑装载道路的运输系数
self
.
goto_excavator_factor
=
np
.
full
((
num_of_dump
,
num_of_excavator
),
10
,
dtype
=
float
)
# 逻辑装载道路的运输系数
=======
self
.
load_area_uuid_to_ref_id_dict
=
{}
# 用于保存装载点uuid到id的映射
self
.
load_area_ref_id_to_uuid_dict
=
{}
# 用于保存装载点id到uuid的映射
self
.
unload_area_uuid_to_ref_id_dict
=
{}
# 用于保存卸载点uuid到id的映射
self
.
unload_area_ref_id_to_uuid_dict
=
{}
# 用于保存卸载点id到uuid的映射
self
.
excavator_uuid_to_ref_id_dict
=
{}
# 用于保存挖机uuid到id的映射
self
.
excavator_ref_id_to_uuid_dict
=
{}
# 用于保存挖机id到uuid的映射
self
.
dump_uuid_to_ref_id_dict
=
{}
# 用于保存卸点uuid到id的映射
self
.
dump_ref_id_to_uuid_dict
=
{}
# 用于保存卸点id到uuid的映射
self
.
dump_uuid_to_unload_area_uuid_dict
=
{}
# 用于保存卸点与卸载区的绑定关系(uuid)
self
.
excavator_uuid_to_load_area_uuid_dict
=
{}
# 用于保存挖机与装载区的绑定关系(uuid)
self
.
dump_ref_id_to_unload_area_ref_id_dict
=
{}
# 用于保存卸点与卸载区的绑定关系(id)
self
.
excavator_ref_id_to_load_area_ref_id_dict
=
{}
# 用于保存挖机与装载区的绑定关系(id)
self
.
excavator_strength
=
np
.
zeros
(
num_of_excavator
)
# 用于保存电铲的工作强度,单位是t/h
self
.
excavator_priority_coefficient
=
np
.
zeros
(
num_of_excavator
)
# 每个电铲的优先级系数
self
.
grade_loading_array
=
np
.
zeros
(
num_of_excavator
)
# 用于保存电铲挖掘矿石的品位
self
.
dump_strength
=
np
.
zeros
(
num_of_dump
)
# 卸载点的工作强度,单位是t/h
self
.
dump_priority_coefficient
=
np
.
zeros
(
num_of_dump
)
# 每个卸载点的优先级系数
self
.
goto_unload_area_factor
=
np
.
full
((
num_of_load_area
,
num_of_unload_area
),
10
,
dtype
=
float
)
# 卸载道路的运输系数
self
.
goto_unload_point_factor
=
np
.
full
((
num_of_excavator
,
num_of_dump
),
10
,
dtype
=
float
)
# 逻辑卸载道路的运输系数
self
.
goto_load_area_factor
=
np
.
full
((
num_of_unload_area
,
num_of_load_area
),
10
,
dtype
=
float
)
# 装载道路的运输系数
self
.
goto_excavator_factor
=
np
.
full
((
num_of_dump
,
num_of_excavator
),
10
,
dtype
=
float
)
# 逻辑1装载道路的运输系数
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
priority_coefficient
=
np
.
zeros
((
num_of_excavator
,
num_of_dump
))
# 卸载道路的优先级系数
self
.
priority_coefficient
=
np
.
zeros
((
num_of_excavator
,
num_of_dump
))
# 卸载道路的优先级系数
self
.
grade_lower_dump_array
=
np
.
zeros
(
num_of_dump
)
# 卸载点矿石品位下限
self
.
grade_lower_dump_array
=
np
.
zeros
(
num_of_dump
)
# 卸载点矿石品位下限
self
.
grade_upper_dump_array
=
np
.
zeros
(
num_of_dump
)
# 卸载点矿石品位上限
self
.
grade_upper_dump_array
=
np
.
zeros
(
num_of_dump
)
# 卸载点矿石品位上限
...
@@ -69,11 +105,19 @@ class TrafficProgPara(object):
...
@@ -69,11 +105,19 @@ class TrafficProgPara(object):
self
.
heavy_speed
=
22
# 重载矿卡平均时速
self
.
heavy_speed
=
22
# 重载矿卡平均时速
self
.
goto_load_area_distance
=
np
.
zeros
((
num_of_unload_area
,
num_of_load_area
))
# 空载运输路线距离
self
.
goto_load_area_distance
=
np
.
zeros
((
num_of_unload_area
,
num_of_load_area
))
# 空载运输路线距离
self
.
goto_unload_area_distance
=
np
.
zeros
((
num_of_load_area
,
num_of_unload_area
))
# 重载运输路线距离
self
.
goto_unload_area_distance
=
np
.
zeros
((
num_of_load_area
,
num_of_unload_area
))
# 重载运输路线距离
<<<<<<<
HEAD
# 装载道路权重因子
# 装载道路权重因子
# self.avg_goto_excavator_weight = np.zeros((num_of_load_area, num_of_unload_area))
# self.avg_goto_excavator_weight = np.zeros((num_of_load_area, num_of_unload_area))
self
.
avg_goto_excavator_weight
=
np
.
full
((
num_of_load_area
,
num_of_unload_area
),
1
)
self
.
avg_goto_excavator_weight
=
np
.
full
((
num_of_load_area
,
num_of_unload_area
),
1
)
# 卸载道路
# 卸载道路
# self.avg_goto_unload_point_weight = np.zeros((num_of_load_area, num_of_unload_area))
# self.avg_goto_unload_point_weight = np.zeros((num_of_load_area, num_of_unload_area))
=======
# 装载道路上,每提供1吨的装载能力需要一辆卡车运行时长,等于(该装载道路上车辆平均运行时长/卡车平均装载能力)
self
.
avg_goto_excavator_weight
=
np
.
zeros
((
num_of_load_area
,
num_of_unload_area
))
self
.
avg_goto_excavator_weight
=
np
.
full
((
num_of_load_area
,
num_of_unload_area
),
1
)
# 卸载道路上,每运输1吨货物需要一辆卡车运行时长,等于(该卸载道路上车辆平均运行时长/卡车平均实际装载量)
self
.
avg_goto_unload_point_weight
=
np
.
zeros
((
num_of_load_area
,
num_of_unload_area
))
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
self
.
avg_goto_unload_point_weight
=
np
.
full
((
num_of_load_area
,
num_of_unload_area
),
1
)
self
.
avg_goto_unload_point_weight
=
np
.
full
((
num_of_load_area
,
num_of_unload_area
),
1
)
self
.
goto_excavator_distance
=
np
.
zeros
((
num_of_dump
,
num_of_excavator
))
# 逻辑空载运输路线距离
self
.
goto_excavator_distance
=
np
.
zeros
((
num_of_dump
,
num_of_excavator
))
# 逻辑空载运输路线距离
self
.
goto_dump_distance
=
np
.
zeros
((
num_of_excavator
,
num_of_dump
))
# 逻辑重载运输路线距离
self
.
goto_dump_distance
=
np
.
zeros
((
num_of_excavator
,
num_of_dump
))
# 逻辑重载运输路线距离
...
@@ -87,6 +131,7 @@ def extract_excavator_info(traffic_programme_para):
...
@@ -87,6 +131,7 @@ def extract_excavator_info(traffic_programme_para):
for
dispatch
in
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
isdeleted
=
0
,
isauto
=
1
)
.
all
():
for
dispatch
in
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
isdeleted
=
0
,
isauto
=
1
)
.
all
():
excavator_id
=
dispatch
.
exactor_id
excavator_id
=
dispatch
.
exactor_id
load_area_id
=
dispatch
.
load_area_id
load_area_id
=
dispatch
.
load_area_id
<<<<<<<
HEAD
if
excavator_id
not
in
traffic_programme_para
.
excavator_uuid_to_index_dict
:
if
excavator_id
not
in
traffic_programme_para
.
excavator_uuid_to_index_dict
:
# excavator_uuid <-> excavator_uuid
# excavator_uuid <-> excavator_uuid
traffic_programme_para
.
excavator_uuid_to_index_dict
[
excavator_id
]
=
excavator_index
traffic_programme_para
.
excavator_uuid_to_index_dict
[
excavator_id
]
=
excavator_index
...
@@ -97,6 +142,18 @@ def extract_excavator_info(traffic_programme_para):
...
@@ -97,6 +142,18 @@ def extract_excavator_info(traffic_programme_para):
traffic_programme_para
.
excavator_index_to_load_area_index_dict
[
traffic_programme_para
.
excavator_index_to_load_area_index_dict
[
traffic_programme_para
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
\
traffic_programme_para
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
\
traffic_programme_para
.
load_area_uuid_to_index_dict
[
load_area_id
]
traffic_programme_para
.
load_area_uuid_to_index_dict
[
load_area_id
]
=======
if
excavator_id
not
in
traffic_programme_para
.
excavator_uuid_to_ref_id_dict
:
# excavator_uuid <-> excavator_uuid
traffic_programme_para
.
excavator_uuid_to_ref_id_dict
[
excavator_id
]
=
excavator_index
traffic_programme_para
.
excavator_ref_id_to_uuid_dict
[
excavator_index
]
=
excavator_id
# excavator_uuid -> load_area_uuid
traffic_programme_para
.
excavator_uuid_to_load_area_uuid_dict
[
excavator_id
]
=
load_area_id
# excavator_id -> load_area_id
traffic_programme_para
.
excavator_ref_id_to_load_area_ref_id_dict
[
traffic_programme_para
.
excavator_uuid_to_ref_id_dict
[
excavator_id
]]
=
\
traffic_programme_para
.
load_area_uuid_to_ref_id_dict
[
load_area_id
]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
traffic_programme_para
.
excavator_strength
[
excavator_index
]
=
300
# 挖机最大装载能力,单位吨/小时
traffic_programme_para
.
excavator_strength
[
excavator_index
]
=
300
# 挖机最大装载能力,单位吨/小时
traffic_programme_para
.
grade_loading_array
[
excavator_index
]
=
100
# 挖机装载物料品位
traffic_programme_para
.
grade_loading_array
[
excavator_index
]
=
100
# 挖机装载物料品位
...
@@ -111,6 +168,7 @@ def extract_dump_info(traffic_programme_para):
...
@@ -111,6 +168,7 @@ def extract_dump_info(traffic_programme_para):
dump_id
=
dispatch
.
dump_id
dump_id
=
dispatch
.
dump_id
if
dump_id
not
in
traffic_programme_para
.
dump_uuid_to_unload_area_uuid_dict
:
if
dump_id
not
in
traffic_programme_para
.
dump_uuid_to_unload_area_uuid_dict
:
# dump_uuid <-> dump_id
# dump_uuid <-> dump_id
<<<<<<<
HEAD
traffic_programme_para
.
dump_uuid_to_index_dict
[
dump_id
]
=
dump_index
traffic_programme_para
.
dump_uuid_to_index_dict
[
dump_id
]
=
dump_index
traffic_programme_para
.
dump_index_to_uuid_dict
[
dump_index
]
=
dump_id
traffic_programme_para
.
dump_index_to_uuid_dict
[
dump_index
]
=
dump_id
# dump_uuid -> unload_area_uuid
# dump_uuid -> unload_area_uuid
...
@@ -119,6 +177,16 @@ def extract_dump_info(traffic_programme_para):
...
@@ -119,6 +177,16 @@ def extract_dump_info(traffic_programme_para):
traffic_programme_para
.
dump_index_to_unload_area_index_dict
[
traffic_programme_para
.
dump_index_to_unload_area_index_dict
[
traffic_programme_para
.
dump_uuid_to_index_dict
[
dump_id
]]
=
\
traffic_programme_para
.
dump_uuid_to_index_dict
[
dump_id
]]
=
\
traffic_programme_para
.
unload_area_uuid_to_index_dict
[
unload_area_id
]
traffic_programme_para
.
unload_area_uuid_to_index_dict
[
unload_area_id
]
=======
traffic_programme_para
.
dump_uuid_to_ref_id_dict
[
dump_id
]
=
dump_index
traffic_programme_para
.
dump_ref_id_to_uuid_dict
[
dump_index
]
=
dump_id
# dump_uuid -> unload_area_uuid
traffic_programme_para
.
dump_uuid_to_unload_area_uuid_dict
[
dump_id
]
=
unload_area_id
# dump_id -> unload_area_id
traffic_programme_para
.
dump_ref_id_to_unload_area_ref_id_dict
[
traffic_programme_para
.
dump_uuid_to_ref_id_dict
[
dump_id
]]
=
\
traffic_programme_para
.
unload_area_uuid_to_ref_id_dict
[
unload_area_id
]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
traffic_programme_para
.
dump_strength
[
dump_index
]
=
300
# 卸载设备最大卸载能力,单位吨/小时
traffic_programme_para
.
dump_strength
[
dump_index
]
=
300
# 卸载设备最大卸载能力,单位吨/小时
traffic_programme_para
.
grade_upper_dump_array
[
dump_index
]
=
100
# 卸点品位上限
traffic_programme_para
.
grade_upper_dump_array
[
dump_index
]
=
100
# 卸点品位上限
...
@@ -137,6 +205,7 @@ def extract_walk_time_info(traffic_programme_para):
...
@@ -137,6 +205,7 @@ def extract_walk_time_info(traffic_programme_para):
load_area_id
=
str
(
walk_time
.
load_area_id
)
load_area_id
=
str
(
walk_time
.
load_area_id
)
unload_area_id
=
str
(
walk_time
.
unload_area_id
)
unload_area_id
=
str
(
walk_time
.
unload_area_id
)
<<<<<<<
HEAD
if
load_area_id
not
in
traffic_programme_para
.
load_area_uuid_to_index_dict
:
if
load_area_id
not
in
traffic_programme_para
.
load_area_uuid_to_index_dict
:
traffic_programme_para
.
load_area_uuid_to_index_dict
[
load_area_id
]
=
load_area_index
traffic_programme_para
.
load_area_uuid_to_index_dict
[
load_area_id
]
=
load_area_index
traffic_programme_para
.
load_area_index_to_uuid_dict
[
load_area_index
]
=
load_area_id
traffic_programme_para
.
load_area_index_to_uuid_dict
[
load_area_index
]
=
load_area_id
...
@@ -144,6 +213,15 @@ def extract_walk_time_info(traffic_programme_para):
...
@@ -144,6 +213,15 @@ def extract_walk_time_info(traffic_programme_para):
if
unload_area_id
not
in
traffic_programme_para
.
unload_area_uuid_to_index_dict
:
if
unload_area_id
not
in
traffic_programme_para
.
unload_area_uuid_to_index_dict
:
traffic_programme_para
.
unload_area_uuid_to_index_dict
[
unload_area_id
]
=
unload_area_index
traffic_programme_para
.
unload_area_uuid_to_index_dict
[
unload_area_id
]
=
unload_area_index
traffic_programme_para
.
unload_area_index_to_uuid_dict
[
unload_area_index
]
=
unload_area_id
traffic_programme_para
.
unload_area_index_to_uuid_dict
[
unload_area_index
]
=
unload_area_id
=======
if
load_area_id
not
in
traffic_programme_para
.
load_area_uuid_to_ref_id_dict
:
traffic_programme_para
.
load_area_uuid_to_ref_id_dict
[
load_area_id
]
=
load_area_index
traffic_programme_para
.
load_area_ref_id_to_uuid_dict
[
load_area_index
]
=
load_area_id
load_area_index
=
load_area_index
+
1
if
unload_area_id
not
in
traffic_programme_para
.
unload_area_uuid_to_ref_id_dict
:
traffic_programme_para
.
unload_area_uuid_to_ref_id_dict
[
unload_area_id
]
=
unload_area_index
traffic_programme_para
.
unload_area_ref_id_to_uuid_dict
[
unload_area_index
]
=
unload_area_id
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
unload_area_index
=
unload_area_index
+
1
unload_area_index
=
unload_area_index
+
1
# 路网信息读取
# 路网信息读取
...
@@ -151,8 +229,13 @@ def extract_walk_time_info(traffic_programme_para):
...
@@ -151,8 +229,13 @@ def extract_walk_time_info(traffic_programme_para):
load_area_id
=
str
(
walk_time
.
load_area_id
)
load_area_id
=
str
(
walk_time
.
load_area_id
)
unload_area_id
=
str
(
walk_time
.
unload_area_id
)
unload_area_id
=
str
(
walk_time
.
unload_area_id
)
# 将uuid转为id
# 将uuid转为id
<<<<<<<
HEAD
load_area_index
=
traffic_programme_para
.
load_area_uuid_to_index_dict
[
load_area_id
]
load_area_index
=
traffic_programme_para
.
load_area_uuid_to_index_dict
[
load_area_id
]
unload_area_index
=
traffic_programme_para
.
unload_area_uuid_to_index_dict
[
unload_area_id
]
unload_area_index
=
traffic_programme_para
.
unload_area_uuid_to_index_dict
[
unload_area_id
]
=======
load_area_index
=
traffic_programme_para
.
load_area_uuid_to_ref_id_dict
[
load_area_id
]
unload_area_index
=
traffic_programme_para
.
unload_area_uuid_to_ref_id_dict
[
unload_area_id
]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 运输路线距离
# 运输路线距离
traffic_programme_para
.
goto_load_area_distance
[
unload_area_index
][
load_area_index
]
=
walk_time
.
to_load_distance
traffic_programme_para
.
goto_load_area_distance
[
unload_area_index
][
load_area_index
]
=
walk_time
.
to_load_distance
...
@@ -161,7 +244,11 @@ def extract_walk_time_info(traffic_programme_para):
...
@@ -161,7 +244,11 @@ def extract_walk_time_info(traffic_programme_para):
# 卸载道路上,每运输1吨货物需要一辆卡车运行时长,等于(该卸载道路上车辆平均运行时长/卡车平均实际装载量)
# 卸载道路上,每运输1吨货物需要一辆卡车运行时长,等于(该卸载道路上车辆平均运行时长/卡车平均实际装载量)
# 单位为辆小时/吨
# 单位为辆小时/吨
<<<<<<<
HEAD
# i代表第i个挖机,j代表第j个卸载点
# i代表第i个挖机,j代表第j个卸载点
=======
# i代表第i个电铲,j代表第j个卸载点
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# walktime_goto_unload_point单位是秒,需要除以3600,转成小时
# walktime_goto_unload_point单位是秒,需要除以3600,转成小时
traffic_programme_para
.
goto_load_area_factor
[
unload_area_index
][
load_area_index
]
=
\
traffic_programme_para
.
goto_load_area_factor
[
unload_area_index
][
load_area_index
]
=
\
(
60
/
1000
*
walk_time
.
to_load_distance
/
traffic_programme_para
.
empty_speed
)
/
traffic_programme_para
.
payload
(
60
/
1000
*
walk_time
.
to_load_distance
/
traffic_programme_para
.
empty_speed
)
/
traffic_programme_para
.
payload
...
@@ -169,14 +256,22 @@ def extract_walk_time_info(traffic_programme_para):
...
@@ -169,14 +256,22 @@ def extract_walk_time_info(traffic_programme_para):
# 装载道路上,每提供1吨的装载能力需要一辆卡车运行时长,等于(该装载道路上车辆平均运行时长/卡车平均装载能力)
# 装载道路上,每提供1吨的装载能力需要一辆卡车运行时长,等于(该装载道路上车辆平均运行时长/卡车平均装载能力)
# 单位为辆小时/吨
# 单位为辆小时/吨
<<<<<<<
HEAD
# i代表第i个卸载点,j代表第j个挖机
# i代表第i个卸载点,j代表第j个挖机
=======
# i代表第i个卸载点,j代表第j个电铲
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# walktime_goto_excavator单位是秒,需要除以3600,转成小时
# walktime_goto_excavator单位是秒,需要除以3600,转成小时
traffic_programme_para
.
goto_unload_area_factor
[
load_area_index
][
unload_area_index
]
=
\
traffic_programme_para
.
goto_unload_area_factor
[
load_area_index
][
unload_area_index
]
=
\
(
60
/
1000
*
walk_time
.
to_unload_distance
/
traffic_programme_para
.
heavy_speed
)
/
traffic_programme_para
.
payload
(
60
/
1000
*
walk_time
.
to_unload_distance
/
traffic_programme_para
.
heavy_speed
)
/
traffic_programme_para
.
payload
# / traffic_programme_para.avg_goto_excavator_weight[unload_area_index][load_area_index]
# / traffic_programme_para.avg_goto_excavator_weight[unload_area_index][load_area_index]
<<<<<<<
HEAD
# 从数据库中读取挖机和卸载点相关参数,并将线性规划所用参数保存在TrafficProgPara类中
# 从数据库中读取挖机和卸载点相关参数,并将线性规划所用参数保存在TrafficProgPara类中
=======
# 从数据库中读取电铲和卸载点相关参数,并将线性规划所用参数保存在TrafficProgPara类中
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
def
traffic_programme_para_init
(
num_of_load_area
,
num_of_unload_area
,
num_of_excavator
,
num_of_dump
):
def
traffic_programme_para_init
(
num_of_load_area
,
num_of_unload_area
,
num_of_excavator
,
num_of_dump
):
# 初始化流量规划参数类
# 初始化流量规划参数类
traffic_programme_para
=
TrafficProgPara
(
num_of_load_area
,
num_of_unload_area
,
num_of_excavator
,
num_of_dump
)
traffic_programme_para
=
TrafficProgPara
(
num_of_load_area
,
num_of_unload_area
,
num_of_excavator
,
num_of_dump
)
...
@@ -200,8 +295,13 @@ def traffic_programme_para_init(num_of_load_area, num_of_unload_area, num_of_exc
...
@@ -200,8 +295,13 @@ def traffic_programme_para_init(num_of_load_area, num_of_unload_area, num_of_exc
for
i
in
range
(
num_of_excavator
):
for
i
in
range
(
num_of_excavator
):
for
j
in
range
(
num_of_dump
):
for
j
in
range
(
num_of_dump
):
# 查找挖机绑定的装载区, 卸载设备绑定的卸载区
# 查找挖机绑定的装载区, 卸载设备绑定的卸载区
<<<<<<<
HEAD
load_area_index
=
traffic_programme_para
.
excavator_index_to_load_area_index_dict
[
i
]
load_area_index
=
traffic_programme_para
.
excavator_index_to_load_area_index_dict
[
i
]
unload_area_index
=
traffic_programme_para
.
dump_index_to_unload_area_index_dict
[
j
]
unload_area_index
=
traffic_programme_para
.
dump_index_to_unload_area_index_dict
[
j
]
=======
load_area_index
=
traffic_programme_para
.
excavator_ref_id_to_load_area_ref_id_dict
[
i
]
unload_area_index
=
traffic_programme_para
.
dump_ref_id_to_unload_area_ref_id_dict
[
j
]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
# 逻辑道路因子赋值, 来自实际道路因子
# 逻辑道路因子赋值, 来自实际道路因子
traffic_programme_para
.
goto_excavator_factor
[
j
][
i
]
=
\
traffic_programme_para
.
goto_excavator_factor
[
j
][
i
]
=
\
...
@@ -210,7 +310,11 @@ def traffic_programme_para_init(num_of_load_area, num_of_unload_area, num_of_exc
...
@@ -210,7 +310,11 @@ def traffic_programme_para_init(num_of_load_area, num_of_unload_area, num_of_exc
traffic_programme_para
.
goto_unload_point_factor
[
i
][
j
]
=
\
traffic_programme_para
.
goto_unload_point_factor
[
i
][
j
]
=
\
traffic_programme_para
.
goto_unload_area_factor
[
load_area_index
][
unload_area_index
]
traffic_programme_para
.
goto_unload_area_factor
[
load_area_index
][
unload_area_index
]
<<<<<<<
HEAD
# 每条卸载道路的优先级,等于挖机的优先级乘以卸载点的优先级
# 每条卸载道路的优先级,等于挖机的优先级乘以卸载点的优先级
=======
# 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
traffic_programme_para
.
priority_coefficient
[
i
][
j
]
=
traffic_programme_para
.
excavator_priority_coefficient
[
i
]
\
traffic_programme_para
.
priority_coefficient
[
i
][
j
]
=
traffic_programme_para
.
excavator_priority_coefficient
[
i
]
\
*
traffic_programme_para
.
dump_priority_coefficient
[
j
]
*
traffic_programme_para
.
dump_priority_coefficient
[
j
]
...
@@ -219,7 +323,11 @@ def traffic_programme_para_init(num_of_load_area, num_of_unload_area, num_of_exc
...
@@ -219,7 +323,11 @@ def traffic_programme_para_init(num_of_load_area, num_of_unload_area, num_of_exc
traffic_programme_para
.
goto_load_area_distance
[
unload_area_index
][
load_area_index
]
traffic_programme_para
.
goto_load_area_distance
[
unload_area_index
][
load_area_index
]
traffic_programme_para
.
goto_dump_distance
[
i
][
j
]
=
\
traffic_programme_para
.
goto_dump_distance
[
i
][
j
]
=
\
<<<<<<<
HEAD
traffic_programme_para
.
goto_unload_area_distance
[
load_area_index
][
unload_area_index
]
traffic_programme_para
.
goto_unload_area_distance
[
load_area_index
][
unload_area_index
]
=======
traffic_programme_para
.
goto_load_area_distance
[
load_area_index
][
unload_area_index
]
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
return
traffic_programme_para
return
traffic_programme_para
...
@@ -230,6 +338,7 @@ def transportation_problem_slove(coefficient, w_ij, s_ij, b_excavator,
...
@@ -230,6 +338,7 @@ def transportation_problem_slove(coefficient, w_ij, s_ij, b_excavator,
max_unload_weigh_alg_flag
,
truck_total_num
,
max_unload_weigh_alg_flag
,
truck_total_num
,
goto_excavator_dis
,
goto_dump_dis
,
min_throughout
,
goto_excavator_dis
,
goto_dump_dis
,
min_throughout
,
grade_lower_array
=
None
,
grade_upper_array
=
None
):
grade_lower_array
=
None
,
grade_upper_array
=
None
):
<<<<<<<
HEAD
row
=
len
(
coefficient
)
# 代表挖机的个数,第i行代表第i台挖机
row
=
len
(
coefficient
)
# 代表挖机的个数,第i行代表第i台挖机
col
=
len
(
coefficient
[
0
])
# 代表卸载点的个数,第j行代表第j个卸载点
col
=
len
(
coefficient
[
0
])
# 代表卸载点的个数,第j行代表第j个卸载点
...
@@ -237,6 +346,15 @@ def transportation_problem_slove(coefficient, w_ij, s_ij, b_excavator,
...
@@ -237,6 +346,15 @@ def transportation_problem_slove(coefficient, w_ij, s_ij, b_excavator,
# 卸载道路的流量,单位是吨/小时,i代表起点为第i个挖机,j代表终点为第j个卸载点
# 卸载道路的流量,单位是吨/小时,i代表起点为第i个挖机,j代表终点为第j个卸载点
var_x
=
[[
pulp
.
LpVariable
(
'x{0}{1}'
.
format
(
i
,
j
),
lowBound
=
0
)
for
j
in
range
(
col
)]
for
i
in
range
(
row
)]
var_x
=
[[
pulp
.
LpVariable
(
'x{0}{1}'
.
format
(
i
,
j
),
lowBound
=
0
)
for
j
in
range
(
col
)]
for
i
in
range
(
row
)]
# 装载道路的流量,单位是吨/小时,i代表起点为第i个卸载点,j代表终点为第j个挖机
# 装载道路的流量,单位是吨/小时,i代表起点为第i个卸载点,j代表终点为第j个挖机
=======
row
=
len
(
coefficient
)
# 代表电铲的个数,第i行代表第i台电铲
col
=
len
(
coefficient
[
0
])
# 代表卸载点的个数,第j行代表第j个卸载点
# prob = pulp.LpProblem('Transportation Problem', sense=pulp.LpMaximize)
# 卸载道路的流量,单位是吨/小时,i代表起点为第i个电铲,j代表终点为第j个卸载点
var_x
=
[[
pulp
.
LpVariable
(
'x{0}{1}'
.
format
(
i
,
j
),
lowBound
=
0
)
for
j
in
range
(
col
)]
for
i
in
range
(
row
)]
# 装载道路的流量,单位是吨/小时,i代表起点为第i个卸载点,j代表终点为第j个电铲
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
var_y
=
[[
pulp
.
LpVariable
(
'y{0}{1}'
.
format
(
i
,
j
),
lowBound
=
0
)
for
j
in
range
(
row
)]
for
i
in
range
(
col
)]
var_y
=
[[
pulp
.
LpVariable
(
'y{0}{1}'
.
format
(
i
,
j
),
lowBound
=
0
)
for
j
in
range
(
row
)]
for
i
in
range
(
col
)]
flatten
=
lambda
x
:
[
y
for
l
in
x
for
y
in
flatten
(
l
)]
if
type
(
x
)
is
list
else
[
x
]
flatten
=
lambda
x
:
[
y
for
l
in
x
for
y
in
flatten
(
l
)]
if
type
(
x
)
is
list
else
[
x
]
...
@@ -267,7 +385,11 @@ def transportation_problem_slove(coefficient, w_ij, s_ij, b_excavator,
...
@@ -267,7 +385,11 @@ def transportation_problem_slove(coefficient, w_ij, s_ij, b_excavator,
pulp
.
lpSum
(
load_truck_totla_num_array
)
<=
truck_total_num
)
pulp
.
lpSum
(
load_truck_totla_num_array
)
<=
truck_total_num
)
# 最大工作强度约束
# 最大工作强度约束
<<<<<<<
HEAD
# 约束每个挖机的工作强度
# 约束每个挖机的工作强度
=======
# 约束每个电铲的工作强度
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
for
i
in
range
(
row
):
for
i
in
range
(
row
):
prob
+=
(
pulp
.
lpSum
(
var_x
[
i
])
<=
b_excavator
[
i
])
prob
+=
(
pulp
.
lpSum
(
var_x
[
i
])
<=
b_excavator
[
i
])
# 约束每个卸载点的工作强度
# 约束每个卸载点的工作强度
...
@@ -276,7 +398,11 @@ def transportation_problem_slove(coefficient, w_ij, s_ij, b_excavator,
...
@@ -276,7 +398,11 @@ def transportation_problem_slove(coefficient, w_ij, s_ij, b_excavator,
'''
'''
# 车流基尔霍夫定理约束
# 车流基尔霍夫定理约束
<<<<<<< HEAD
# 进入挖机和从挖机出去的车辆个数需要相同
# 进入挖机和从挖机出去的车辆个数需要相同
=======
# 进入电铲和从电铲出去的车辆个数需要相同
>>>>>>> acc639d456bb6cab81fb693f04b04a95a6f30b81
for i in range(row):
for i in range(row):
prob += (pulp.lpSum(unload_truck_total_num_array[i]) == pulp.lpSum(load_truck_totla_num_array[:,i]))
prob += (pulp.lpSum(unload_truck_total_num_array[i]) == pulp.lpSum(load_truck_totla_num_array[:,i]))
# 从装载点离开和进来的车辆个数需要相同
# 从装载点离开和进来的车辆个数需要相同
...
@@ -293,7 +419,11 @@ def transportation_problem_slove(coefficient, w_ij, s_ij, b_excavator,
...
@@ -293,7 +419,11 @@ def transportation_problem_slove(coefficient, w_ij, s_ij, b_excavator,
prob
+=
(
pulp
.
lpSum
((
np
.
array
(
var_y
))[
j
])
<=
pulp
.
lpSum
((
np
.
array
(
var_x
))[:,
j
]))
prob
+=
(
pulp
.
lpSum
((
np
.
array
(
var_y
))[
j
])
<=
pulp
.
lpSum
((
np
.
array
(
var_x
))[:,
j
]))
# 矿石品位约束卸载
# 矿石品位约束卸载
<<<<<<<
HEAD
# 去往卸载点的流量使用矩阵乘法乘以每个挖机处矿石的品位,得到每个卸载点的矿石品位总和
# 去往卸载点的流量使用矩阵乘法乘以每个挖机处矿石的品位,得到每个卸载点的矿石品位总和
=======
# 去往卸载点的流量使用矩阵乘法乘以每个电铲处矿石的品位,得到每个卸载点的矿石品位总和
>>>>>>>
acc639d456bb6cab81fb693f04b04a95a6f30b81
grade_array
=
np
.
dot
(
grade_loading_array
,
var_x
)
grade_array
=
np
.
dot
(
grade_loading_array
,
var_x
)
for
j
in
range
(
col
):
for
j
in
range
(
col
):
sum_traffic_unload
=
pulp
.
lpSum
((
np
.
array
(
var_x
))[:,
j
])
sum_traffic_unload
=
pulp
.
lpSum
((
np
.
array
(
var_x
))[:,
j
])
...
...
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