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
d950f451
Commit
d950f451
authored
Oct 09, 2021
by
Allvey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复矿卡禁止BUG
parent
bf5cad37
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
109 additions
and
53 deletions
+109
-53
dump.py
equipment/dump.py
+8
-1
excavator.py
equipment/excavator.py
+2
-1
truck.py
equipment/truck.py
+32
-31
para_config.py
para_config.py
+42
-8
path_plannner.py
path_plan/path_plannner.py
+10
-3
realtime_dispatch.py
realtime_dispatch.py
+0
-0
settings.py
settings.py
+1
-1
traffic_flow_info.py
traffic_flow/traffic_flow_info.py
+0
-0
traffic_flow_planner.py
traffic_flow/traffic_flow_planner.py
+14
-8
No files found.
equipment/dump.py
View file @
d950f451
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
from
para_config
import
*
from
para_config
import
*
from
settings
import
*
from
settings
import
*
# 卸载设备类
# 卸载设备类
class
DumpInfo
(
WalkManage
):
class
DumpInfo
(
WalkManage
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -96,7 +97,7 @@ class DumpInfo(WalkManage):
...
@@ -96,7 +97,7 @@ class DumpInfo(WalkManage):
for
query
in
(
for
query
in
(
session_mysql
.
query
(
WorkRecord
)
session_mysql
.
query
(
WorkRecord
)
.
filter
(
.
filter
(
WorkRecord
.
equipment_id
==
dump_id
,
WorkRecord
.
work_day
>
now
WorkRecord
.
equipment_id
==
dump_id
,
WorkRecord
.
work_day
>
=
now
)
)
.
first
()
.
first
()
):
):
...
@@ -115,17 +116,23 @@ class DumpInfo(WalkManage):
...
@@ -115,17 +116,23 @@ class DumpInfo(WalkManage):
def
update_dump_material
(
self
):
def
update_dump_material
(
self
):
self
.
dump_material
=
{}
self
.
dump_material
=
{}
for
dump_id
in
dynamic_dump_set
:
for
dump_id
in
dynamic_dump_set
:
try
:
unload_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
.
unload_area_id
unload_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
.
unload_area_id
dump_material_id
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
Material
dump_material_id
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
Material
self
.
dump_material
[
dump_id
]
=
dump_material_id
self
.
dump_material
[
dump_id
]
=
dump_material_id
except
Exception
as
es
:
logger
.
error
(
"无动态派车计划可用"
)
def
update_dump_priority
(
self
):
def
update_dump_priority
(
self
):
self
.
dump_priority_coefficient
=
np
.
ones
(
self
.
dynamic_dump_num
)
self
.
dump_priority_coefficient
=
np
.
ones
(
self
.
dynamic_dump_num
)
for
dump_id
in
dynamic_dump_set
:
for
dump_id
in
dynamic_dump_set
:
try
:
unload_area_index
=
self
.
dump_index_to_unload_area_index_dict
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
unload_area_index
=
self
.
dump_index_to_unload_area_index_dict
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
unload_area_id
=
unload_area_index_to_uuid_dict
[
unload_area_index
]
unload_area_id
=
unload_area_index_to_uuid_dict
[
unload_area_index
]
item
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
item
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
self
.
dump_priority_coefficient
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
item
.
Priority
self
.
dump_priority_coefficient
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
item
.
Priority
except
Exception
as
es
:
logger
.
error
(
"无动态派车计划可用"
)
def
para_period_update
(
self
):
def
para_period_update
(
self
):
...
...
equipment/excavator.py
View file @
d950f451
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
from
para_config
import
*
from
para_config
import
*
from
settings
import
*
from
settings
import
*
# 挖机设备类
# 挖机设备类
class
ExcavatorInfo
(
WalkManage
):
class
ExcavatorInfo
(
WalkManage
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -90,7 +91,7 @@ class ExcavatorInfo(WalkManage):
...
@@ -90,7 +91,7 @@ class ExcavatorInfo(WalkManage):
session_mysql
.
query
(
WorkRecord
)
session_mysql
.
query
(
WorkRecord
)
.
filter
(
.
filter
(
WorkRecord
.
equipment_id
==
excavator_id
,
WorkRecord
.
equipment_id
==
excavator_id
,
WorkRecord
.
work_day
>
now
,
WorkRecord
.
work_day
>
=
now
,
)
)
.
first
()
.
first
()
):
):
...
...
equipment/truck.py
View file @
d950f451
...
@@ -7,10 +7,13 @@
...
@@ -7,10 +7,13 @@
# @Software: PyCharm
# @Software: PyCharm
from
para_config
import
*
from
para_config
import
*
from
settings
import
*
from
equipment.dump
import
DumpInfo
from
equipment.dump
import
DumpInfo
from
equipment.excavator
import
ExcavatorInfo
from
equipment.excavator
import
ExcavatorInfo
# 引入对象
dump
=
DumpInfo
()
excavator
=
ExcavatorInfo
()
# 矿卡设备类
# 矿卡设备类
class
TruckInfo
(
WalkManage
):
class
TruckInfo
(
WalkManage
):
...
@@ -18,13 +21,13 @@ class TruckInfo(WalkManage):
...
@@ -18,13 +21,13 @@ class TruckInfo(WalkManage):
# object fileds
# object fileds
# self.walker = WalkManage()
# self.walker = WalkManage()
# 矿卡数量
# 矿卡数量
self
.
dynamic_truck_num
=
len
(
dynamic_truck_set
)
self
.
dynamic_truck_num
=
get_value
(
"dynamic_truck_num"
)
# 用于动态派车的矿卡集合
self
.
dynamic_truck_set
=
get_value
(
"dynamic_truck_set"
)
# 矿卡抵达卸载设备时间
# 矿卡抵达卸载设备时间
self
.
cur_truck_reach_dump
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
cur_truck_reach_dump
=
np
.
zeros
(
self
.
dynamic_truck_num
)
# 矿卡抵达挖机时间
# 矿卡抵达挖机时间
self
.
cur_truck_reach_excavator
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
cur_truck_reach_excavator
=
np
.
zeros
(
self
.
dynamic_truck_num
)
# 用于动态派车的矿卡集合
self
.
dynamic_truck_set
=
[]
# 矿卡最后装载/卸载时间
# 矿卡最后装载/卸载时间
self
.
last_load_time
=
{}
self
.
last_load_time
=
{}
self
.
last_unload_time
=
{}
self
.
last_unload_time
=
{}
...
@@ -56,21 +59,18 @@ class TruckInfo(WalkManage):
...
@@ -56,21 +59,18 @@ class TruckInfo(WalkManage):
# 矿卡卸点排斥关系
# 矿卡卸点排斥关系
self
.
truck_dump_exclude
=
{}
self
.
truck_dump_exclude
=
{}
# 排斥关系modify
# 排斥关系modify
self
.
excavator_exclude_modify
=
np
.
full
((
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
self
.
excavator_exclude_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
get_value
(
"dynamic_excavator_num"
)
),
0
)
# 矿卡优先级
# 矿卡优先级
self
.
truck_priority
=
np
.
ones
(
self
.
dynamic_truck_num
)
self
.
truck_priority
=
np
.
ones
(
self
.
dynamic_truck_num
)
# 矿卡绑定物料
# 矿卡绑定物料
self
.
truck_material_bind
=
{}
self
.
truck_material_bind
=
{}
# 矿卡绑定物料modify
# 矿卡绑定物料modify
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_
excavator
_num
),
0
)
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_
dump
_num
),
0
)
self
.
excavator_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
excavator_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
# 引入对象
self
.
dump
=
DumpInfo
()
self
.
excavator
=
ExcavatorInfo
()
# 初始化读取映射及路网
# 初始化读取映射及路网
self
.
period_map_para_load
()
self
.
period_map_para_load
()
self
.
period_walk_para_load
()
self
.
period_walk_para_load
()
# 初始化读取参数
self
.
para_period_update
()
self
.
para_period_update
()
def
get_truck_current_trip
(
self
):
def
get_truck_current_trip
(
self
):
...
@@ -363,7 +363,7 @@ class TruckInfo(WalkManage):
...
@@ -363,7 +363,7 @@ class TruckInfo(WalkManage):
self
.
truck_excavator_exclude
=
{}
self
.
truck_excavator_exclude
=
{}
self
.
excavator_exclude_modify
=
np
.
full
(
self
.
excavator_exclude_modify
=
np
.
full
(
(
dynamic_truck_num
,
dynamic_excavator_num
),
0
(
self
.
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
)
try
:
try
:
...
@@ -393,15 +393,15 @@ class TruckInfo(WalkManage):
...
@@ -393,15 +393,15 @@ class TruckInfo(WalkManage):
def
update_truck_material
(
self
):
def
update_truck_material
(
self
):
self
.
excavator
.
update_excavator_material
()
excavator
.
update_excavator_material
()
self
.
dump
.
update_dump_material
()
dump
.
update_dump_material
()
self
.
truck_material_bind
=
{}
self
.
truck_material_bind
=
{}
self
.
update_truck_excavator_bind
()
self
.
update_truck_excavator_bind
()
self
.
update_truck_dump_area_bind
()
self
.
update_truck_dump_area_bind
()
self
.
excavator_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
self
.
excavator_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_
excavator
_num
),
0
)
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_
dump
_num
),
0
)
for
truck_id
in
dynamic_truck_set
:
for
truck_id
in
dynamic_truck_set
:
...
@@ -415,7 +415,7 @@ class TruckInfo(WalkManage):
...
@@ -415,7 +415,7 @@ class TruckInfo(WalkManage):
if
truck_id
in
self
.
truck_excavator_bind
:
if
truck_id
in
self
.
truck_excavator_bind
:
excavator_id
=
self
.
truck_excavator_bind
[
truck_id
]
excavator_id
=
self
.
truck_excavator_bind
[
truck_id
]
# print(self.excavator.excavator_material)
# print(self.excavator.excavator_material)
excavator_material_id
=
self
.
excavator
.
excavator_material
[
excavator_id
]
excavator_material_id
=
excavator
.
excavator_material
[
excavator_id
]
self
.
truck_material_bind
[
truck_id
]
=
excavator_material_id
self
.
truck_material_bind
[
truck_id
]
=
excavator_material_id
...
@@ -428,14 +428,14 @@ class TruckInfo(WalkManage):
...
@@ -428,14 +428,14 @@ class TruckInfo(WalkManage):
material
=
self
.
truck_material_bind
[
truck_id
]
material
=
self
.
truck_material_bind
[
truck_id
]
for
excavator_id
in
dynamic_excavator_set
:
for
excavator_id
in
dynamic_excavator_set
:
excavator_material_id
=
self
.
excavator
.
excavator_material
[
excavator_id
]
excavator_material_id
=
excavator
.
excavator_material
[
excavator_id
]
excavator_index
=
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
excavator_index
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
if
excavator_material_id
!=
material
:
if
excavator_material_id
!=
material
:
self
.
excavator_material_bind_modify
[
truck_index
][
excavator_index
]
=
1000000
self
.
excavator_material_bind_modify
[
truck_index
][
excavator_index
]
=
1000000
for
dump_id
in
dynamic_dump_set
:
for
dump_id
in
dynamic_dump_set
:
dump_material_id
=
self
.
dump
.
dump_material
[
dump_id
]
dump_material_id
=
dump
.
dump_material
[
dump_id
]
dump_index
=
self
.
dump
.
dump_uuid_to_index_dict
[
dump_id
]
dump_index
=
dump
.
dump_uuid_to_index_dict
[
dump_id
]
if
dump_material_id
!=
material
:
if
dump_material_id
!=
material
:
self
.
dump_material_bind_modify
[
truck_index
][
dump_index
]
=
1000000
self
.
dump_material_bind_modify
[
truck_index
][
dump_index
]
=
1000000
...
@@ -460,6 +460,10 @@ class TruckInfo(WalkManage):
...
@@ -460,6 +460,10 @@ class TruckInfo(WalkManage):
filter
(
Equipment
.
id
==
truck_id
)
.
first
()
.
max_speed
filter
(
Equipment
.
id
==
truck_id
)
.
first
()
.
max_speed
def
reset
(
self
):
def
reset
(
self
):
# 更新矿卡数量
self
.
dynamic_truck_num
=
get_value
(
"dynamic_truck_num"
)
# 更新矿卡集合
self
.
dynamic_truck_set
=
get_value
(
"dynamic_truck_set"
)
# 矿卡挖机绑定关系
# 矿卡挖机绑定关系
self
.
truck_excavator_bind
=
{}
self
.
truck_excavator_bind
=
{}
# 矿卡卸点绑定关系
# 矿卡卸点绑定关系
...
@@ -469,7 +473,7 @@ class TruckInfo(WalkManage):
...
@@ -469,7 +473,7 @@ class TruckInfo(WalkManage):
# 矿卡卸点排斥关系
# 矿卡卸点排斥关系
self
.
truck_dump_exclude
=
{}
self
.
truck_dump_exclude
=
{}
# 排斥关系modify
# 排斥关系modify
self
.
excavator_exclude_modify
=
np
.
full
((
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
self
.
excavator_exclude_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
get_value
(
"dynamic_excavator_num"
)
),
0
)
# 矿卡优先级
# 矿卡优先级
self
.
truck_priority
=
np
.
ones
(
self
.
dynamic_truck_num
)
self
.
truck_priority
=
np
.
ones
(
self
.
dynamic_truck_num
)
# 矿卡绑定物料
# 矿卡绑定物料
...
@@ -496,17 +500,14 @@ class TruckInfo(WalkManage):
...
@@ -496,17 +500,14 @@ class TruckInfo(WalkManage):
self
.
period_walk_para_load
()
self
.
period_walk_para_load
()
# 更新全部矿卡设备集合
# # 更新全部矿卡设备集合
truck_set
=
set
(
update_total_truck
())
# truck_set = set(update_total_truck())
#
# 更新固定派车矿卡集合
# # 更新固定派车矿卡集合
fixed_truck_set
=
set
(
update_fixdisp_truck
())
# fixed_truck_set = set(update_fixdisp_truck())
#
# 更新动态派车矿卡集合
# # 更新动态派车矿卡集合
self
.
dynamic_truck_set
=
truck_set
.
difference
(
fixed_truck_set
)
# self.dynamic_truck_set = truck_set.difference(fixed_truck_set)
# 更新矿卡数量
self
.
dynamic_truck_num
=
len
(
self
.
dynamic_truck_set
)
# 更新有效载重
# 更新有效载重
self
.
update_truck_payload
()
self
.
update_truck_payload
()
...
...
para_config.py
View file @
d950f451
...
@@ -37,6 +37,11 @@ excavator_target_mass = 5000
...
@@ -37,6 +37,11 @@ excavator_target_mass = 5000
# 任务集合
# 任务集合
task_set
=
[
-
2
,
0
,
1
,
2
,
3
,
4
,
5
]
task_set
=
[
-
2
,
0
,
1
,
2
,
3
,
4
,
5
]
#
# truck = TruckInfo()
# excavator = ExcavatorInfo()
# dump = DumpInfo()
# Big integer
# Big integer
M
=
100000000
M
=
100000000
...
@@ -80,6 +85,18 @@ dynamic_excavator_num = len(dynamic_excavator_set)
...
@@ -80,6 +85,18 @@ dynamic_excavator_num = len(dynamic_excavator_set)
dynamic_dump_set
=
set
(
update_autodisp_dump
())
dynamic_dump_set
=
set
(
update_autodisp_dump
())
dynamic_dump_num
=
len
(
dynamic_dump_set
)
dynamic_dump_num
=
len
(
dynamic_dump_set
)
global
global_dict
global_dict
=
{}
global_dict
[
"dynamic_truck_set"
]
=
dynamic_truck_set
global_dict
[
"dynamic_truck_num"
]
=
dynamic_truck_num
global_dict
[
"dynamic_excavator_set"
]
=
dynamic_excavator_set
global_dict
[
"dynamic_excavator_num"
]
=
dynamic_excavator_num
global_dict
[
"dynamic_dump_set"
]
=
dynamic_dump_set
global_dict
[
"dynamic_dump_num"
]
=
dynamic_dump_num
# 设备映射类, 存储除工作区以外的映射关系
# 设备映射类, 存储除工作区以外的映射关系
# 其余设备类继承该类
# 其余设备类继承该类
class
DeviceMap
:
class
DeviceMap
:
...
@@ -292,7 +309,7 @@ class WalkManage(DeviceMap):
...
@@ -292,7 +309,7 @@ class WalkManage(DeviceMap):
logger
.
error
(
"设备路网信息异常异常"
)
logger
.
error
(
"设备路网信息异常异常"
)
logger
.
error
(
es
)
logger
.
error
(
es
)
#
try:
try
:
for
item
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
for
item
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
load_area
=
str
(
item
.
load_area_id
)
load_area
=
str
(
item
.
load_area_id
)
park_area
=
str
(
item
.
park_area_id
)
park_area
=
str
(
item
.
park_area_id
)
...
@@ -304,10 +321,10 @@ class WalkManage(DeviceMap):
...
@@ -304,10 +321,10 @@ class WalkManage(DeviceMap):
self
.
walk_time_park_to_load_area
[
park_index
][
load_area_index
]
=
float
(
self
.
walk_time_park_to_load_area
[
park_index
][
load_area_index
]
=
float
(
60
/
1000
*
item
.
park_load_distance
/
empty_speed
60
/
1000
*
item
.
park_load_distance
/
empty_speed
)
)
#
except Exception as es:
except
Exception
as
es
:
#
logger.error("备停区路网信息异常")
logger
.
error
(
"备停区路网信息异常"
)
#
logger.error(es)
logger
.
error
(
es
)
#
try:
try
:
for
i
in
range
(
park_num
):
for
i
in
range
(
park_num
):
for
j
in
range
(
dynamic_excavator_num
):
for
j
in
range
(
dynamic_excavator_num
):
self
.
distance_park_to_excavator
[
i
][
j
]
=
self
.
distance_park_to_load_area
[
self
.
distance_park_to_excavator
[
i
][
j
]
=
self
.
distance_park_to_load_area
[
...
@@ -318,9 +335,9 @@ class WalkManage(DeviceMap):
...
@@ -318,9 +335,9 @@ class WalkManage(DeviceMap):
]
=
self
.
walk_time_park_to_load_area
[
i
][
]
=
self
.
walk_time_park_to_load_area
[
i
][
self
.
excavator_index_to_load_area_index_dict
[
j
]
self
.
excavator_index_to_load_area_index_dict
[
j
]
]
]
#
except Exception as es:
except
Exception
as
es
:
#
logger.error("备停区设备路网信息异常")
logger
.
error
(
"备停区设备路网信息异常"
)
#
logger.error(es)
logger
.
error
(
es
)
def
period_walk_para_load
(
self
):
def
period_walk_para_load
(
self
):
# 装载路网信息
# 装载路网信息
...
@@ -357,6 +374,11 @@ def period_para_update():
...
@@ -357,6 +374,11 @@ def period_para_update():
global
park_uuid_to_index_dict
,
park_index_to_uuid_dict
global
park_uuid_to_index_dict
,
park_index_to_uuid_dict
global
truck_uuid_to_name_dict
,
truck_name_to_uuid_dict
global
truck_uuid_to_name_dict
,
truck_name_to_uuid_dict
global
dynamic_truck_num
,
dynamic_excavator_num
,
dynamic_dump_num
global
dynamic_truck_num
,
dynamic_excavator_num
,
dynamic_dump_num
# 清空数据库缓存
session_mysql
.
commit
()
session_mysql
.
flush
()
# 装载区、卸载区、备停区在调度算法运行器件默认不发生改变,提前计算部分参量
# 装载区、卸载区、备停区在调度算法运行器件默认不发生改变,提前计算部分参量
# (uuid,index(id)映射关系, 装载区数量, 卸载区数量, 备停区数量, 以及初次统计动态调度矿卡)
# (uuid,index(id)映射关系, 装载区数量, 卸载区数量, 备停区数量, 以及初次统计动态调度矿卡)
(
(
...
@@ -388,6 +410,7 @@ def period_para_update():
...
@@ -388,6 +410,7 @@ def period_para_update():
dynamic_truck_num
=
len
(
dynamic_truck_set
)
dynamic_truck_num
=
len
(
dynamic_truck_set
)
logger
.
info
(
"可用于动态派车的矿卡:"
)
logger
.
info
(
"可用于动态派车的矿卡:"
)
logger
.
info
(
dynamic_truck_num
)
logger
.
info
(
dynamic_truck_set
)
logger
.
info
(
dynamic_truck_set
)
# 用于动态调度的挖机及卸载设备
# 用于动态调度的挖机及卸载设备
...
@@ -400,3 +423,14 @@ def period_para_update():
...
@@ -400,3 +423,14 @@ def period_para_update():
device_map
.
period_map_para_update
()
device_map
.
period_map_para_update
()
walk_manage
.
period_walk_para_update
()
walk_manage
.
period_walk_para_update
()
global_dict
[
"dynamic_truck_set"
]
=
dynamic_truck_set
global_dict
[
"dynamic_truck_num"
]
=
dynamic_truck_num
global_dict
[
"dynamic_excavator_set"
]
=
dynamic_excavator_set
global_dict
[
"dynamic_excavator_num"
]
=
dynamic_excavator_num
global_dict
[
"dynamic_dump_set"
]
=
dynamic_dump_set
global_dict
[
"dynamic_dump_num"
]
=
dynamic_dump_num
def
get_value
(
name
):
return
global_dict
[
name
]
path_plan/path_plannner.py
View file @
d950f451
...
@@ -13,6 +13,10 @@ from tables import *
...
@@ -13,6 +13,10 @@ from tables import *
M
=
1000000
M
=
1000000
truck
=
TruckInfo
()
truck
.
update_truck_size
()
class
PathPlanner
(
WalkManage
):
class
PathPlanner
(
WalkManage
):
def
__init__
(
self
):
def
__init__
(
self
):
# 路线行驶成本
# 路线行驶成本
...
@@ -20,9 +24,8 @@ class PathPlanner(WalkManage):
...
@@ -20,9 +24,8 @@ class PathPlanner(WalkManage):
# 路段集合
# 路段集合
self
.
lane_set
=
{}
self
.
lane_set
=
{}
# 车辆长度(暂)
# 车辆长度(暂)
self
.
truck
=
TruckInfo
()
# self.truck_length = float(sum(truck.get_length().values())) / len(truck.get_length())
self
.
truck
.
update_truck_size
()
self
.
truck_length
=
3
self
.
truck_length
=
float
(
sum
(
self
.
truck
.
get_length
()
.
values
()))
/
len
(
self
.
truck
.
get_length
())
# 装载区数量
# 装载区数量
self
.
num_of_load_area
=
len
(
set
(
update_load_area
()))
self
.
num_of_load_area
=
len
(
set
(
update_load_area
()))
# 卸载区数量
# 卸载区数量
...
@@ -167,6 +170,7 @@ class PathPlanner(WalkManage):
...
@@ -167,6 +170,7 @@ class PathPlanner(WalkManage):
cost_to_dump
=
np
.
zeros_like
(
self
.
distance_to_dump
)
cost_to_dump
=
np
.
zeros_like
(
self
.
distance_to_dump
)
cost_park_to_excavator
=
np
.
zeros_like
(
self
.
distance_park_to_excavator
)
cost_park_to_excavator
=
np
.
zeros_like
(
self
.
distance_park_to_excavator
)
try
:
# 路网权重
# 路网权重
walk_weight
,
park_walk_weight
=
weighted_walk_cost
()
walk_weight
,
park_walk_weight
=
weighted_walk_cost
()
...
@@ -177,6 +181,9 @@ class PathPlanner(WalkManage):
...
@@ -177,6 +181,9 @@ class PathPlanner(WalkManage):
print
(
"walk_avail"
,
walk_available
)
print
(
"walk_avail"
,
walk_available
)
except
Exception
as
es
:
logger
.
error
(
"无派车计划可用"
)
for
i
in
range
(
dynamic_dump_num
):
for
i
in
range
(
dynamic_dump_num
):
for
j
in
range
(
dynamic_excavator_num
):
for
j
in
range
(
dynamic_excavator_num
):
load_area_index
=
self
.
excavator_index_to_load_area_index_dict
[
j
]
load_area_index
=
self
.
excavator_index_to_load_area_index_dict
[
j
]
...
...
realtime_dispatch.py
View file @
d950f451
This diff is collapsed.
Click to expand it.
settings.py
View file @
d950f451
...
@@ -43,7 +43,7 @@ filehandler = logging.handlers.RotatingFileHandler(log_path + "/dispatch.log", m
...
@@ -43,7 +43,7 @@ filehandler = logging.handlers.RotatingFileHandler(log_path + "/dispatch.log", m
# 设置后缀名称,跟strftime的格式一样
# 设置后缀名称,跟strftime的格式一样
filehandler
.
suffix
=
"
%
Y-
%
m-
%
d_
%
H-
%
M.log"
filehandler
.
suffix
=
"
%
Y-
%
m-
%
d_
%
H-
%
M.log"
formatter
=
logging
.
Formatter
(
"
%(asctime)
s -
%(name)
s:
%(levelname)
s
%(message)
s"
)
formatter
=
logging
.
Formatter
(
"
%(asctime)
s -
%(name)
s:
%(levelname)
s
%(
filename)
s
%(
message)
s"
)
filehandler
.
setFormatter
(
formatter
)
filehandler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
filehandler
)
logger
.
addHandler
(
filehandler
)
...
...
traffic_flow/traffic_flow_info.py
View file @
d950f451
This diff is collapsed.
Click to expand it.
traffic_flow/traffic_flow_planner.py
View file @
d950f451
...
@@ -9,10 +9,7 @@
...
@@ -9,10 +9,7 @@
# import
# import
import
pulp
import
pulp
from
traffic_flow.traffic_flow_info
import
*
from
traffic_flow.traffic_flow_info
import
*
# from backstore_traffic_flow_info import *
from
para_config
import
*
# import time
# start = time.time()
# much_job = [x**2 for x in range (1, 1000000, 3)]
# 从数据库中读取挖机和卸载设备相关参数,并将线性规划所用参数保存在TrafficProgPara类中
# 从数据库中读取挖机和卸载设备相关参数,并将线性规划所用参数保存在TrafficProgPara类中
...
@@ -42,14 +39,15 @@ def transportation_problem_slove(coefficient_goto_dump, coefficient_goto_excavat
...
@@ -42,14 +39,15 @@ def transportation_problem_slove(coefficient_goto_dump, coefficient_goto_excavat
prob
+=
(
pulp
.
lpDot
(
flatten
(
var_x
),
coefficient_goto_dump
.
flatten
()))
prob
+=
(
pulp
.
lpDot
(
flatten
(
var_x
),
coefficient_goto_dump
.
flatten
()))
else
:
else
:
prob
=
pulp
.
LpProblem
(
'Transportation Problem'
,
sense
=
pulp
.
LpMinimize
)
prob
=
pulp
.
LpProblem
(
'Transportation Problem'
,
sense
=
pulp
.
LpMinimize
)
goto_excavator_cost
=
var_
x
*
walk_time_to_excavator
goto_excavator_cost
=
var_
y
*
walk_time_to_excavator
goto_dump_cost
=
var_
y
*
walk_time_to_dump
goto_dump_cost
=
var_
x
*
walk_time_to_dump
prob
+=
(
pulp
.
lpSum
(
flatten
(
goto_excavator_cost
))
+
1.5
*
pulp
.
lpSum
(
flatten
(
goto_dump_cost
)))
prob
+=
(
pulp
.
lpSum
(
flatten
(
goto_excavator_cost
))
+
1.5
*
pulp
.
lpSum
(
flatten
(
goto_dump_cost
)))
# 定义约束条件
# 定义约束条件
# 最小产量约束,仅在最小化成本模式下成立
# 最小产量约束,仅在最小化成本模式下成立
if
max_unload_weigh_alg_flag
==
False
:
if
max_unload_weigh_alg_flag
==
False
:
prob
+=
pulp
.
lpSum
(
var_x
)
>=
min_throughout
for
i
in
range
(
col
):
prob
+=
pulp
.
lpSum
(
var_y
[
i
])
>=
min_throughout
[
i
]
logger
.
info
(
"road_factor"
)
logger
.
info
(
"road_factor"
)
logger
.
info
(
w_ij
)
logger
.
info
(
w_ij
)
...
@@ -144,6 +142,10 @@ def traffic_flow_plan():
...
@@ -144,6 +142,10 @@ def traffic_flow_plan():
print
(
"装载区数量:"
,
load_area_num
,
"卸载区数量:"
,
unload_area_num
,
"挖机数量:"
,
excavator_num
,
"卸载设备数量:"
,
dump_num
)
print
(
"装载区数量:"
,
load_area_num
,
"卸载区数量:"
,
unload_area_num
,
"挖机数量:"
,
excavator_num
,
"卸载设备数量:"
,
dump_num
)
# try:
if
(
load_area_num
*
unload_area_num
*
excavator_num
*
dump_num
==
0
):
raise
Exception
(
"无派车计划可用"
)
# 初始化参量
# 初始化参量
traffic_programme_para
=
Traffic_para_init
(
load_area_num
,
unload_area_num
,
excavator_num
,
dump_num
)
traffic_programme_para
=
Traffic_para_init
(
load_area_num
,
unload_area_num
,
excavator_num
,
dump_num
)
# traffic_programme_para = traffic_programme_para_init(load_area_num, unload_area_num, excavator_num, dump_num)
# traffic_programme_para = traffic_programme_para_init(load_area_num, unload_area_num, excavator_num, dump_num)
...
@@ -204,7 +206,11 @@ def traffic_flow_plan():
...
@@ -204,7 +206,11 @@ def traffic_flow_plan():
return
res
[
"var_x"
],
res
[
"var_y"
]
return
res
[
"var_x"
],
res
[
"var_y"
]
traffic_flow_plan
()
# except Exception as es:
# logger.error("车流规划参数异常")
# logger.error(es)
return
None
# end = time.time()
# end = time.time()
# print("used {:.5}s".format(end-start))
# print("used {:.5}s".format(end-start))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment