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
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
222 additions
and
185 deletions
+222
-185
integrated-scheduling.iml
.idea/integrated-scheduling.iml
+1
-0
dump.py
equipment/dump.py
+44
-40
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
+101
-85
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 @@
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$/../WatoDisp-master"
/>
<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=
"sourceFolder"
forTests=
"false"
/>
</component>
...
...
equipment/dump.py
View file @
bf68c9af
...
...
@@ -85,25 +85,25 @@ class DumpInfo(WalkManage):
for
dump_id
in
self
.
dump_uuid_to_index_dict
.
keys
():
ave_unload_time
=
0
unload_count
=
0
try
:
for
query
in
(
session_mysql
.
query
(
JobRecord
.
start_time
,
JobRecord
.
end_time
)
.
join
(
Equipment
,
JobRecord
.
equipment_id
==
Equipment
.
equipment_id
)
.
filter
(
Equipment
.
id
==
dump_id
,
JobRecord
.
end_time
!=
None
)
.
order_by
(
JobRecord
.
start_time
.
desc
())
.
limit
(
10
)
):
ave_unload_time
=
ave_unload_time
+
float
(
(
query
.
end_time
-
query
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
)
)
unload_count
=
unload_count
+
1
self
.
unloading_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
(
ave_unload_time
/
unload_count
)
except
Exception
as
es
:
logger
.
error
(
f
"卸载设备 {dump_id} 卸载时间信息缺失, 已设为默认值(1min)"
)
logger
.
error
(
es
)
#
try:
#
for query in (
#
session_mysql.query(JobRecord.start_time, JobRecord.end_time)
#
.join(Equipment, JobRecord.equipment_id == Equipment.equipment_id)
#
.filter(Equipment.id == dump_id, JobRecord.end_time != None)
#
.order_by(JobRecord.start_time.desc())
#
.limit(10)
#
):
#
ave_unload_time = ave_unload_time + float(
#
(query.end_time - query.start_time)
#
/ timedelta(hours=0, minutes=1, seconds=0)
#
)
#
unload_count = unload_count + 1
#
self.unloading_time[self.dump_uuid_to_index_dict[dump_id]] = (
#
ave_unload_time / unload_count
#
)
#
except Exception as es:
#
logger.error(f"卸载设备 {dump_id} 卸载时间信息缺失, 已设为默认值(1min)")
#
logger.error(es)
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]])
...
...
@@ -114,23 +114,23 @@ class DumpInfo(WalkManage):
now
=
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d"
)
for
dump_id
in
self
.
dump_uuid_to_index_dict
.
keys
():
try
:
for
query
in
(
session_mysql
.
query
(
WorkRecord
)
.
filter
(
WorkRecord
.
equipment_id
==
dump_id
,
WorkRecord
.
work_day
>
now
)
.
first
()
):
self
.
entrance_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
float
(
query
.
load_entrance_time
/
query
.
load_entrance_count
)
self
.
exit_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
float
(
query
.
exit_entrance_time
/
query
.
exit_entrance_count
)
except
Exception
as
es
:
logger
.
error
(
f
"卸载设备 {dump_id} 出入场时间信息缺失, 已设为默认值(1min)"
)
logger
.
error
(
es
)
#
try:
#
for query in (
#
session_mysql.query(WorkRecord)
#
.filter(
#
WorkRecord.equipment_id == dump_id, WorkRecord.work_day > now
#
)
#
.first()
#
):
#
self.entrance_time[self.dump_uuid_to_index_dict[dump_id]] = float(
#
query.load_entrance_time / query.load_entrance_count
#
)
#
self.exit_time[self.dump_uuid_to_index_dict[dump_id]] = float(
#
query.exit_entrance_time / query.exit_entrance_count
#
)
#
except Exception as es:
#
logger.error(f"卸载设备 {dump_id} 出入场时间信息缺失, 已设为默认值(1min)")
#
logger.error(es)
self
.
entrance_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
0.50
self
.
exit_time
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
=
0.50
...
...
@@ -154,15 +154,19 @@ class DumpInfo(WalkManage):
)
def
update_dump_material
(
self
):
self
.
dump_material
=
{}
for
dump_id
in
dynamic_dump_set
:
unload_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
)
.
first
()
.
unload_area_id
unload_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
dump_id
=
dump_id
,
isauto
=
1
,
isdeleted
=
0
)
.
first
()
.
unload_area_id
dump_material_id
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
.
Material
self
.
dump_material
[
dump_id
]
=
dump_material_id
\
self
.
dump_material
[
dump_id
]
=
dump_material_id
def
update_dump_priority
(
self
):
self
.
dump_priority_coefficient
=
np
.
ones
(
self
.
dynamic_dump_num
)
for
dump_id
in
dynamic_dump_set
:
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
dump_id
)
.
first
()
self
.
dump_priority_coefficient
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
item
.
priority
unload_area_index
=
self
.
dump_index_to_unload_area_index_dict
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
unload_area_id
=
unload_area_index_to_uuid_dict
[
unload_area_index
]
item
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
()
self
.
dump_priority_coefficient
[
self
.
dump_uuid_to_index_dict
[
dump_id
]]
+=
item
.
Priority
def
para_period_update
(
self
):
...
...
equipment/excavator.py
View file @
bf68c9af
...
...
@@ -167,11 +167,14 @@ class ExcavatorInfo(WalkManage):
def
update_excavator_material
(
self
):
for
excavator_id
in
dynamic_excavator_set
:
load_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator_id
)
.
first
()
.
load_area_id
load_area_id
=
session_mysql
.
query
(
Dispatch
)
.
filter_by
(
exactor_id
=
excavator_id
,
isdeleted
=
0
,
isauto
=
1
)
.
first
()
.
load_area_id
excavator_material_id
=
session_postgre
.
query
(
DiggingWorkArea
)
.
filter_by
(
Id
=
load_area_id
)
.
first
()
.
Material
self
.
excavator_material
[
excavator_id
]
=
excavator_material_id
def
update_excavator_priority
(
self
):
self
.
excavator_material_priority
=
np
.
ones
(
dynamic_excavator_num
)
for
excavator_id
in
dynamic_excavator_set
:
item
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
excavator_id
)
.
first
()
self
.
excavator_priority_coefficient
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
item
.
priority
+
1
...
...
@@ -184,10 +187,10 @@ class ExcavatorInfo(WalkManage):
rule
=
rule7
.
rule_weight
if
rule
==
3
:
if
se
ssion_mysql
.
query
(
Material
)
.
filter_by
(
id
=
self
.
excavator_material
[
excavator_id
])
.
first
()
.
name
==
'土
'
:
if
se
lf
.
excavator_material
[
excavator_id
]
==
'c8092d59-7597-44d7-a731-5a568b46060e
'
:
self
.
excavator_material_priority
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5
elif
rule
==
1
:
if
se
ssion_mysql
.
query
(
Material
)
.
filter_by
(
id
=
self
.
excavator_material
[
excavator_id
])
.
first
()
.
name
==
'煤
'
:
if
se
lf
.
excavator_material
[
excavator_id
]
==
'c481794b-6ced-45b9-a9c4-c4a388f44418
'
:
self
.
excavator_material_priority
[
self
.
excavator_uuid_to_index_dict
[
excavator_id
]]
=
5
...
...
@@ -222,6 +225,7 @@ class ExcavatorInfo(WalkManage):
self
.
update_excavator_material
()
# 更新挖机优先级
self
.
update_excavator_priority
()
# 挖机目标产量
self
.
excavator_target_mass
=
np
.
full
(
...
...
equipment/truck.py
View file @
bf68c9af
...
...
@@ -61,14 +61,14 @@ class TruckInfo(WalkManage):
# 矿卡卸点排斥关系
self
.
truck_dump_exclude
=
{}
# 排斥关系modify
self
.
excavator_exclude_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
excavator_exclude_modify
=
np
.
full
((
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
# 矿卡优先级
self
.
truck_priority
=
np
.
ones
(
self
.
dynamic_truck_num
)
# 矿卡绑定物料
self
.
truck_material_bind
=
{}
# 矿卡绑定物料modify
self
.
dump_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
excavator_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
self
.
dump_material_bind_modify
=
np
.
full
((
self
.
dynamic_truck_num
,
dynamic_excavator_num
),
0
)
self
.
excavator_material_bind_modify
=
np
.
zeros
(
self
.
dynamic_truck_num
)
# 引入对象
self
.
dump
=
DumpInfo
()
self
.
excavator
=
ExcavatorInfo
()
...
...
@@ -251,6 +251,7 @@ class TruckInfo(WalkManage):
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:
# print("here")
# self.cur_truck_reach_excavator[i] = last_unload_time + 10 * self.walk_time_to_load_area[start_area_index][
# end_area_index]
# else:
...
...
@@ -336,9 +337,6 @@ class TruckInfo(WalkManage):
elif
item
.
priority
==
3
:
self
.
truck_priority
[
truck_index
]
=
10
logger
.
info
(
"矿卡优先级:"
)
logger
.
info
(
self
.
truck_priority
)
def
update_truck_dump_area_bind
(
self
):
try
:
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
...
...
@@ -354,10 +352,6 @@ class TruckInfo(WalkManage):
logger
.
error
(
"矿卡-卸载区域绑定关系读取异常"
)
logger
.
error
(
es
)
logger
.
info
(
"矿卡-卸载点绑定关系"
)
logger
.
info
(
self
.
truck_dump_bind
)
def
update_truck_excavator_bind
(
self
):
try
:
rule5
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
5
)
.
first
()
...
...
@@ -374,9 +368,6 @@ class TruckInfo(WalkManage):
logger
.
error
(
"矿卡-挖机绑定关系读取异常"
)
logger
.
error
(
es
)
logger
.
info
(
"矿卡-挖机绑定关系"
)
logger
.
info
(
self
.
truck_excavator_bind
)
def
update_truck_excavator_exclude
(
self
):
self
.
truck_excavator_exclude
=
{}
...
...
@@ -407,10 +398,6 @@ class TruckInfo(WalkManage):
logger
.
error
(
"矿卡-挖机禁止关系读取异常"
)
logger
.
error
(
es
)
logger
.
info
(
"矿卡-挖机禁止关系"
)
logger
.
info
(
self
.
truck_excavator_exclude
)
logger
.
info
(
self
.
excavator_exclude_modify
)
def
update_truck_dump_exclude
(
self
):
pass
...
...
@@ -437,9 +424,11 @@ class TruckInfo(WalkManage):
if
truck_id
in
self
.
truck_excavator_bind
:
excavator_id
=
self
.
truck_excavator_bind
[
truck_id
]
# print(self.excavator.excavator_material)
excavator_material_id
=
self
.
excavator
.
excavator_material
[
excavator_id
]
self
.
truck_material_bind
[
truck_id
]
=
excavator_material_id
for
truck_id
in
dynamic_truck_set
:
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
...
...
@@ -460,9 +449,6 @@ class TruckInfo(WalkManage):
if
dump_material_id
!=
material
:
self
.
dump_material_bind_modify
[
truck_index
][
dump_index
]
=
1000000
logger
.
info
(
"矿卡-物料类型"
)
logger
.
info
(
self
.
truck_material_bind
)
def
update_truck_spec
(
self
):
for
truck_id
in
dynamic_truck_set
:
self
.
size
[
truck_id
]
=
session_mysql
.
query
(
Equipment
)
.
filter_by
(
id
=
truck_id
)
.
first
()
.
equipment_spec
...
...
path_plan/path_plannner.py
View file @
bf68c9af
...
...
@@ -53,21 +53,28 @@ class PathPlanner(WalkManage):
weighted_distance
=
weighted_walk_cost
()
# 修正因子
weight
=
100
00
weight
=
100
# 阻塞成本权重
alpha
=
1
*
weight
alpha
=
0
# 距离成本权重
beta
=
1
session_mysql
.
commit
()
# 距离成本启用
rule1
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
1
)
.
first
()
if
rule1
.
disabled
==
0
:
alpha
=
alpha
*
rule1
.
rule_weight
beta
=
rule1
.
rule_weight
# 拥堵成本启用
rule2
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
2
)
.
first
()
if
rule2
.
disabled
==
0
:
beta
=
beta
*
rule2
.
rule_weight
alpha
=
rule2
.
rule_weight
beta
/=
beta
alpha
=
alpha
/
beta
*
weight
try
:
# 备停区处理
...
...
@@ -134,7 +141,7 @@ class PathPlanner(WalkManage):
# 读取路网成本
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)
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
]
...
...
@@ -147,7 +154,7 @@ class PathPlanner(WalkManage):
for
walk_time_park
in
session_postgre
.
query
(
WalkTimePark
)
.
all
():
park_area_index
=
park_uuid_to_index_dict
[
str
(
walk_time_park
.
park_area_id
)]
load_area_index
=
load_area_uuid_to_index_dict
[
str
(
walk_time_park
.
load_area_id
)]
_
,
self
.
cost_park_to_load_area
[
park_area_index
][
load_area_index
]
=
\
self
.
cost_park_to_load_area
[
park_area_index
][
load_area_index
],
_
=
\
self
.
path_cost_generate
(
str
(
walk_time_park
.
load_area_id
),
str
(
walk_time_park
.
park_area_id
),
True
)
# except Exception as es:
# logger.error('路网信息计成本计算异常')
...
...
@@ -155,15 +162,20 @@ class PathPlanner(WalkManage):
cost_to_excavator
=
np
.
zeros_like
(
self
.
distance_to_excavator
)
cost_to_dump
=
np
.
zeros_like
(
self
.
distance_to_dump
)
cost_park_to_excavator
=
np
.
zeros_like
(
self
.
distance_park_to_excavator
)
# 路网优先级
walk_weight
=
weighted_walk_cost
()
walk_weight
,
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
()
logger
.
info
(
"walk_weight"
,
walk_weight
)
print
(
"path_weight"
,
walk_weight
)
print
(
"walk_avail"
,
walk_available
)
for
i
in
range
(
dynamic_dump_num
):
for
j
in
range
(
dynamic_excavator_num
):
...
...
@@ -172,19 +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_dump
[
i
][
j
]
=
self
.
cost_to_unload_area
[
unload_area_index
][
load_area_index
]
/
walk_weight
[
i
][
j
]
*
walk_available
[
i
][
j
]
for
j
in
range
(
dynamic_excavator_num
):
load_area_index
=
self
.
excavator_index_to_load_area_index_dict
[
j
]
cost_park_to_excavator
[
0
][
j
]
=
self
.
cost_park_to_load_area
[
0
][
load_area_index
]
/
park_walk_weight
[
0
][
j
]
logger
.
info
(
"真实路网距离-驶往挖机:"
)
logger
.
info
(
self
.
distance_to_excavator
)
logger
.
info
(
"真实路网距离-驶往卸点:"
)
logger
.
info
(
self
.
distance_to_dump
)
logger
.
info
(
"加权-阻塞路网距离-驶往挖机:"
)
logger
.
info
(
"真实备停区路网距离-驶往挖机:"
)
logger
.
info
(
self
.
distance_park_to_excavator
)
logger
.
info
(
"阻塞路网距离-驶往挖机:"
)
logger
.
info
(
cost_to_excavator
)
logger
.
info
(
"
加权-
阻塞路网距离-驶往卸点:"
)
logger
.
info
(
"阻塞路网距离-驶往卸点:"
)
logger
.
info
(
cost_to_dump
)
return
cost_to_excavator
,
cost_to_dump
,
walk_weight
,
walk_available
logger
.
info
(
"阻塞备停区路网距离-驶往挖机:"
)
logger
.
info
(
cost_park_to_excavator
)
return
cost_to_excavator
,
cost_to_dump
,
walk_weight
,
walk_available
,
cost_park_to_excavator
class
LaneInfo
:
...
...
path_plan/priority_control.py
View file @
bf68c9af
...
...
@@ -23,6 +23,7 @@ def weighted_walk_cost():
excavator_material_priority
=
excavator
.
excavator_material_priority
dump_priority
=
dump
.
dump_priority_coefficient
dump_material_priority
=
np
.
ones
(
dynamic_dump_num
)
park_walk_weight
=
np
.
ones
((
park_num
,
dynamic_excavator_num
))
rule6
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
6
)
.
first
()
if
not
rule6
.
disabled
:
...
...
@@ -32,6 +33,7 @@ def weighted_walk_cost():
excavator_inedx
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
walk_weight
[
dump_index
][
excavator_inedx
]
+=
dump_priority
[
dump_index
]
*
\
excavator_priority
[
excavator_inedx
]
park_walk_weight
=
park_walk_weight
*
excavator
.
excavator_priority_coefficient
rule7
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
7
)
.
first
()
if
not
rule7
.
disabled
:
...
...
@@ -41,11 +43,16 @@ def weighted_walk_cost():
excavator_inedx
=
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]
walk_weight
[
dump_index
][
excavator_inedx
]
+=
dump_material_priority
[
dump_index
]
*
\
excavator_material_priority
[
excavator_inedx
]
park_walk_weight
=
park_walk_weight
*
excavator
.
excavator_material_priority
logger
.
info
(
"路网优先级"
)
logger
.
info
(
walk_weight
)
#
logger.info("路网优先级")
#
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
():
...
...
@@ -60,8 +67,8 @@ def available_walk():
if
excavator
.
excavator_material
[
excavator_id
]
!=
dump
.
dump_material
[
dump_id
]:
walk_weight
[
dump_index
][
excavator_inedx
]
+=
1000
logger
.
info
(
"路网禁用关系"
)
logger
.
info
(
walk_weight
)
#
logger.info("路网禁用关系")
#
logger.info(walk_weight)
return
walk_weight
realtime_dispatch.py
View file @
bf68c9af
...
...
@@ -77,6 +77,8 @@ class Dispatcher(WalkManage):
(
self
.
dump
.
get_dump_num
(),
self
.
excavator
.
get_excavator_num
())
)
self
.
path
=
PathPlanner
()
# 更新矿卡预计抵达目的地时间
def
update_truck_reach_time
(
self
):
try
:
...
...
@@ -517,9 +519,13 @@ class Dispatcher(WalkManage):
rule3
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
3
)
.
first
()
.
disabled
rule4
=
session_mysql
.
query
(
DispatchRule
)
.
filter_by
(
id
=
4
)
.
first
()
.
disabled
path
=
PathPlanner
()
# path = PathPlanner()
cost_to_excavator
,
cost_to_dump
,
walk_weight
,
walk_available
,
cost_park_to_excavator
=
self
.
path
.
walk_cost
()
excavator_priority_coefficient
=
self
.
excavator
.
excavator_priority_coefficient
cost_to_excavator
,
cost_to_dump
,
walk_weight
,
walk_available
=
path
.
walk_cost
()
excavator_material_priority
=
self
.
excavator
.
excavator_material_priority
# 矿卡对应序号
truck_index
=
self
.
truck_uuid_to_index_dict
[
truck_id
]
...
...
@@ -533,41 +539,40 @@ class Dispatcher(WalkManage):
excavator_target_mass
=
self
.
excavator
.
get_excavator_target_mass
()
# 挖机装载时间
loading_time
=
self
.
excavator
.
get_loading_time
()
# 卸载设备目标产量
dump_target_mass
=
self
.
dump
.
get_dump_target_mass
()
# 卸载设备卸载时间
unloading_time
=
self
.
dump
.
get_unloading_time
()
#
#
卸载设备目标产量
#
dump_target_mass = self.dump.get_dump_target_mass()
#
#
卸载设备卸载时间
#
unloading_time = self.dump.get_unloading_time()
# 路网信息
walk_time_park_to_excavator
=
walk_manage
.
get_walk_time_park_to_excavator
()
\
*
(
empty_speed
/
float
(
self
.
truck
.
empty_speed
[
truck_id
]))
walk_time_to_dump
=
walk_manage
.
get_walk_time_to_dump
()
*
\
(
heavy_speed
/
self
.
truck
.
heavy_speed
[
truck_id
])
walk_time_to_excavator
=
walk_manage
.
get_walk_time_to_excavator
()
*
\
(
empty_speed
/
float
(
self
.
truck
.
empty_speed
[
truck_id
]))
# 出入场时间
loading_task_time
=
self
.
excavator
.
get_loading_task_time
()
unloading_task_time
=
self
.
dump
.
get_unloading_task_time
()
#
walk_time_to_dump = walk_manage.get_walk_time_to_dump() * \
#
(heavy_speed / self.truck.heavy_speed[truck_id])
#
walk_time_to_excavator = walk_manage.get_walk_time_to_excavator() * \
#
(empty_speed / float(self.truck.empty_speed[truck_id]))
#
#
#
出入场时间
#
loading_task_time = self.excavator.get_loading_task_time()
#
unloading_task_time = self.dump.get_unloading_task_time()
dynamic_dump_num
=
self
.
dump
.
get_dump_num
()
dynamic_excavator_num
=
self
.
excavator
.
get_excavator_num
()
now
=
float
(
(
datetime
.
now
()
-
self
.
start_time
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
)
)
/
timedelta
(
hours
=
0
,
minutes
=
1
,
seconds
=
0
))
# print()
# print("调度矿卡:", truck_id, truck_uuid_to_name_dict[truck_id])
logger
.
info
(
"
"
)
logger
.
info
(
f
"调度矿卡 {truck_id} {truck_uuid_to_name_dict[truck_id]}"
)
logger
.
info
(
"
==========================================================
"
)
logger
.
info
(
f
"调度矿卡 {truck_id}
{truck_index}
{truck_uuid_to_name_dict[truck_id]}"
)
target
=
0
logger
.
info
(
"矿卡-挖机锁定"
)
logger
.
info
(
self
.
truck
.
excavator_material_bind_modify
[
truck_index
])
logger
.
info
(
"矿卡排斥关系"
)
logger
.
info
(
self
.
truck
.
excavator_exclude_modify
[
truck_index
])
#
logger.info("矿卡-挖机锁定")
#
logger.info(self.truck.excavator_material_bind_modify[truck_index])
#
logger.info("矿卡排斥关系")
#
logger.info(self.truck.excavator_exclude_modify[truck_index])
if
task
==
-
2
:
try
:
...
...
@@ -575,42 +580,48 @@ class Dispatcher(WalkManage):
logger
.
info
(
"矿卡行程:无"
)
logger
.
info
(
f
"涉及挖机:{list(self.excavator_uuid_to_index_dict.keys())}"
)
logger
.
info
(
f
"挖机饱和度:{(1 - self.sim_excavator_real_mass / excavator_target_mass)}"
)
f
"挖机饱和度:{(1 - self.sim_excavator_real_mass / excavator_target_mass)}"
)
logger
.
info
(
f
"行程时间:{(np.maximum(self.sim_excavator_ava_time, now + walk_time_park_to_excavator[0, :]) + loading_time - now)}"
)
f
"行程时间:{(np.maximum(self.sim_excavator_ava_time, now + walk_time_park_to_excavator[0, :]) + loading_time - now)}"
)
logger
.
info
(
f
"行驶时间:{walk_time_park_to_excavator[0, :] + loading_time}"
)
logger
.
info
(
"物料类型"
)
if
truck_id
in
self
.
truck
.
truck_material_bind
:
logger
.
info
(
self
.
truck
.
truck_material_bind
[
truck_id
])
logger
.
info
(
"挖机物料优先级"
)
logger
.
info
(
excavator_material_priority
)
logger
.
info
(
"挖机设备优先级"
)
logger
.
info
(
excavator_priority_coefficient
)
except
Exception
as
es
:
logger
.
error
(
f
"矿卡{truck_id}状态不匹配"
)
logger
.
error
(
es
)
if
truck_id
in
self
.
truck
.
truck_excavator_bind
:
target
=
self
.
excavator_uuid_to_index_dict
[
self
.
truck
.
truck_excavator_bind
[
truck_id
]
]
self
.
truck
.
truck_excavator_bind
[
truck_id
]]
else
:
transport_value
=
\
(
10
*
(
1
-
self
.
sim_excavator_real_mass
/
excavator_target_mass
)
/
(
np
.
maximum
(
self
.
sim_excavator_ava_time
,
now
+
walk_time_park_to_excavator
[
0
,
:],
)
+
loading_task_time
-
now
)
)
target
=
np
.
argmax
(
transport_value
=
cost_park_to_excavator
# transport_value = \
# (
# 10
# * (1 - self.sim_excavator_real_mass / excavator_target_mass)
# / (
# np.maximum(
# self.sim_excavator_ava_time,
# now + walk_time_park_to_excavator[0, :] / (excavator_material_priority * excavator_priority_coefficient),
# )
# + loading_task_time
# - now
# )
# )
logger
.
info
(
"transport_value"
)
logger
.
info
(
transport_value
)
target
=
np
.
argmin
(
transport_value
-
self
.
truck
.
excavator_exclude_modify
[
truck_index
]
-
self
.
truck
.
excavator_material_bind_modify
[
truck_index
]
)
-
self
.
truck
.
excavator_material_bind_modify
[
truck_index
])
# target = np.argmin((walk_time_park_to_excavator[0, :] + loading_time))
...
...
@@ -641,26 +652,22 @@ class Dispatcher(WalkManage):
try
:
assert
np
.
array
(
self
.
actual_goto_dump_traffic_flow
)
.
shape
==
(
dynamic_excavator_num
,
dynamic_dump_num
,
)
dynamic_dump_num
,)
assert
np
.
array
(
self
.
opt_goto_dump_traffic_flow
)
.
shape
==
(
dynamic_excavator_num
,
dynamic_dump_num
,
)
dynamic_dump_num
,)
except
Exception
as
es
:
logger
.
warning
(
es
)
self
.
actual_goto_dump_traffic_flow
=
np
.
array
(
self
.
actual_goto_dump_traffic_flow
)
.
reshape
((
dynamic_excavator_num
,
dynamic_dump_num
))
self
.
actual_goto_dump_traffic_flow
)
.
reshape
((
dynamic_excavator_num
,
dynamic_dump_num
))
self
.
opt_goto_dump_traffic_flow
=
np
.
array
(
self
.
opt_goto_dump_traffic_flow
)
.
reshape
((
dynamic_excavator_num
,
dynamic_dump_num
))
self
.
opt_goto_dump_traffic_flow
)
.
reshape
((
dynamic_excavator_num
,
dynamic_dump_num
))
self
.
actual_goto_dump_traffic_flow
=
np
.
array
(
self
.
actual_goto_dump_traffic_flow
)
self
.
actual_goto_dump_traffic_flow
=
np
.
array
(
self
.
actual_goto_dump_traffic_flow
)
self
.
opt_goto_dump_traffic_flow
=
np
.
array
(
self
.
opt_goto_dump_traffic_flow
)
try
:
logger
.
info
(
"挖机id:"
)
logger
.
info
(
self
.
excavator_uuid_to_index_dict
)
logger
.
info
(
"卸点id:"
)
...
...
@@ -674,9 +681,18 @@ class Dispatcher(WalkManage):
logger
.
info
(
self
.
actual_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:])
logger
.
info
(
"卸载点理想车流"
)
logger
.
info
(
self
.
opt_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:])
logger
.
info
(
"物料类型"
)
if
truck_id
in
self
.
truck
.
truck_material_bind
:
logger
.
info
(
self
.
truck
.
truck_material_bind
[
truck_id
])
logger
.
info
(
"驶往卸点的运输成本"
)
logger
.
info
(
cost_to_dump
)
logger
.
info
(
"卸点物料修正"
)
logger
.
info
(
self
.
truck
.
dump_material_bind_modify
)
except
Exception
as
es
:
logger
.
info
(
"车流及修正因子"
)
logger
.
info
(
es
)
if
truck_id
in
self
.
truck
.
truck_dump_bind
:
bind_unload_area_id
=
self
.
truck
.
truck_dump_bind
[
truck_id
]
...
...
@@ -686,31 +702,28 @@ class Dispatcher(WalkManage):
break
else
:
if
rule3
and
rule4
:
transport_value
=
(
cost_to_excavator
/
walk_weight
*
walk_available
)[:,
int
(
trip
[
1
])]
logger
.
info
(
"不含车流规划:"
)
logger
.
info
(
transport_value
)
# transport_value = (cost_to_dump / walk_weight * walk_available)[:, int(trip[1])]
transport_value
=
cost_to_dump
[:,
int
(
trip
[
1
])]
else
:
transport_value
=
\
(
self
.
actual_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
)
\
/
(
self
.
opt_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
)
logger
.
info
(
"transport_value"
)
logger
.
info
(
transport_value
)
target
=
np
.
argmin
(
transport_value
+
self
.
truck
.
excavator_exclude_modify
[
truck_index
]
+
self
.
truck
.
excavator_material_bind_modify
[
truck_index
]
)
+
self
.
truck
.
dump_material_bind_modify
[
truck_index
])
logger
.
info
(
"车流比:"
)
logger
.
info
(
(
self
.
actual_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
)
/
(
self
.
opt_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
)
)
/
(
self
.
opt_goto_dump_traffic_flow
[
int
(
trip
[
1
]),
:]
+
0.001
))
logger
.
info
(
f
"目的地:{self.dump_index_to_uuid_dict[target]}"
)
elif
task
in
[
3
,
4
,
5
]:
try
:
logger
.
info
(
"矿卡状态:矿卡重载"
)
# logger.info(f'矿卡行程:{self.excavator_index_to_uuid_dict[trip[0]]}-{self.dump_index_to_uuid_dict[trip[1]]}')
logger
.
info
(
f
"涉及挖机设备:{list(self.excavator_uuid_to_index_dict.keys())}"
)
...
...
@@ -732,29 +745,21 @@ class Dispatcher(WalkManage):
try
:
assert
np
.
array
(
self
.
actual_goto_excavator_traffic_flow
)
.
shape
==
(
dynamic_excavator_num
,
dynamic_dump_num
,
)
dynamic_dump_num
,)
assert
np
.
array
(
self
.
opt_goto_excavator_traffic_flow
)
.
shape
==
(
dynamic_excavator_num
,
dynamic_dump_num
,
)
dynamic_dump_num
,)
except
Exception
as
es
:
logger
.
warning
(
es
)
self
.
actual_goto_excavator_traffic_flow
=
np
.
array
(
self
.
actual_goto_excavator_traffic_flow
)
.
reshape
((
dynamic_dump_num
,
dynamic_excavator_num
))
self
.
actual_goto_excavator_traffic_flow
)
.
reshape
((
dynamic_dump_num
,
dynamic_excavator_num
))
self
.
opt_goto_excavator_traffic_flow
=
np
.
array
(
self
.
opt_goto_excavator_traffic_flow
)
.
reshape
((
dynamic_dump_num
,
dynamic_excavator_num
))
self
.
opt_goto_excavator_traffic_flow
)
.
reshape
((
dynamic_dump_num
,
dynamic_excavator_num
))
# 不知道为什么,偶尔变成了list
self
.
actual_goto_excavator_traffic_flow
=
np
.
array
(
self
.
actual_goto_excavator_traffic_flow
)
self
.
opt_goto_excavator_traffic_flow
=
np
.
array
(
self
.
opt_goto_excavator_traffic_flow
)
self
.
actual_goto_excavator_traffic_flow
=
np
.
array
(
self
.
actual_goto_excavator_traffic_flow
)
self
.
opt_goto_excavator_traffic_flow
=
np
.
array
(
self
.
opt_goto_excavator_traffic_flow
)
try
:
logger
.
info
(
"挖机id:"
)
logger
.
info
(
self
.
excavator_uuid_to_index_dict
)
logger
.
info
(
"卸点id:"
)
...
...
@@ -771,18 +776,28 @@ class Dispatcher(WalkManage):
logger
.
info
(
"物料类型"
)
if
truck_id
in
self
.
truck
.
truck_material_bind
:
logger
.
info
(
self
.
truck
.
truck_material_bind
[
truck_id
])
logger
.
info
(
"驶往挖机的运输成本"
)
logger
.
info
(
cost_to_excavator
)
logger
.
info
(
"挖机物料修正"
)
logger
.
info
(
self
.
truck
.
excavator_material_bind_modify
)
logger
.
info
(
"挖机优先级修正"
)
logger
.
info
(
self
.
excavator
.
excavator_priority_coefficient
)
except
Exception
as
es
:
logger
.
info
(
"车流及修正因子"
)
logger
.
info
(
es
)
if
truck_id
in
self
.
truck
.
truck_excavator_bind
:
target
=
self
.
excavator_uuid_to_index_dict
[
self
.
truck
.
truck_excavator_bind
[
truck_id
]
]
target
=
self
.
excavator_uuid_to_index_dict
[
self
.
truck
.
truck_excavator_bind
[
truck_id
]]
else
:
if
rule3
and
rule4
:
transport_value
=
(
cost_to_excavator
/
walk_weight
*
walk_available
)[
int
(
trip
[
1
]),
:]
# transport_value = (cost_to_excavator / walk_weight * walk_available)[int(trip[1]), :]
transport_value
=
cost_to_excavator
[
int
(
trip
[
1
]),
:]
else
:
transport_value
=
\
(
self
.
actual_goto_excavator_traffic_flow
[
trip
[
1
],
:]
+
0.001
)
\
/
(
self
.
opt_goto_excavator_traffic_flow
[
trip
[
1
],
:]
+
0.001
)
logger
.
info
(
"transport_value"
)
logger
.
info
(
transport_value
)
target
=
np
.
argmin
(
transport_value
...
...
@@ -793,11 +808,12 @@ class Dispatcher(WalkManage):
logger
.
info
(
"车流比:"
)
logger
.
info
(
(
self
.
actual_goto_excavator_traffic_flow
[
trip
[
1
],
:]
+
0.001
)
/
(
self
.
opt_goto_excavator_traffic_flow
[
trip
[
1
],
:]
+
0.001
)
)
/
(
self
.
opt_goto_excavator_traffic_flow
[
trip
[
1
],
:]
+
0.001
))
logger
.
info
(
f
"目的地:{self.excavator_index_to_uuid_dict[target]}"
)
logger
.
info
(
"=========================================================="
)
return
target
def
schedule_construct
(
self
):
...
...
settings.py
View file @
bf68c9af
...
...
@@ -28,8 +28,8 @@ import time
log_path
=
"/usr/local/fleet-log/dispatch"
# 创建日志目录
if
not
os
.
path
.
exists
(
log_path
):
os
.
mkdir
(
log_path
)
#
if not os.path.exists(log_path):
#
os.mkdir(log_path)
# logging初始化工作
logging
.
basicConfig
()
...
...
@@ -39,8 +39,8 @@ logger.setLevel(logging.INFO)
# timefilehandler = logging.handlers.TimedRotatingFileHandler(log_path + "/dispatch.log", when='M', interval=1, backupCount=60)
filehandler
=
logging
.
handlers
.
RotatingFileHandler
(
log_path
+
"/dispatch.log"
,
maxBytes
=
3
*
1024
*
1024
,
backupCount
=
10
)
#
filehandler = logging.handlers.RotatingFileHandler("./Logs/dispatch.log", maxBytes=3 * 1024 * 1024, backupCount=10)
#
filehandler = logging.handlers.RotatingFileHandler(log_path + "/dispatch.log", maxBytes=3*1024*1024, backupCount=10)
filehandler
=
logging
.
handlers
.
RotatingFileHandler
(
"./Logs/dispatch.log"
,
maxBytes
=
3
*
1024
*
1024
,
backupCount
=
10
)
# 设置后缀名称,跟strftime的格式一样
filehandler
.
suffix
=
"
%
Y-
%
m-
%
d_
%
H-
%
M.log"
...
...
tables.py
View file @
bf68c9af
...
...
@@ -390,13 +390,15 @@ class DumpArea(Base):
UnloadAbililty
=
Column
(
Float
)
Disabled
=
Column
(
Integer
)
Material
=
Column
(
VARCHAR
(
36
))
Priority
=
Column
(
Integer
)
def
__init__
(
self
,
Id
,
BindList
,
UnloadAbililty
,
Disabled
,
Material
):
def
__init__
(
self
,
Id
,
BindList
,
UnloadAbililty
,
Disabled
,
Material
,
Priority
):
self
.
Id
=
Id
self
.
BindList
=
BindList
self
.
UnloadAbililty
=
UnloadAbililty
self
.
Disabled
=
Disabled
self
.
Material
=
Material
self
.
Priority
=
Priority
class
DiggingWorkArea
(
Base
):
...
...
@@ -424,7 +426,7 @@ class DispatchRule(Base):
class
Material
(
Base
):
__tablename__
=
'resource_m
ate
rials'
__tablename__
=
'resource_m
eta
rials'
id
=
Column
(
VARCHAR
(
40
),
primary_key
=
True
)
name
=
Column
(
VARCHAR
(
40
))
...
...
traffic_flow/traffic_flow_info.py
View file @
bf68c9af
...
...
@@ -7,9 +7,8 @@
# @Software: PyCharm
# import
from
path_plan.path_plannner
import
*
from
traffic_flow.traffic_flow_planner
import
*
from
path_plan.path_plannner
import
*
from
para_config
import
*
from
equipment.excavator
import
ExcavatorInfo
from
equipment.dump
import
DumpInfo
...
...
@@ -194,6 +193,7 @@ class Traffic_para(WalkManage):
#
# if rule == 0:
# if self.excavator.excavator_material[excavator_id] == 'c8092d59-7597-44d7-a731-5a568b46060e':
# print("here111")
# self.excavator_material_priority[self.excavator_uuid_to_index_dict[excavator_id]] = 5
# elif rule == 2:
# if self.excavator.excavator_material[excavator_id] == 'c481794b-6ced-45b9-a9c4-c4a388f44418':
...
...
@@ -338,6 +338,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# # 设备优先级
# if not device_priority_use:
# print("here1")
# # 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
# tra_para.priority_coefficient_goto_dump[i][j] = tra_para.excavator_priority_coefficient[i] \
# * tra_para.dump_priority_coefficient[j]
...
...
@@ -347,6 +348,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# * tra_para.dump_priority_coefficient[j]
# # 物料优先级
# if not material_priority_use:
# print("here2")
# # # 每条卸载道路的优先级,等于电铲的优先级乘以卸载点的优先级
# # tra_para.priority_coefficient_goto_dump[i][j] += tra_para.excavator_material_priority[i] \
# # * tra_para.dump_material_priority[j]
...
...
@@ -364,10 +366,7 @@ def Traffic_para_init(num_of_load_area, num_of_unload_area, num_of_excavator, nu
# tra_para.walk_time_to_dump[i][j] = \
# tra_para.walk_time_to_unload_area[load_area_index][unload_area_index]
logger
.
info
(
"priority_coefficient_goto_dump"
)
logger
.
info
(
tra_para
.
priority_coefficient_goto_dump
)
logger
.
info
(
"priority_coefficient_goto_excavator"
)
logger
.
info
(
tra_para
.
priority_coefficient_goto_excavator
)
print
(
"cout"
,
tra_para
.
priority_coefficient_goto_dump
,
tra_para
.
priority_coefficient_goto_excavator
)
# except Exception as es:
# logger.error(es)
...
...
traffic_flow/traffic_flow_planner.py
View file @
bf68c9af
...
...
@@ -39,7 +39,7 @@ def transportation_problem_slove(coefficient_goto_dump, coefficient_goto_excavat
if
max_unload_weigh_alg_flag
==
True
:
prob
=
pulp
.
LpProblem
(
'Transportation Problem'
,
sense
=
pulp
.
LpMaximize
)
# 得到目标函数,目标函数是使得系统的运输量最大
prob
+=
(
pulp
.
lpDot
(
flatten
(
var_
y
),
coefficient_goto_excavator
.
flatten
()))
prob
+=
(
pulp
.
lpDot
(
flatten
(
var_
x
),
coefficient_goto_dump
.
flatten
()))
else
:
prob
=
pulp
.
LpProblem
(
'Transportation Problem'
,
sense
=
pulp
.
LpMinimize
)
goto_excavator_cost
=
var_x
*
walk_time_to_excavator
...
...
@@ -168,7 +168,7 @@ def traffic_flow_plan():
walk_time_to_dump
=
traffic_programme_para
.
walk_time_to_dump
truck_total_num
=
traffic_programme_para
.
truck_total_num
#
print(w_ij, s_ij, b_excavator, b_dump)
print
(
w_ij
,
s_ij
,
b_excavator
,
b_dump
)
res
=
transportation_problem_slove
(
coefficient_goto_dump
,
coefficient_goto_excavator
,
w_ij
,
s_ij
,
b_excavator
,
b_dump
,
grade_loading_array
,
max_unload_weigh_alg_flag
,
truck_total_num
,
...
...
@@ -184,16 +184,12 @@ def traffic_flow_plan():
print
(
'各变量的取值为:'
)
logger
.
info
(
'各变量取值:'
)
logger
.
info
(
dynamic_excavator_set
)
logger
.
info
(
dynamic_dump_set
)
print
(
dynamic_excavator_set
)
print
(
dynamic_dump_set
)
print
(
dynamic_excavator_set
)
print
(
np
.
array
(
res
[
'var_x'
])
.
round
(
3
))
logger
.
info
(
f
'重运车流:{res["var_x"]} 单位: 吨/时'
)
logger
.
info
(
dynamic_dump_set
)
logger
.
info
(
dynamic_excavator_set
)
print
(
dynamic_dump_set
)
print
(
dynamic_excavator_set
)
print
(
dynamic_dump_set
)
print
(
np
.
array
(
res
[
'var_y'
])
.
round
(
3
))
logger
.
info
(
f
'空运车流:{res["var_y"]} 单位: 吨/时'
)
...
...
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