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
43fcb027
Commit
43fcb027
authored
Aug 02, 2021
by
Allvey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add path plan module
parent
35b28e4c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
142 additions
and
33 deletions
+142
-33
path_plannner.py
path_plannner.py
+99
-10
realtime_dispatch.py
realtime_dispatch.py
+1
-10
static_data_process.py
static_data_process.py
+8
-1
tables.py
tables.py
+25
-7
traffic_flow_planner.py
traffic_flow_planner.py
+9
-5
No files found.
path_plannner.py
View file @
43fcb027
...
...
@@ -9,35 +9,124 @@
import
numpy
from
settings
import
*
from
static_data_process
import
*
from
settings
import
*
load_area_uuid_to_index_dict
,
unload_area_uuid_to_index_dict
,
\
load_area_index_to_uuid_dict
,
unload_area_index_to_uuid_dict
=
build_work_area_uuid_index_map
()
park_uuid_to_index_dict
,
park_index_to_uuid_dict
=
build_park_uuid_index_map
()
load_area_num
,
unload_area_num
=
len
(
load_area_uuid_to_index_dict
),
len
(
unload_area_uuid_to_index_dict
)
truck_uuid_to_name_dict
,
truck_name_to_uuid_dict
=
build_truck_uuid_name_map
()
M
=
1000000
class
PathPlanner
:
def
__init__
(
self
):
# 路线行驶成本
self
.
rout_cost
=
np
.
array
((
unload_area_num
,
load_area_num
))
# 路段集合
self
.
lane_set
=
{}
# 车辆长度
self
.
truck_length
=
10
# 车辆长度(暂)
self
.
truck_length
=
113
# 装载区数量
self
.
num_of_load_area
=
len
(
set
(
update_load_area
()))
# 卸载区数量
self
.
num_of_unload_area
=
len
(
set
(
update_unload_area
()))
# 备停区数量
self
.
num_of_park_area
=
len
(
set
(
update_park_area
()))
# 路网信息
self
.
walk_time_to_load_area
=
np
.
full
((
self
.
num_of_unload_area
,
self
.
num_of_load_area
),
M
)
self
.
walk_time_to_unload_area
=
np
.
full
((
self
.
num_of_unload_area
,
self
.
num_of_load_area
),
M
)
# 路网信息(备停区)
self
.
walk_time_park
=
np
.
full
((
self
.
num_of_park_area
,
self
.
num_of_load_area
),
M
)
def
path_cost_generate
(
self
,
load_area_id
,
unload_area_id
,
is_park
):
to_unload_blockage_cost
=
0
to_load_blockage_cost
=
0
to_unload_cost
=
0
to_load_cost
=
0
if
is_park
:
path
=
session_postgre
.
query
(
WalkTimePark
)
.
filter_by
(
park_area_id
=
unload_area_id
,
load_area_id
=
load_area_id
)
.
first
()
for
lane_id
in
path
.
park_load_lanes
:
to_load_blockage_cost
=
to_load_blockage_cost
+
self
.
lane_cost_generate
(
lane_id
)
to_load_cost
=
to_load_blockage_cost
+
path
.
park_load_distance
else
:
path
=
session_postgre
.
query
(
WalkTime
)
.
filter_by
(
load_area_id
=
load_area_id
,
unload_area_id
=
unload_area_id
)
.
first
()
for
lane_id
in
path
.
to_unload_lanes
:
to_unload_blockage_cost
=
to_unload_blockage_cost
+
self
.
lane_cost_generate
(
lane_id
)
for
lane_id
in
path
.
to_load_lanes
:
to_load_blockage_cost
=
to_load_blockage_cost
+
self
.
lane_cost_generate
(
lane_id
)
print
(
to_unload_blockage_cost
,
to_load_blockage_cost
)
def
path_cost_generate
(
self
,
path_id
):
pass
to_unload_cost
=
to_unload_blockage_cost
+
path
.
to_unload_distance
to_load_cost
=
to_load_blockage_cost
+
path
.
to_load_distance
return
to_unload_cost
,
to_load_cost
def
lane_cost_generate
(
self
,
lane_id
):
lane
=
session_postgre
.
query
(
Lane
)
.
filter_by
(
Id
=
lane_id
)
.
first
()
# 道路长度
lane_length
=
100
# 路段实际矿卡速度
actual_speed
=
20
lane_length
=
lane
.
Length
# 车辆自由行驶时的速度
clear_speed
=
25
clear_speed
=
lane
.
MaxSpeed
# 1. 计算阻塞时车辆密度
truck_density
=
lane_length
/
self
.
truck_length
# 2. 读取实际车流速度
actual_speed
=
20
# 2. 读取实际车流速度
(暂)
actual_speed
=
clear_speed
# 3. 计算路段阻塞程度
lane_blockage
=
(
1
-
actual_speed
/
clear_speed
)
*
truck_density
return
lane_blockage
def
walk_cost
(
self
):
for
walk_time
in
session_postgre
.
query
(
WalkTime
)
.
all
():
unload_area_index
=
unload_area_uuid_to_index_dict
[
str
(
walk_time
.
unload_area_id
)]
load_area_index
=
load_area_uuid_to_index_dict
[
str
(
walk_time
.
load_area_id
)]
self
.
walk_time_to_load_area
[
unload_area_index
][
load_area_index
],
\
self
.
walk_time_to_unload_area
[
unload_area_index
][
load_area_index
]
=
\
self
.
path_cost_generate
(
walk_time
.
load_area_id
,
walk_time
.
unload_area_id
,
False
)
for
walk_time_park
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
park_area_index
=
park_uuid_to_index_dict
[
str
(
walk_time_park
.
park_area_id
)]
load_area_index
=
load_area_uuid_to_index_dict
[
str
(
walk_time_park
.
load_area_id
)]
_
,
self
.
walk_time_park
[
park_area_index
][
load_area_index
]
=
\
self
.
path_cost_generate
(
walk_time_park
.
load_area_id
,
walk_time_park
.
park_area_id
,
True
)
print
(
self
.
walk_time_to_unload_area
)
print
(
self
.
walk_time_to_load_area
)
print
(
self
.
walk_time_park
)
def
update_truck_speed
(
self
):
truck_speed_dict
=
{}
device_name_set
=
redis2
.
keys
()
for
item
in
device_name_set
:
item
=
item
.
decode
(
encoding
=
'utf-8'
)
json_value
=
json
.
loads
(
redis2
.
get
(
item
))
device_type
=
json_value
.
get
(
'type'
)
if
device_type
==
1
:
truck_speed
=
json_value
.
get
(
'speed'
)
truck_speed_dict
[
truck_name_to_uuid_dict
[
item
]]
=
truck_speed
return
truck_speed_dict
planner
=
PathPlanner
()
planner
.
walk_cost
()
planner
.
update_truck_speed
()
realtime_dispatch.py
View file @
43fcb027
...
...
@@ -31,10 +31,6 @@ from traffic_flow_planner import *
from
settings
import
*
from
static_data_process
import
*
# item = session_postgre.query(Lane).first()
#
# print(item.LaneIds)
# 全局参数设定
# 空载任务集合
...
...
@@ -91,11 +87,6 @@ dynamic_excavator_set = set(update_autodisp_excavator())
dynamic_dump_set
=
set
(
update_autodisp_dump
())
item
=
session_postgre
.
query
(
Lane
)
.
first
()
print
(
item
.
LaneIds
)
# 设备映射类, 存储除工作区以外的映射关系
# 其余设备类继承该类
class
DeviceMap
:
...
...
@@ -428,7 +419,7 @@ class WalkManage(DeviceMap):
try
:
for
item
in
session_postgre
.
query
(
WalkTimeP
ort
)
.
all
():
for
item
in
session_postgre
.
query
(
WalkTimeP
ark
)
.
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
]
...
...
static_data_process.py
View file @
43fcb027
...
...
@@ -51,7 +51,7 @@ def build_park_uuid_index_map():
park_num
=
0
try
:
for
item
in
session_postgre
.
query
(
WalkTimeP
ort
)
.
all
():
for
item
in
session_postgre
.
query
(
WalkTimeP
ark
)
.
all
():
park
=
str
(
item
.
park_area_id
)
if
park
not
in
park_uuid_to_index_dict
:
park_uuid_to_index_dict
[
park
]
=
park_num
...
...
@@ -223,3 +223,9 @@ def update_unload_area():
for
walk_time
in
session_postgre
.
query
(
WalkTime
)
.
all
():
unload_area_list
.
append
(
walk_time
.
unload_area_id
)
return
unload_area_list
def
update_park_area
():
park_area_list
=
[]
for
walk_time_park
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
park_area_list
.
append
(
walk_time_park
.
park_area_id
)
return
park_area_list
\ No newline at end of file
tables.py
View file @
43fcb027
...
...
@@ -119,15 +119,19 @@ class WalkTime(Base):
unload_area_name
=
Column
(
VARCHAR
(
30
))
to_unload_distance
=
Column
(
Float
(
10
))
to_load_distance
=
Column
(
Float
(
10
))
to_unload_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
,
to_unload_distance
):
to_unload_distance
,
to_unload_lanes
,
to_load_lanes
):
self
.
load_area_id
=
load_area_id
self
.
unload_area_id
=
unload_area_id
self
.
load_area_name
=
load_area_name
self
.
unload_area_name
=
unload_area_name
self
.
to_load_distance
=
to_load_distance
self
.
to_unload_distance
=
to_unload_distance
self
.
to_unload_lanes
=
to_unload_lanes
self
.
to_load_lanes
=
to_load_lanes
# Rid = Column(VARCHAR(36), primary_key=True)
# load_area_id = Column(VARCHAR(36))
...
...
@@ -209,15 +213,27 @@ class EquipmentPair(Base):
self
.
isdeleted
=
isdeleted
self
.
createtime
=
createtime
# class Lane(Base):
# # 表的名字
# __tablename__ = 'Geo_Node'
# Id = Column(VARCHAR(36), primary_key=True)
# LaneIds = Column(VARCHAR(100))
#
# def __init__(self, Id, LaneIds):
# self.Id = Id
# self.LaneIds = LaneIds
class
Lane
(
Base
):
# 表的名字
__tablename__
=
'Geo_
Nod
e'
__tablename__
=
'Geo_
Lan
e'
Id
=
Column
(
VARCHAR
(
36
),
primary_key
=
True
)
LaneIds
=
Column
(
VARCHAR
(
100
))
Length
=
Column
(
Float
)
MaxSpeed
=
Column
(
Float
)
def
__init__
(
self
,
Id
,
L
aneIds
):
def
__init__
(
self
,
Id
,
L
ength
,
MaxSpeed
):
self
.
Id
=
Id
self
.
LaneIds
=
LaneIds
self
.
Length
=
Length
self
.
MaxSpeed
=
MaxSpeed
class
Dispatch
(
Base
):
# 表的名字:
...
...
@@ -259,7 +275,7 @@ class Dispatch(Base):
self
.
deletor
=
deletor
self
.
deletetime
=
deletetime
class
WalkTimeP
ort
(
Base
):
class
WalkTimeP
ark
(
Base
):
__tablename__
=
'park_load_distance'
park_area_id
=
Column
(
VARCHAR
(
36
),
primary_key
=
True
)
...
...
@@ -267,13 +283,15 @@ class WalkTimePort(Base):
park_area_name
=
Column
(
VARCHAR
(
36
))
load_area_name
=
Column
(
VARCHAR
(
36
))
park_load_distance
=
Column
(
Float
(
10
))
park_load_lanes
=
Column
(
VARCHAR
(
100
))
def
__init__
(
self
,
park_area_id
,
load_area_id
,
park_area_name
,
load_area_name
,
park_load_distance
):
def
__init__
(
self
,
park_area_id
,
load_area_id
,
park_area_name
,
load_area_name
,
park_load_distance
,
park_load_lanes
):
self
.
park_area_id
=
park_area_id
self
.
load_area_id
=
load_area_id
self
.
park_area_name
=
park_area_name
self
.
load_area_name
=
load_area_name
self
.
park_load_distance
=
park_load_distance
self
.
park_load_lanes
=
park_load_lanes
class
Equipment
(
Base
):
__tablename__
=
'sys_equipment'
...
...
traffic_flow_planner.py
View file @
43fcb027
...
...
@@ -53,10 +53,14 @@ class TrafficProgPara(object):
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
)
# 每个卸载点的优先级系数
# 装载道路上,每提供1吨的装载能力需要一辆卡车运行时长,等于(该装载道路上车辆平均运行时长/卡车平均装载能力)
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
)
# 逻辑卸载道路的运输系数
# 卸载道路上,每运输1吨货物需要一辆卡车运行时长,等于(该卸载道路上车辆平均运行时长/卡车平均实际装载量)
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装载道路的运输系数
self
.
goto_excavator_factor
=
np
.
full
((
num_of_dump
,
num_of_excavator
),
10
,
dtype
=
float
)
# 逻辑装载道路的运输系数
self
.
priority_coefficient
=
np
.
zeros
((
num_of_excavator
,
num_of_dump
))
# 卸载道路的优先级系数
self
.
grade_lower_dump_array
=
np
.
zeros
(
num_of_dump
)
# 卸载点矿石品位下限
self
.
grade_upper_dump_array
=
np
.
zeros
(
num_of_dump
)
# 卸载点矿石品位上限
...
...
@@ -65,11 +69,11 @@ class TrafficProgPara(object):
self
.
heavy_speed
=
22
# 重载矿卡平均时速
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
))
# 重载运输路线距离
# 装载道路
上,每提供1吨的装载能力需要一辆卡车运行时长,等于(该装载道路上车辆平均运行时长/卡车平均装载能力)
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
)
# 卸载道路
上,每运输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))
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_dump_distance
=
np
.
zeros
((
num_of_excavator
,
num_of_dump
))
# 逻辑重载运输路线距离
...
...
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