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
bf68c9af
Commit
bf68c9af
authored
Sep 13, 2021
by
Allvey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cover
parent
2c77ecd3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
124 additions
and
103 deletions
+124
-103
integrated-scheduling.iml
.idea/integrated-scheduling.iml
+1
-0
dump.py
equipment/dump.py
+47
-43
excavator.py
equipment/excavator.py
+7
-3
truck.py
equipment/truck.py
+6
-20
path_plannner.py
path_plan/path_plannner.py
+34
-12
priority_control.py
path_plan/priority_control.py
+12
-5
realtime_dispatch.py
realtime_dispatch.py
+0
-0
settings.py
settings.py
+4
-4
tables.py
tables.py
+4
-2
traffic_flow_info.py
traffic_flow/traffic_flow_info.py
+5
-6
traffic_flow_planner.py
traffic_flow/traffic_flow_planner.py
+4
-8
No files found.
.idea/integrated-scheduling.iml
View file @
bf68c9af
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<component
name=
"NewModuleRootManager"
>
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$/../WatoDisp-master"
/>
<content
url=
"file://$MODULE_DIR$/../WatoDisp-master"
/>
<content
url=
"file://$MODULE_DIR$"
/>
<content
url=
"file://$MODULE_DIR$"
/>
<content
url=
"file://$MODULE_DIR$/../integrated-scheduling-v2"
/>
<orderEntry
type=
"jdk"
jdkName=
"Python 3.7 (waytous)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"jdk"
jdkName=
"Python 3.7 (waytous)"
jdkType=
"Python SDK"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</component>
...
...
equipment/dump.py
View file @
bf68c9af
...
@@ -85,26 +85,26 @@ class DumpInfo(WalkManage):
...
@@ -85,26 +85,26 @@ class DumpInfo(WalkManage):
for
dump_id
in
self
.
dump_uuid_to_index_dict
.
keys
():
for
dump_id
in
self
.
dump_uuid_to_index_dict
.
keys
():
ave_unload_time
=
0
ave_unload_time
=
0
unload_count
=
0
unload_count
=
0
try
:
#
try:
for
query
in
(
#
for query in (
session_mysql
.
query
(
JobRecord
.
start_time
,
JobRecord
.
end_time
)
#
session_mysql.query(JobRecord.start_time, JobRecord.end_time)
.
join
(
Equipment
,
JobRecord
.
equipment_id
==
Equipment
.
equipment_id
)
#
.join(Equipment, JobRecord.equipment_id == Equipment.equipment_id)
.
filter
(
Equipment
.
id
==
dump_id
,
JobRecord
.
end_time
!=
None
)
#
.filter(Equipment.id == dump_id, JobRecord.end_time != None)
.
order_by
(
JobRecord
.
start_time
.
desc
())
#
.order_by(JobRecord.start_time.desc())
.
limit
(
10
)
#
.limit(10)
):
#
):
ave_unload_time
=
ave_unload_time
+
float
(
#
ave_unload_time = ave_unload_time + float(
(
query
.
end_time
-
query
.
start_time
)
#
(query.end_time - query.start_time)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
)
#
/ timedelta(hours=0, minutes=1, seconds=0)
)
#
)
unload_count
=
unload_count
+
1
#
unload_count = unload_count + 1
self
.
unloading_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
(
#
self.unloading_time[self.dump_uuid_to_index_dict[dump_id]] = (
ave_unload_time
/
unload_count
#
ave_unload_time / unload_count
)
#
)
except
Exception
as
es
:
#
except Exception as es:
logger
.
error
(
f
"卸载设备 {dump_id} 卸载时间信息缺失, 已设为默认值(1min)"
)
#
logger.error(f"卸载设备 {dump_id} 卸载时间信息缺失, 已设为默认值(1min)")
logger
.
error
(
es
)
#
logger.error(es)
self
.
unloading_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
5.00
self
.
unloading_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
5.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]])
# 更新卸载设备出入时间
# 更新卸载设备出入时间
...
@@ -114,25 +114,25 @@ class DumpInfo(WalkManage):
...
@@ -114,25 +114,25 @@ class DumpInfo(WalkManage):
now
=
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d"
)
now
=
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d"
)
for
dump_id
in
self
.
dump_uuid_to_index_dict
.
keys
():
for
dump_id
in
self
.
dump_uuid_to_index_dict
.
keys
():
try
:
#
try:
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()
):
#
):
self
.
entrance_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
float
(
#
self.entrance_time[self.dump_uuid_to_index_dict[dump_id]] = float(
query
.
load_entrance_time
/
query
.
load_entrance_count
#
query.load_entrance_time / query.load_entrance_count
)
#
)
self
.
exit_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
float
(
#
self.exit_time[self.dump_uuid_to_index_dict[dump_id]] = float(
query
.
exit_entrance_time
/
query
.
exit_entrance_count
#
query.exit_entrance_time / query.exit_entrance_count
)
#
)
except
Exception
as
es
:
#
except Exception as es:
logger
.
error
(
f
"卸载设备 {dump_id} 出入场时间信息缺失, 已设为默认值(1min)"
)
#
logger.error(f"卸载设备 {dump_id} 出入场时间信息缺失, 已设为默认值(1min)")
logger
.
error
(
es
)
#
logger.error(es)
self
.
entrance_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
0.50
self
.
entrance_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
0.50
self
.
exit_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
0.50
self
.
exit_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
0.50
# 更新卸载设备实际卸载量
# 更新卸载设备实际卸载量
def
update_actual_unload_thoughout
(
self
):
def
update_actual_unload_thoughout
(
self
):
...
@@ -154,15 +154,19 @@ class DumpInfo(WalkManage):
...
@@ -154,15 +154,19 @@ class DumpInfo(WalkManage):
)
)
def
update_dump_material
(
self
):
def
update_dump_material
(
self
):
self
.
dump_material
=
{}
for
dump_id
in
dynamic_dump_set
:
for
dump_id
in
dynamic_dump_set
:
unload_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
)
.
first
()
.
unload_area_id
unload_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
.
unload_area_id
dump_material_id
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
Material
dump_material_id
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
Material
self
.
dump_material
[
dump_id
]
=
dump_material_id
\
self
.
dump_material
[
dump_id
]
=
dump_material_id
def
update_dump_priority
(
self
):
def
update_dump_priority
(
self
):
self
.
dump_priority_coefficient
=
np
.
ones
(
self
.
dynamic_dump_num
)
for
dump_id
in
dynamic_dump_set
:
for
dump_id
in
dynamic_dump_set
:
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
dump_id
)
.
first
()
unload_area_index
=
self
.
dump_index_to_unload_area_index_dict
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
self
.
dump_priority_coefficient
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
item
.
priority
unload_area_id
=
unload_area_index_to_uuid_dict
[
unload_area_index
]
item
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
self
.
dump_priority_coefficient
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
item
.
Priority
def
para_period_update
(
self
):
def
para_period_update
(
self
):
...
...
equipment/excavator.py
View file @
bf68c9af
...
@@ -167,11 +167,14 @@ class ExcavatorInfo(WalkManage):
...
@@ -167,11 +167,14 @@ class ExcavatorInfo(WalkManage):
def
update_excavator_material
(
self
):
def
update_excavator_material
(
self
):
for
excavator_id
in
dynamic_excavator_set
:
for
excavator_id
in
dynamic_excavator_set
:
load_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator_id
)
.
first
()
.
load_area_id
load_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator_id
,
isdeleted
=
0
,
isauto
=
1
)
.
first
()
.
load_area_id
excavator_material_id
=
session_postgre
.
query
(
DiggingWorkArea
)
.
filter_by
(
Id
=
load_area_id
)
.
first
()
.
Material
excavator_material_id
=
session_postgre
.
query
(
DiggingWorkArea
)
.
filter_by
(
Id
=
load_area_id
)
.
first
()
.
Material
self
.
excavator_material
[
excavator_id
]
=
excavator_material_id
self
.
excavator_material
[
excavator_id
]
=
excavator_material_id
def
update_excavator_priority
(
self
):
def
update_excavator_priority
(
self
):
self
.
excavator_material_priority
=
np
.
ones
(
dynamic_excavator_num
)
for
excavator_id
in
dynamic_excavator_set
:
for
excavator_id
in
dynamic_excavator_set
:
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
excavator_id
)
.
first
()
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
excavator_id
)
.
first
()
self
.
excavator_priority_coefficient
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
item
.
priority
+
1
self
.
excavator_priority_coefficient
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
item
.
priority
+
1
...
@@ -184,10 +187,10 @@ class ExcavatorInfo(WalkManage):
...
@@ -184,10 +187,10 @@ class ExcavatorInfo(WalkManage):
rule
=
rule7
.
rule_weight
rule
=
rule7
.
rule_weight
if
rule
==
3
:
if
rule
==
3
:
if
se
ssion_mysql
.
query
(
Material
)
.
filter_by
(
id
=
self
.
excavator_material
[
excavator_id
])
.
first
()
.
name
==
'土
'
:
if
se
lf
.
excavator_material
[
excavator_id
]
==
'c8092d59-7597-44d7-a731-5a568b46060e
'
:
self
.
excavator_material_priority
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5
self
.
excavator_material_priority
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5
elif
rule
==
1
:
elif
rule
==
1
:
if
se
ssion_mysql
.
query
(
Material
)
.
filter_by
(
id
=
self
.
excavator_material
[
excavator_id
])
.
first
()
.
name
==
'煤
'
:
if
se
lf
.
excavator_material
[
excavator_id
]
==
'c481794b-6ced-45b9-a9c4-c4a388f44418
'
:
self
.
excavator_material_priority
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5
self
.
excavator_material_priority
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5
...
@@ -222,6 +225,7 @@ class ExcavatorInfo(WalkManage):
...
@@ -222,6 +225,7 @@ class ExcavatorInfo(WalkManage):
self
.
update_excavator_material
()
self
.
update_excavator_material
()
# 更新挖机优先级
# 更新挖机优先级
self
.
update_excavator_priority
()
# 挖机目标产量
# 挖机目标产量
self
.
excavator_target_mass
=
np
.
full
(
self
.
excavator_target_mass
=
np
.
full
(
...
...
equipment/truck.py
View file @
bf68c9af
...
@@ -61,14 +61,14 @@ class TruckInfo(WalkManage):
...
@@ -61,14 +61,14 @@ class TruckInfo(WalkManage):
# 矿卡卸点排斥关系
# 矿卡卸点排斥关系
self
.
truck_dump_exclude
=
{}
self
.
truck_dump_exclude
=
{}
# 排斥关系modify
# 排斥关系modify
self
.
excavator_exclude_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
excavator_exclude_modify
=
np
.
full
((
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
# 矿卡优先级
# 矿卡优先级
self
.
truck_priority
=
np
.
ones
(
self
.
dynamic_truck_num
)
self
.
truck_priority
=
np
.
ones
(
self
.
dynamic_truck_num
)
# 矿卡绑定物料
# 矿卡绑定物料
self
.
truck_material_bind
=
{}
self
.
truck_material_bind
=
{}
# 矿卡绑定物料modify
# 矿卡绑定物料modify
self
.
dump_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
self
.
excavator_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
excavator_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
# 引入对象
# 引入对象
self
.
dump
=
DumpInfo
()
self
.
dump
=
DumpInfo
()
self
.
excavator
=
ExcavatorInfo
()
self
.
excavator
=
ExcavatorInfo
()
...
@@ -251,6 +251,7 @@ class TruckInfo(WalkManage):
...
@@ -251,6 +251,7 @@ class TruckInfo(WalkManage):
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")
# self.cur_truck_reach_excavator[i] = last_unload_time + 10 * self.walk_time_to_load_area[start_area_index][
# self.cur_truck_reach_excavator[i] = last_unload_time + 10 * self.walk_time_to_load_area[start_area_index][
# end_area_index]
# end_area_index]
# else:
# else:
...
@@ -336,9 +337,6 @@ class TruckInfo(WalkManage):
...
@@ -336,9 +337,6 @@ class TruckInfo(WalkManage):
elif
item
.
priority
==
3
:
elif
item
.
priority
==
3
:
self
.
truck_priority
[
truck_index
]
=
10
self
.
truck_priority
[
truck_index
]
=
10
logger
.
info
(
"矿卡优先级:"
)
logger
.
info
(
self
.
truck_priority
)
def
update_truck_dump_area_bind
(
self
):
def
update_truck_dump_area_bind
(
self
):
try
:
try
:
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
...
@@ -354,10 +352,6 @@ class TruckInfo(WalkManage):
...
@@ -354,10 +352,6 @@ class TruckInfo(WalkManage):
logger
.
error
(
"矿卡-卸载区域绑定关系读取异常"
)
logger
.
error
(
"矿卡-卸载区域绑定关系读取异常"
)
logger
.
error
(
es
)
logger
.
error
(
es
)
logger
.
info
(
"矿卡-卸载点绑定关系"
)
logger
.
info
(
self
.
truck_dump_bind
)
def
update_truck_excavator_bind
(
self
):
def
update_truck_excavator_bind
(
self
):
try
:
try
:
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
...
@@ -374,9 +368,6 @@ class TruckInfo(WalkManage):
...
@@ -374,9 +368,6 @@ class TruckInfo(WalkManage):
logger
.
error
(
"矿卡-挖机绑定关系读取异常"
)
logger
.
error
(
"矿卡-挖机绑定关系读取异常"
)
logger
.
error
(
es
)
logger
.
error
(
es
)
logger
.
info
(
"矿卡-挖机绑定关系"
)
logger
.
info
(
self
.
truck_excavator_bind
)
def
update_truck_excavator_exclude
(
self
):
def
update_truck_excavator_exclude
(
self
):
self
.
truck_excavator_exclude
=
{}
self
.
truck_excavator_exclude
=
{}
...
@@ -407,10 +398,6 @@ class TruckInfo(WalkManage):
...
@@ -407,10 +398,6 @@ class TruckInfo(WalkManage):
logger
.
error
(
"矿卡-挖机禁止关系读取异常"
)
logger
.
error
(
"矿卡-挖机禁止关系读取异常"
)
logger
.
error
(
es
)
logger
.
error
(
es
)
logger
.
info
(
"矿卡-挖机禁止关系"
)
logger
.
info
(
self
.
truck_excavator_exclude
)
logger
.
info
(
self
.
excavator_exclude_modify
)
def
update_truck_dump_exclude
(
self
):
def
update_truck_dump_exclude
(
self
):
pass
pass
...
@@ -437,9 +424,11 @@ class TruckInfo(WalkManage):
...
@@ -437,9 +424,11 @@ 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)
excavator_material_id
=
self
.
excavator
.
excavator_material
[
excavator_id
]
excavator_material_id
=
self
.
excavator
.
excavator_material
[
excavator_id
]
self
.
truck_material_bind
[
truck_id
]
=
excavator_material_id
self
.
truck_material_bind
[
truck_id
]
=
excavator_material_id
for
truck_id
in
dynamic_truck_set
:
for
truck_id
in
dynamic_truck_set
:
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
...
@@ -460,9 +449,6 @@ class TruckInfo(WalkManage):
...
@@ -460,9 +449,6 @@ class TruckInfo(WalkManage):
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
logger
.
info
(
"矿卡-物料类型"
)
logger
.
info
(
self
.
truck_material_bind
)
def
update_truck_spec
(
self
):
def
update_truck_spec
(
self
):
for
truck_id
in
dynamic_truck_set
:
for
truck_id
in
dynamic_truck_set
:
self
.
size
[
truck_id
]
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
truck_id
)
.
first
()
.
equipment_spec
self
.
size
[
truck_id
]
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
truck_id
)
.
first
()
.
equipment_spec
...
...
path_plan/path_plannner.py
View file @
bf68c9af
...
@@ -53,21 +53,28 @@ class PathPlanner(WalkManage):
...
@@ -53,21 +53,28 @@ class PathPlanner(WalkManage):
weighted_distance
=
weighted_walk_cost
()
weighted_distance
=
weighted_walk_cost
()
# 修正因子
# 修正因子
weight
=
100
00
weight
=
100
# 阻塞成本权重
# 阻塞成本权重
alpha
=
1
*
weight
alpha
=
0
# 距离成本权重
# 距离成本权重
beta
=
1
beta
=
1
session_mysql
.
commit
()
# 距离成本启用
# 距离成本启用
rule1
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
1
)
.
first
()
rule1
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
1
)
.
first
()
if
rule1
.
disabled
==
0
:
if
rule1
.
disabled
==
0
:
alpha
=
alpha
*
rule1
.
rule_weight
beta
=
rule1
.
rule_weight
# 拥堵成本启用
# 拥堵成本启用
rule2
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
2
)
.
first
()
rule2
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
2
)
.
first
()
if
rule2
.
disabled
==
0
:
if
rule2
.
disabled
==
0
:
beta
=
beta
*
rule2
.
rule_weight
alpha
=
rule2
.
rule_weight
beta
/=
beta
alpha
=
alpha
/
beta
*
weight
try
:
try
:
# 备停区处理
# 备停区处理
...
@@ -134,7 +141,7 @@ class PathPlanner(WalkManage):
...
@@ -134,7 +141,7 @@ class PathPlanner(WalkManage):
# 读取路网成本
# 读取路网成本
for
walk_time
in
session_postgre
.
query
(
WalkTime
)
.
all
():
for
walk_time
in
session_postgre
.
query
(
WalkTime
)
.
all
():
# print(str(walk_time.load_area_id),str(walk_time.unload_area_id))
# print(str(walk_time.load_area_id),
str(walk_time.unload_area_id))
# print(walk_time.load_area_name, walk_time.unload_area_name)
# print(walk_time.load_area_name, walk_time.unload_area_name)
load_area_id
,
unload_area_id
=
str
(
walk_time
.
load_area_id
),
str
(
walk_time
.
unload_area_id
)
load_area_id
,
unload_area_id
=
str
(
walk_time
.
load_area_id
),
str
(
walk_time
.
unload_area_id
)
unload_area_index
=
unload_area_uuid_to_index_dict
[
unload_area_id
]
unload_area_index
=
unload_area_uuid_to_index_dict
[
unload_area_id
]
...
@@ -147,7 +154,7 @@ class PathPlanner(WalkManage):
...
@@ -147,7 +154,7 @@ class PathPlanner(WalkManage):
for
walk_time_park
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
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
)]
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
)]
load_area_index
=
load_area_uuid_to_index_dict
[
str
(
walk_time_park
.
load_area_id
)]
_
,
self
.
cost_park_to_load_area
[
park_area_index
][
load_area_index
]
=
\
self
.
cost_park_to_load_area
[
park_area_index
][
load_area_index
],
_
=
\
self
.
path_cost_generate
(
str
(
walk_time_park
.
load_area_id
),
str
(
walk_time_park
.
park_area_id
),
True
)
self
.
path_cost_generate
(
str
(
walk_time_park
.
load_area_id
),
str
(
walk_time_park
.
park_area_id
),
True
)
# except Exception as es:
# except Exception as es:
# logger.error('路网信息计成本计算异常')
# logger.error('路网信息计成本计算异常')
...
@@ -155,15 +162,20 @@ class PathPlanner(WalkManage):
...
@@ -155,15 +162,20 @@ class PathPlanner(WalkManage):
cost_to_excavator
=
np
.
zeros_like
(
self
.
distance_to_excavator
)
cost_to_excavator
=
np
.
zeros_like
(
self
.
distance_to_excavator
)
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
)
# 路网优先级
# 路网优先级
walk_weight
=
weighted_walk_cost
()
walk_weight
,
park_walk_weight
=
weighted_walk_cost
()
walk_weight
=
walk_weight
/
walk_weight
.
min
(
)
# walk_weight = walk_weight - (walk_weight.min() - 1
)
# 路网禁用关系
# 路网禁用关系
walk_available
=
available_walk
()
walk_available
=
available_walk
()
logger
.
info
(
"walk_weight"
,
walk_weight
)
print
(
"path_weight"
,
walk_weight
)
print
(
"walk_avail"
,
walk_available
)
for
i
in
range
(
dynamic_dump_num
):
for
i
in
range
(
dynamic_dump_num
):
for
j
in
range
(
dynamic_excavator_num
):
for
j
in
range
(
dynamic_excavator_num
):
...
@@ -172,19 +184,29 @@ class PathPlanner(WalkManage):
...
@@ -172,19 +184,29 @@ class PathPlanner(WalkManage):
cost_to_excavator
[
i
][
j
]
=
self
.
cost_to_load_area
[
unload_area_index
][
load_area_index
]
/
walk_weight
[
i
][
j
]
cost_to_excavator
[
i
][
j
]
=
self
.
cost_to_load_area
[
unload_area_index
][
load_area_index
]
/
walk_weight
[
i
][
j
]
cost_to_dump
[
i
][
j
]
=
self
.
cost_to_unload_area
[
unload_area_index
][
load_area_index
]
/
walk_weight
[
i
][
j
]
*
walk_available
[
i
][
j
]
cost_to_dump
[
i
][
j
]
=
self
.
cost_to_unload_area
[
unload_area_index
][
load_area_index
]
/
walk_weight
[
i
][
j
]
*
walk_available
[
i
][
j
]
for
j
in
range
(
dynamic_excavator_num
):
load_area_index
=
self
.
excavator_index_to_load_area_index_dict
[
j
]
cost_park_to_excavator
[
0
][
j
]
=
self
.
cost_park_to_load_area
[
0
][
load_area_index
]
/
park_walk_weight
[
0
][
j
]
logger
.
info
(
"真实路网距离-驶往挖机:"
)
logger
.
info
(
"真实路网距离-驶往挖机:"
)
logger
.
info
(
self
.
distance_to_excavator
)
logger
.
info
(
self
.
distance_to_excavator
)
logger
.
info
(
"真实路网距离-驶往卸点:"
)
logger
.
info
(
"真实路网距离-驶往卸点:"
)
logger
.
info
(
self
.
distance_to_dump
)
logger
.
info
(
self
.
distance_to_dump
)
logger
.
info
(
"加权-阻塞路网距离-驶往挖机:"
)
logger
.
info
(
"真实备停区路网距离-驶往挖机:"
)
logger
.
info
(
self
.
distance_park_to_excavator
)
logger
.
info
(
"阻塞路网距离-驶往挖机:"
)
logger
.
info
(
cost_to_excavator
)
logger
.
info
(
cost_to_excavator
)
logger
.
info
(
"
加权-
阻塞路网距离-驶往卸点:"
)
logger
.
info
(
"阻塞路网距离-驶往卸点:"
)
logger
.
info
(
cost_to_dump
)
logger
.
info
(
cost_to_dump
)
return
cost_to_excavator
,
cost_to_dump
,
walk_weight
,
walk_available
logger
.
info
(
"阻塞备停区路网距离-驶往挖机:"
)
logger
.
info
(
cost_park_to_excavator
)
return
cost_to_excavator
,
cost_to_dump
,
walk_weight
,
walk_available
,
cost_park_to_excavator
class
LaneInfo
:
class
LaneInfo
:
...
...
path_plan/priority_control.py
View file @
bf68c9af
...
@@ -23,6 +23,7 @@ def weighted_walk_cost():
...
@@ -23,6 +23,7 @@ def weighted_walk_cost():
excavator_material_priority
=
excavator
.
excavator_material_priority
excavator_material_priority
=
excavator
.
excavator_material_priority
dump_priority
=
dump
.
dump_priority_coefficient
dump_priority
=
dump
.
dump_priority_coefficient
dump_material_priority
=
np
.
ones
(
dynamic_dump_num
)
dump_material_priority
=
np
.
ones
(
dynamic_dump_num
)
park_walk_weight
=
np
.
ones
((
park_num
,
dynamic_excavator_num
))
rule6
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
6
)
.
first
()
rule6
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
6
)
.
first
()
if
not
rule6
.
disabled
:
if
not
rule6
.
disabled
:
...
@@ -32,6 +33,7 @@ def weighted_walk_cost():
...
@@ -32,6 +33,7 @@ def weighted_walk_cost():
excavator_inedx
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
excavator_inedx
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
walk_weight
[
dump_index
][
excavator_inedx
]
+=
dump_priority
[
dump_index
]
*
\
walk_weight
[
dump_index
][
excavator_inedx
]
+=
dump_priority
[
dump_index
]
*
\
excavator_priority
[
excavator_inedx
]
excavator_priority
[
excavator_inedx
]
park_walk_weight
=
park_walk_weight
*
excavator
.
excavator_priority_coefficient
rule7
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
7
)
.
first
()
rule7
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
7
)
.
first
()
if
not
rule7
.
disabled
:
if
not
rule7
.
disabled
:
...
@@ -41,11 +43,16 @@ def weighted_walk_cost():
...
@@ -41,11 +43,16 @@ def weighted_walk_cost():
excavator_inedx
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
excavator_inedx
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
walk_weight
[
dump_index
][
excavator_inedx
]
+=
dump_material_priority
[
dump_index
]
*
\
walk_weight
[
dump_index
][
excavator_inedx
]
+=
dump_material_priority
[
dump_index
]
*
\
excavator_material_priority
[
excavator_inedx
]
excavator_material_priority
[
excavator_inedx
]
park_walk_weight
=
park_walk_weight
*
excavator
.
excavator_material_priority
logger
.
info
(
"路网优先级"
)
#
logger.info("路网优先级")
logger
.
info
(
walk_weight
)
#
logger.info(walk_weight)
return
walk_weight
walk_weight
=
walk_weight
-
(
walk_weight
.
min
()
-
1
)
park_walk_weight
=
park_walk_weight
-
(
park_walk_weight
.
min
()
-
1
)
return
walk_weight
,
park_walk_weight
def
available_walk
():
def
available_walk
():
...
@@ -60,8 +67,8 @@ def available_walk():
...
@@ -60,8 +67,8 @@ def available_walk():
if
excavator
.
excavator_material
[
excavator_id
]
!=
dump
.
dump_material
[
dump_id
]:
if
excavator
.
excavator_material
[
excavator_id
]
!=
dump
.
dump_material
[
dump_id
]:
walk_weight
[
dump_index
][
excavator_inedx
]
+=
1000
walk_weight
[
dump_index
][
excavator_inedx
]
+=
1000
logger
.
info
(
"路网禁用关系"
)
#
logger.info("路网禁用关系")
logger
.
info
(
walk_weight
)
#
logger.info(walk_weight)
return
walk_weight
return
walk_weight
realtime_dispatch.py
View file @
bf68c9af
This diff is collapsed.
Click to expand it.
settings.py
View file @
bf68c9af
...
@@ -28,8 +28,8 @@ import time
...
@@ -28,8 +28,8 @@ import time
log_path
=
"/usr/local/fleet-log/dispatch"
log_path
=
"/usr/local/fleet-log/dispatch"
# 创建日志目录
# 创建日志目录
if
not
os
.
path
.
exists
(
log_path
):
#
if not os.path.exists(log_path):
os
.
mkdir
(
log_path
)
#
os.mkdir(log_path)
# logging初始化工作
# logging初始化工作
logging
.
basicConfig
()
logging
.
basicConfig
()
...
@@ -39,8 +39,8 @@ logger.setLevel(logging.INFO)
...
@@ -39,8 +39,8 @@ logger.setLevel(logging.INFO)
# timefilehandler = logging.handlers.TimedRotatingFileHandler(log_path + "/dispatch.log", when='M', interval=1, backupCount=60)
# timefilehandler = logging.handlers.TimedRotatingFileHandler(log_path + "/dispatch.log", when='M', interval=1, backupCount=60)
filehandler
=
logging
.
handlers
.
RotatingFileHandler
(
log_path
+
"/dispatch.log"
,
maxBytes
=
3
*
1024
*
1024
,
backupCount
=
10
)
#
filehandler = logging.handlers.RotatingFileHandler(log_path + "/dispatch.log", maxBytes=3*1024*1024, backupCount=10)
#
filehandler = logging.handlers.RotatingFileHandler("./Logs/dispatch.log", maxBytes=3 * 1024 * 1024, backupCount=10)
filehandler
=
logging
.
handlers
.
RotatingFileHandler
(
"./Logs/dispatch.log"
,
maxBytes
=
3
*
1024
*
1024
,
backupCount
=
10
)
# 设置后缀名称,跟strftime的格式一样
# 设置后缀名称,跟strftime的格式一样
filehandler
.
suffix
=
"
%
Y-
%
m-
%
d_
%
H-
%
M.log"
filehandler
.
suffix
=
"
%
Y-
%
m-
%
d_
%
H-
%
M.log"
...
...
tables.py
View file @
bf68c9af
...
@@ -390,13 +390,15 @@ class DumpArea(Base):
...
@@ -390,13 +390,15 @@ class DumpArea(Base):
UnloadAbililty
=
Column
(
Float
)
UnloadAbililty
=
Column
(
Float
)
Disabled
=
Column
(
Integer
)
Disabled
=
Column
(
Integer
)
Material
=
Column
(
VARCHAR
(
36
))
Material
=
Column
(
VARCHAR
(
36
))
Priority
=
Column
(
Integer
)
def
__init__
(
self
,
Id
,
BindList
,
UnloadAbililty
,
Disabled
,
Material
):
def
__init__
(
self
,
Id
,
BindList
,
UnloadAbililty
,
Disabled
,
Material
,
Priority
):
self
.
Id
=
Id
self
.
Id
=
Id
self
.
BindList
=
BindList
self
.
BindList
=
BindList
self
.
UnloadAbililty
=
UnloadAbililty
self
.
UnloadAbililty
=
UnloadAbililty
self
.
Disabled
=
Disabled
self
.
Disabled
=
Disabled
self
.
Material
=
Material
self
.
Material
=
Material
self
.
Priority
=
Priority
class
DiggingWorkArea
(
Base
):
class
DiggingWorkArea
(
Base
):
...
@@ -424,7 +426,7 @@ class DispatchRule(Base):
...
@@ -424,7 +426,7 @@ class DispatchRule(Base):
class
Material
(
Base
):
class
Material
(
Base
):
__tablename__
=
'resource_m
ate
rials'
__tablename__
=
'resource_m
eta
rials'
id
=
Column
(
VARCHAR
(
40
),
primary_key
=
True
)
id
=
Column
(
VARCHAR
(
40
),
primary_key
=
True
)
name
=
Column
(
VARCHAR
(
40
))
name
=
Column
(
VARCHAR
(
40
))
...
...
traffic_flow/traffic_flow_info.py
View file @
bf68c9af
...
@@ -7,9 +7,8 @@
...
@@ -7,9 +7,8 @@
# @Software: PyCharm
# @Software: PyCharm
# import
# import
from
path_plan.path_plannner
import
*
from
traffic_flow.traffic_flow_planner
import
*
from
traffic_flow.traffic_flow_planner
import
*
from
path_plan.path_plannner
import
*
from
para_config
import
*
from
para_config
import
*
from
equipment.excavator
import
ExcavatorInfo
from
equipment.excavator
import
ExcavatorInfo
from
equipment.dump
import
DumpInfo
from
equipment.dump
import
DumpInfo
...
@@ -194,6 +193,7 @@ class Traffic_para(WalkManage):
...
@@ -194,6 +193,7 @@ class Traffic_para(WalkManage):
#
#
# if rule == 0:
# if rule == 0:
# if self.excavator.excavator_material[excavator_id] == 'c8092d59-7597-44d7-a731-5a568b46060e':
# if self.excavator.excavator_material[excavator_id] == 'c8092d59-7597-44d7-a731-5a568b46060e':
# print("here111")
# self.excavator_material_priority[self.excavator_uuid_to_index_dict[excavator_id]] = 5
# self.excavator_material_priority[self.excavator_uuid_to_index_dict[excavator_id]] = 5
# elif rule == 2:
# elif rule == 2:
# if self.excavator.excavator_material[excavator_id] == 'c481794b-6ced-45b9-a9c4-c4a388f44418':
# if self.excavator.excavator_material[excavator_id] == 'c481794b-6ced-45b9-a9c4-c4a388f44418':
...
@@ -338,6 +338,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
...
@@ -338,6 +338,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# # 设备优先级
# # 设备优先级
# if not device_priority_use:
# if not device_priority_use:
# print("here1")
# # 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
# # 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
# tra_para.priority_coefficient_goto_dump[i][j] = tra_para.excavator_priority_coefficient[i] \
# tra_para.priority_coefficient_goto_dump[i][j] = tra_para.excavator_priority_coefficient[i] \
# * tra_para.dump_priority_coefficient[j]
# * tra_para.dump_priority_coefficient[j]
...
@@ -347,6 +348,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
...
@@ -347,6 +348,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# * tra_para.dump_priority_coefficient[j]
# * tra_para.dump_priority_coefficient[j]
# # 物料优先级
# # 物料优先级
# if not material_priority_use:
# if not material_priority_use:
# print("here2")
# # # 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
# # # 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
# # tra_para.priority_coefficient_goto_dump[i][j] += tra_para.excavator_material_priority[i] \
# # tra_para.priority_coefficient_goto_dump[i][j] += tra_para.excavator_material_priority[i] \
# # * tra_para.dump_material_priority[j]
# # * tra_para.dump_material_priority[j]
...
@@ -364,10 +366,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
...
@@ -364,10 +366,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# tra_para.walk_time_to_dump[i][j] = \
# tra_para.walk_time_to_dump[i][j] = \
# tra_para.walk_time_to_unload_area[load_area_index][unload_area_index]
# tra_para.walk_time_to_unload_area[load_area_index][unload_area_index]
logger
.
info
(
"priority_coefficient_goto_dump"
)
print
(
"cout"
,
tra_para
.
priority_coefficient_goto_dump
,
tra_para
.
priority_coefficient_goto_excavator
)
logger
.
info
(
tra_para
.
priority_coefficient_goto_dump
)
logger
.
info
(
"priority_coefficient_goto_excavator"
)
logger
.
info
(
tra_para
.
priority_coefficient_goto_excavator
)
# except Exception as es:
# except Exception as es:
# logger.error(es)
# logger.error(es)
...
...
traffic_flow/traffic_flow_planner.py
View file @
bf68c9af
...
@@ -39,7 +39,7 @@ def transportation_problem_slove(coefficient_goto_dump, coefficient_goto_excavat
...
@@ -39,7 +39,7 @@ def transportation_problem_slove(coefficient_goto_dump, coefficient_goto_excavat
if
max_unload_weigh_alg_flag
==
True
:
if
max_unload_weigh_alg_flag
==
True
:
prob
=
pulp
.
LpProblem
(
'Transportation Problem'
,
sense
=
pulp
.
LpMaximize
)
prob
=
pulp
.
LpProblem
(
'Transportation Problem'
,
sense
=
pulp
.
LpMaximize
)
# 得到目标函数,目标函数是使得系统的运输量最大
# 得到目标函数,目标函数是使得系统的运输量最大
prob
+=
(
pulp
.
lpDot
(
flatten
(
var_
y
),
coefficient_goto_excavator
.
flatten
()))
prob
+=
(
pulp
.
lpDot
(
flatten
(
var_
x
),
coefficient_goto_dump
.
flatten
()))
else
:
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_x
*
walk_time_to_excavator
...
@@ -168,7 +168,7 @@ def traffic_flow_plan():
...
@@ -168,7 +168,7 @@ def traffic_flow_plan():
walk_time_to_dump
=
traffic_programme_para
.
walk_time_to_dump
walk_time_to_dump
=
traffic_programme_para
.
walk_time_to_dump
truck_total_num
=
traffic_programme_para
.
truck_total_num
truck_total_num
=
traffic_programme_para
.
truck_total_num
#
print(w_ij, s_ij, b_excavator, b_dump)
print
(
w_ij
,
s_ij
,
b_excavator
,
b_dump
)
res
=
transportation_problem_slove
(
coefficient_goto_dump
,
coefficient_goto_excavator
,
w_ij
,
s_ij
,
b_excavator
,
b_dump
,
res
=
transportation_problem_slove
(
coefficient_goto_dump
,
coefficient_goto_excavator
,
w_ij
,
s_ij
,
b_excavator
,
b_dump
,
grade_loading_array
,
max_unload_weigh_alg_flag
,
truck_total_num
,
grade_loading_array
,
max_unload_weigh_alg_flag
,
truck_total_num
,
...
@@ -184,16 +184,12 @@ def traffic_flow_plan():
...
@@ -184,16 +184,12 @@ def traffic_flow_plan():
print
(
'各变量的取值为:'
)
print
(
'各变量的取值为:'
)
logger
.
info
(
'各变量取值:'
)
logger
.
info
(
'各变量取值:'
)
logger
.
info
(
dynamic_excavator_set
)
logger
.
info
(
dynamic_dump_set
)
print
(
dynamic_excavator_set
)
print
(
dynamic_dump_set
)
print
(
dynamic_dump_set
)
print
(
dynamic_excavator_set
)
print
(
np
.
array
(
res
[
'var_x'
])
.
round
(
3
))
print
(
np
.
array
(
res
[
'var_x'
])
.
round
(
3
))
logger
.
info
(
f
'重运车流:{res["var_x"]} 单位: 吨/时'
)
logger
.
info
(
f
'重运车流:{res["var_x"]} 单位: 吨/时'
)
logger
.
info
(
dynamic_dump_set
)
logger
.
info
(
dynamic_excavator_set
)
print
(
dynamic_dump_set
)
print
(
dynamic_excavator_set
)
print
(
dynamic_excavator_set
)
print
(
dynamic_dump_set
)
print
(
np
.
array
(
res
[
'var_y'
])
.
round
(
3
))
print
(
np
.
array
(
res
[
'var_y'
])
.
round
(
3
))
logger
.
info
(
f
'空运车流:{res["var_y"]} 单位: 吨/时'
)
logger
.
info
(
f
'空运车流:{res["var_y"]} 单位: 吨/时'
)
...
...
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