Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
integrated-scheduling-v3
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
1
Merge Requests
1
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-v3
Commits
4cca50a5
Commit
4cca50a5
authored
Sep 15, 2022
by
张晓彤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
二次调度问题修复
parent
7856246e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
10 deletions
+64
-10
algorithm.py
alg/algorithm.py
+3
-3
dispatcher.py
core/dispatcher.py
+1
-0
group.py
core/group.py
+0
-0
schedule.py
core/schedule.py
+7
-5
util.py
core/util.py
+34
-0
truck.py
equipment/truck.py
+1
-1
topo_graph.py
graph/topo_graph.py
+18
-1
No files found.
alg/algorithm.py
View file @
4cca50a5
...
@@ -190,7 +190,7 @@ class ExpectedTime(AlgorithmBase):
...
@@ -190,7 +190,7 @@ class ExpectedTime(AlgorithmBase):
# 挖机可用时间
# 挖机可用时间
excavator_val_time_global
=
self
.
pre_sch
.
get_excavator_avl_time
()
excavator_val_time_global
=
self
.
pre_sch
.
get_excavator_avl_time
()
excavator_val_time
=
np
.
full
(
len
(
self
.
group
.
excavator
),
0
)
excavator_val_time
=
np
.
full
(
len
(
self
.
group
.
excavator
),
0
.0
)
for
excavator_id
,
excavator_index
in
self
.
group
.
excavator_uuid_index_dict
.
items
():
for
excavator_id
,
excavator_index
in
self
.
group
.
excavator_uuid_index_dict
.
items
():
excavator_val_time
[
excavator_index
]
=
excavator_val_time_global
[
excavator_id
]
excavator_val_time
[
excavator_index
]
=
excavator_val_time_global
[
excavator_id
]
...
@@ -222,7 +222,7 @@ class ExpectedTime(AlgorithmBase):
...
@@ -222,7 +222,7 @@ class ExpectedTime(AlgorithmBase):
# self.logger.error(es)
# self.logger.error(es)
# transport_value = np.zeros(group_dynamic_excavator_num)
# transport_value = np.zeros(group_dynamic_excavator_num)
if
task
in
[
0
,
1
,
2
]:
if
task
in
[
1
,
2
]:
################################################ 矿卡空载 ###############################################
################################################ 矿卡空载 ###############################################
try
:
try
:
...
@@ -276,7 +276,7 @@ class ExpectedTime(AlgorithmBase):
...
@@ -276,7 +276,7 @@ class ExpectedTime(AlgorithmBase):
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
transport_value
=
np
.
zeros
(
group_dynamic_unload_area_num
)
transport_value
=
np
.
zeros
(
group_dynamic_unload_area_num
)
elif
task
in
[
3
,
4
,
5
]:
elif
task
in
[
4
,
5
]:
################################################ 矿卡重载 ###############################################
################################################ 矿卡重载 ###############################################
try
:
try
:
...
...
core/dispatcher.py
View file @
4cca50a5
...
@@ -89,6 +89,7 @@ class Dispatcher:
...
@@ -89,6 +89,7 @@ class Dispatcher:
self
.
logger
.
error
(
f
'分组{group.group_id} 调度异常'
)
self
.
logger
.
error
(
f
'分组{group.group_id} 调度异常'
)
self
.
logger
.
info
(
f
'调度分组: {group.group_id} {DispatchInfo.group_name[group.group_id]}'
)
self
.
logger
.
info
(
f
'调度分组: {group.group_id} {DispatchInfo.group_name[group.group_id]}'
)
self
.
logger
.
info
(
f
'组内车辆 {group.truck_set}'
)
self
.
logger
.
info
(
"组内挖机"
)
self
.
logger
.
info
(
"组内挖机"
)
self
.
logger
.
info
(
group
.
excavator
)
self
.
logger
.
info
(
group
.
excavator
)
self
.
logger
.
info
(
"组内卸点"
)
self
.
logger
.
info
(
"组内卸点"
)
...
...
core/group.py
View file @
4cca50a5
This diff is collapsed.
Click to expand it.
core/schedule.py
View file @
4cca50a5
...
@@ -50,7 +50,7 @@ class PreSchedule:
...
@@ -50,7 +50,7 @@ class PreSchedule:
self
.
logger
=
get_logger
(
"zxt.pre_schedule"
)
self
.
logger
=
get_logger
(
"zxt.pre_schedule"
)
def
update_truck_reach_time
(
self
):
def
update_truck_reach_time
(
self
,
truck_id
=
None
):
"""
"""
更新矿卡预计抵达目的地时间
更新矿卡预计抵达目的地时间
:return:
:return:
...
@@ -75,6 +75,8 @@ class PreSchedule:
...
@@ -75,6 +75,8 @@ class PreSchedule:
# self.logger.info("update_truck_reach_time-trucks")
# self.logger.info("update_truck_reach_time-trucks")
# self.logger.info(trucks)
# self.logger.info(trucks)
for
i
in
range
(
trucks
):
for
i
in
range
(
trucks
):
if
truck_id
is
not
None
and
i
==
self
.
truck
.
truck_uuid_to_index_dict
[
truck_id
]:
continue
task
=
truck_current_task
[
self
.
truck
.
truck_index_to_uuid_dict
[
i
]]
task
=
truck_current_task
[
self
.
truck
.
truck_index_to_uuid_dict
[
i
]]
end_area_index
=
truck_current_trip
[
i
][
1
]
end_area_index
=
truck_current_trip
[
i
][
1
]
if
end_area_index
==
-
1
:
if
end_area_index
==
-
1
:
...
@@ -133,8 +135,6 @@ class PreSchedule:
...
@@ -133,8 +135,6 @@ class PreSchedule:
)
)
for
reach_ls
in
excavator_avl_ls
:
for
reach_ls
in
excavator_avl_ls
:
self
.
logger
.
info
(
"update_excavator_avl_time-excavator_avl_ls"
)
self
.
logger
.
info
(
excavator_avl_ls
)
if
len
(
reach_ls
)
!=
0
:
if
len
(
reach_ls
)
!=
0
:
reach_ls
=
np
.
array
(
reach_ls
)
reach_ls
=
np
.
array
(
reach_ls
)
tmp
=
reach_ls
[
np
.
lexsort
(
reach_ls
[:,
::
-
1
]
.
T
)]
tmp
=
reach_ls
[
np
.
lexsort
(
reach_ls
[:,
::
-
1
]
.
T
)]
...
@@ -183,6 +183,8 @@ class PreSchedule:
...
@@ -183,6 +183,8 @@ class PreSchedule:
# self.truck_avl_time[int(tmp[i][1])] = now
# self.truck_avl_time[int(tmp[i][1])] = now
# if abs(self.excavator_avl_time[excavator_index] - now) > 60:
# if abs(self.excavator_avl_time[excavator_index] - now) > 60:
# self.excavator_avl_time[excavator_index] = now
# self.excavator_avl_time[excavator_index] = now
self
.
logger
.
info
(
"update_excavator_avl_time-excavator_avl_ls"
)
self
.
logger
.
info
(
excavator_avl_ls
)
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
"挖机可用时间计算异常"
)
self
.
logger
.
error
(
"挖机可用时间计算异常"
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
...
@@ -279,7 +281,7 @@ class PreSchedule:
...
@@ -279,7 +281,7 @@ class PreSchedule:
dump_avl_time
=
self
.
update_dump_avl_time
(
dump_avl_ls
)
dump_avl_time
=
self
.
update_dump_avl_time
(
dump_avl_ls
)
return
dump_avl_time
return
dump_avl_time
def
get_excavator_avl_time
(
self
,
excavator_id
=
None
):
def
get_excavator_avl_time
(
self
,
excavator_id
=
None
,
truck_id
=
None
):
"""
"""
获取挖机最早可用时间
获取挖机最早可用时间
:param excavator_id: 挖机编号uuid
:param excavator_id: 挖机编号uuid
...
@@ -287,7 +289,7 @@ class PreSchedule:
...
@@ -287,7 +289,7 @@ class PreSchedule:
excavator_avl_time: (array) 各挖机完成所有已分配矿卡装载的时间
excavator_avl_time: (array) 各挖机完成所有已分配矿卡装载的时间
"""
"""
self
.
_reset
()
self
.
_reset
()
excavator_avl_ls
,
dump_avl_ls
=
self
.
update_truck_reach_time
()
excavator_avl_ls
,
dump_avl_ls
=
self
.
update_truck_reach_time
(
truck_id
=
truck_id
)
if
excavator_id
is
not
None
:
if
excavator_id
is
not
None
:
return
self
.
update_excavator_avl_time
(
excavator_avl_ls
)
\
return
self
.
update_excavator_avl_time
(
excavator_avl_ls
)
\
[
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]]
[
self
.
excavator
.
excavator_uuid_to_index_dict
[
excavator_id
]]
...
...
core/util.py
View file @
4cca50a5
...
@@ -40,6 +40,40 @@ with open(json_file) as f:
...
@@ -40,6 +40,40 @@ with open(json_file) as f:
#
#
# return POST(real_data)
# return POST(real_data)
def
get_cross_next_lanes
(
truck_locate
):
next_lane_list
=
[]
startNodeId
=
session_postgre
.
query
(
Lane
)
.
filter_by
(
Id
=
truck_locate
)
.
first
()
.
EndNodeId
for
item
in
session_postgre
.
query
(
Lane
)
.
filter_by
(
StartNodeId
=
startNodeId
)
.
all
():
next_lane_list
.
append
(
str
(
item
.
Id
))
return
next_lane_list
def
delete_congestion_load_area
(
congestion_lane_dict
,
load_area_dict
,
next_lane_load_area_dict
):
"""
:param congestion_lane_dict: 拥堵路段
:param load_area_dict: 拓扑图规划得到的可达装载区
:param next_lane_load_area_dict: 路段可达的装载区
:return:
"""
for
lane_id
in
next_lane_load_area_dict
:
# 下一装载区路段
if
lane_id
in
congestion_lane_dict
:
#
for
load_area
in
next_lane_load_area_dict
[
lane_id
]:
if
load_area
in
load_area_dict
:
del
load_area_dict
[
load_area
]
def
get_lane_reach_load_areas
(
load_area_lane_dict
,
next_lane_list
):
next_lane_load_area_dict
=
{}
for
lane_id
in
next_lane_list
:
for
key
,
value
in
load_area_lane_dict
.
items
():
if
lane_id
in
value
:
if
lane_id
not
in
next_lane_load_area_dict
:
next_lane_load_area_dict
[
lane_id
]
=
[
key
]
else
:
next_lane_load_area_dict
[
lane_id
]
.
append
(
key
)
return
next_lane_load_area_dict
def
POST
(
truck_id
):
def
POST
(
truck_id
):
"""
"""
...
...
equipment/truck.py
View file @
4cca50a5
...
@@ -212,9 +212,9 @@ class TruckInfo(WalkManage):
...
@@ -212,9 +212,9 @@ class TruckInfo(WalkManage):
if
truck_name_to_uuid_dict
[
item
]
in
self
.
dynamic_truck_set
:
if
truck_name_to_uuid_dict
[
item
]
in
self
.
dynamic_truck_set
:
try
:
try
:
isTemp
=
key_value_dict
[
"isTemp"
]
isTemp
=
key_value_dict
[
"isTemp"
]
print
(
isTemp
)
self
.
truck_is_temp
[
truck_name_to_uuid_dict
[
item
]]
=
bool
(
isTemp
)
self
.
truck_is_temp
[
truck_name_to_uuid_dict
[
item
]]
=
bool
(
isTemp
)
except
Exception
as
es
:
except
Exception
as
es
:
self
.
logger
.
error
(
item
)
self
.
logger
.
error
(
es
)
self
.
logger
.
error
(
es
)
self
.
truck_is_temp
[
truck_name_to_uuid_dict
[
item
]]
=
True
self
.
truck_is_temp
[
truck_name_to_uuid_dict
[
item
]]
=
True
...
...
graph/topo_graph.py
View file @
4cca50a5
...
@@ -343,6 +343,8 @@ class Topo():
...
@@ -343,6 +343,8 @@ class Topo():
if
not
len
(
target_list
):
if
not
len
(
target_list
):
self
.
logger
.
error
(
"当前无可去卸载区!"
)
self
.
logger
.
error
(
"当前无可去卸载区!"
)
unload_area_lane_dict
=
{}
path_length_map
=
{}
path_length_map
=
{}
# build the path_length_map from source node
# build the path_length_map from source node
...
@@ -350,6 +352,12 @@ class Topo():
...
@@ -350,6 +352,12 @@ class Topo():
try
:
try
:
distance
,
path
=
nx
.
single_source_dijkstra
(
self
.
unload_G
,
source
=
source_node
,
target
=
i
,
distance
,
path
=
nx
.
single_source_dijkstra
(
self
.
unload_G
,
source
=
source_node
,
target
=
i
,
weight
=
"real_distance"
)
weight
=
"real_distance"
)
unload_area_id
=
session_postgre
.
query
(
DumpArea
)
.
filter_by
(
Id
=
unload_area_id
)
.
first
(
EntranceNodeId
=
i
)
.
first
()
.
Id
unload_area_lane_dict
[
str
(
unload_area_id
)]
=
[]
for
j
in
range
(
len
(
path
)
-
1
):
unload_area_lane_dict
[
str
(
unload_area_id
)]
+=
self
.
load_G
[
path
[
j
]][
path
[
j
+
1
]][
'lane'
]
path_length_map
[
distance
]
=
path
path_length_map
[
distance
]
=
path
# print(path)
# print(path)
except
Exception
as
es
:
except
Exception
as
es
:
...
@@ -446,6 +454,9 @@ class Topo():
...
@@ -446,6 +454,9 @@ class Topo():
if
not
len
(
target_list
):
if
not
len
(
target_list
):
self
.
logger
.
error
(
"当前无可去装载区!"
)
self
.
logger
.
error
(
"当前无可去装载区!"
)
load_area_lane_dict
=
{}
# print(target_list)
# print(target_list)
path_length_map
=
{}
path_length_map
=
{}
# build the path_length_map from source node
# build the path_length_map from source node
...
@@ -453,6 +464,12 @@ class Topo():
...
@@ -453,6 +464,12 @@ class Topo():
try
:
try
:
distance
,
path
=
nx
.
single_source_dijkstra
(
self
.
load_G
,
source
=
source_node
,
target
=
i
,
distance
,
path
=
nx
.
single_source_dijkstra
(
self
.
load_G
,
source
=
source_node
,
target
=
i
,
weight
=
"real_distance"
)
weight
=
"real_distance"
)
load_area_id
=
session_postgre
.
query
(
DiggingWorkArea
)
.
filter_by
(
EntranceNodeId
=
i
)
.
first
()
.
Id
load_area_lane_dict
[
str
(
load_area_id
)]
=
[]
for
j
in
range
(
len
(
path
)
-
1
):
load_area_lane_dict
[
str
(
load_area_id
)]
+=
self
.
load_G
[
path
[
j
]][
path
[
j
+
1
]][
'lane'
]
path_length_map
[
distance
]
=
path
path_length_map
[
distance
]
=
path
# print(path)
# print(path)
except
Exception
as
es
:
except
Exception
as
es
:
...
@@ -470,7 +487,7 @@ class Topo():
...
@@ -470,7 +487,7 @@ class Topo():
else
:
else
:
reachable_destinations
[
target_digging_area
]
=
[
k
+
distance_end_node
,
1
]
reachable_destinations
[
target_digging_area
]
=
[
k
+
distance_end_node
,
1
]
return
reachable_destinations
return
reachable_destinations
,
load_area_lane_dict
def
update_cross_nodes
(
self
):
def
update_cross_nodes
(
self
):
"""
"""
...
...
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