Browse Source

modified 2-4 assign_signal : unprotected_left and unassigned uturn

master
김선중 1 year ago
parent
commit
3853034c18
11 changed files with 7458 additions and 6029 deletions
  1. +0
    -20
      Analysis/0411_unp-left_p-right-uturn/0416_initialize_state.ipynb
  2. +1551
    -133
      Analysis/0411_unp-left_p-right-uturn/0417_assign_signal.ipynb
  3. +3540
    -3575
      Data/tables/history.csv
  4. +20
    -20
      Data/tables/plan.csv
  5. +618
    -603
      Data/tables/raw_tables/0409_make_sample_table.ipynb
  6. +4
    -6
      Intermediates/modify_match1.py
  7. +535
    -525
      Results/sn_1704417600.add.xml
  8. +619
    -662
      Results/sn_1704418800.add.xml
  9. +518
    -464
      Results/sn_1704419700.add.xml
  10. BIN
      Scripts/__pycache__/preprocess_daily.cpython-38.pyc
  11. +53
    -21
      Scripts/preprocess_daily.py

+ 0
- 20
Analysis/0411_unp-left_p-right-uturn/0416_initialize_state.ipynb View File

@ -963,26 +963,6 @@
" self.p2UPLindices[parent_id][UPLindex] = inc_edge_ids"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{2: ['571542073_01']}"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"self.p2UPLindices[self.parent_ids[5]]"
]
},
{
"cell_type": "code",
"execution_count": 23,

+ 1551
- 133
Analysis/0411_unp-left_p-right-uturn/0417_assign_signal.ipynb
File diff suppressed because it is too large
View File


+ 3540
- 3575
Data/tables/history.csv
File diff suppressed because it is too large
View File


+ 20
- 20
Data/tables/plan.csv View File

@ -3,31 +3,31 @@ inter_no,start_hour,start_minute,dura_A1,dura_A2,dura_A3,dura_A4,dura_A5,dura_A6
175,07,00,40,42,55,33,0,0,0,0,40,42,29,59,0,0,0,0,170,40,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
175,09,00,43,45,55,37,0,0,0,0,43,45,33,59,0,0,0,0,180,28,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
175,18,30,46,48,55,41,0,0,0,0,46,48,37,59,0,0,0,0,190,18,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
176,00,00,37,73,40,0,0,0,0,0,37,73,40,0,0,0,0,0,150,131,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
176,07,00,37,93,40,0,0,0,0,0,37,93,40,0,0,0,0,0,170,153,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
176,09,00,37,103,40,0,0,0,0,0,37,103,40,0,0,0,0,0,180,169,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
176,18,30,37,113,40,0,0,0,0,0,37,113,40,0,0,0,0,0,190,185,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
177,00,00,36,20,68,26,0,0,0,0,36,20,68,26,0,0,0,0,150,35,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
177,07,00,40,25,71,34,0,0,0,0,40,25,71,34,0,0,0,0,170,33,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
177,09,00,43,27,70,40,0,0,0,0,43,27,70,40,0,0,0,0,180,41,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
177,18,30,45,32,77,36,0,0,0,0,45,32,77,36,0,0,0,0,190,49,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
178,00,00,38,39,40,23,0,0,0,0,38,39,40,23,0,0,0,0,140,50,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
178,07,00,38,39,42,41,0,0,0,0,38,39,62,21,0,0,0,0,160,90,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
178,09,00,38,39,43,50,0,0,0,0,38,39,71,22,0,0,0,0,170,80,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
178,18,30,38,39,44,59,0,0,0,0,38,39,80,23,0,0,0,0,180,75,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
176,00,00,37,73,40,0,0,0,0,0,37,73,40,0,0,0,0,0,150,131,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
176,07,00,37,93,40,0,0,0,0,0,37,93,40,0,0,0,0,0,170,153,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
176,09,00,37,103,40,0,0,0,0,0,37,103,40,0,0,0,0,0,180,169,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
176,18,30,37,113,40,0,0,0,0,0,37,113,40,0,0,0,0,0,190,185,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
177,00,00,36,20,68,26,0,0,0,0,36,20,68,26,0,0,0,0,150,35,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
177,07,00,40,25,71,34,0,0,0,0,40,25,71,34,0,0,0,0,170,33,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
177,09,00,43,27,70,40,0,0,0,0,43,27,70,40,0,0,0,0,180,41,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
177,18,30,45,32,77,36,0,0,0,0,45,32,77,36,0,0,0,0,190,49,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
178,00,00,38,39,40,23,0,0,0,0,38,39,40,23,0,0,0,0,140,50,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
178,07,00,38,39,42,41,0,0,0,0,38,39,62,21,0,0,0,0,160,90,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
178,09,00,38,39,43,50,0,0,0,0,38,39,71,22,0,0,0,0,170,80,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
178,18,30,38,39,44,59,0,0,0,0,38,39,80,23,0,0,0,0,180,75,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
201,00,00,24,24,17,58,17,0,0,0,24,24,17,58,17,0,0,0,140,133,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
201,07,00,30,36,18,58,18,0,0,0,30,36,18,58,18,0,0,0,160,132,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
201,09,00,33,36,25,58,18,0,0,0,33,36,25,58,18,0,0,0,170,134,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
201,18,30,36,50,18,58,18,0,0,0,36,50,18,58,18,0,0,0,180,137,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
202,00,00,39,101,0,0,0,0,0,0,39,101,0,0,0,0,0,0,140,103,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
202,07,00,46,114,0,0,0,0,0,0,46,114,0,0,0,0,0,0,160,103,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
202,09,00,46,114,0,0,0,0,0,0,46,114,0,0,0,0,0,0,160,103,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
202,18,30,48,122,0,0,0,0,0,0,48,122,0,0,0,0,0,0,170,103,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
202,00,00,39,101,0,0,0,0,0,0,39,101,0,0,0,0,0,0,140,103,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
202,07,00,46,114,0,0,0,0,0,0,46,114,0,0,0,0,0,0,160,103,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
202,09,00,46,114,0,0,0,0,0,0,46,114,0,0,0,0,0,0,160,103,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
202,18,30,48,122,0,0,0,0,0,0,48,122,0,0,0,0,0,0,170,103,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
206,00,00,33,35,26,26,0,0,0,0,33,35,26,26,0,0,0,0,120,10,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
206,07,00,44,44,26,26,0,0,0,0,44,44,26,26,0,0,0,0,140,7,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
206,09,00,45,53,26,26,0,0,0,0,45,53,26,26,0,0,0,0,150,17,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
206,18,30,46,62,26,26,0,0,0,0,46,62,26,26,0,0,0,0,160,10,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
210,00,00,43,29,56,22,0,0,0,0,24,48,56,22,0,0,0,0,150,115,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
210,07,00,43,39,65,23,0,0,0,0,24,58,65,23,0,0,0,0,170,131,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
210,09,00,43,43,70,24,0,0,0,0,28,58,70,24,0,0,0,0,180,137,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
210,18,30,43,47,75,25,0,0,0,0,24,66,75,25,0,0,0,0,190,143,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
210,00,00,43,29,56,22,0,0,0,0,24,48,56,22,0,0,0,0,150,115,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
210,07,00,43,39,65,23,0,0,0,0,24,58,65,23,0,0,0,0,170,131,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
210,09,00,43,43,70,24,0,0,0,0,28,58,70,24,0,0,0,0,180,137,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
210,18,30,43,47,75,25,0,0,0,0,24,66,75,25,0,0,0,0,190,143,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

+ 618
- 603
Data/tables/raw_tables/0409_make_sample_table.ipynb
File diff suppressed because it is too large
View File


+ 4
- 6
Intermediates/modify_match1.py View File

@ -6,11 +6,9 @@ self = DailyPreprocessor()
self.load_data() # 1. 데이터 불러오기
self.make_match1(fetch_all=True) # 2-1-1
print(self.match1)
self.match1 = self.match1.drop(index=[9, 11])
self.match1.loc[10, ['phas_A', 'phas_B']] = 2
# 이 사례 말고도 비보호좌회전 사례가 존재하므로 이 코드는 주석처리
# # 201(i8), 5현시 B링의 이동류번호 7 없앰 (비보호좌회전 사례 만들기 위함)
# self.match1.at[20, 'move_A'] = 4
# self.match1.at[7, 'move_A'] = 17 # 176(i1) 비보호 좌회전 사례 만들기 (잘 되지 않음)
self.match1 = self.match1.drop(index=[9, 11]) # 177(i2) 잘못 지정된 이동류번호 수정
self.match1.loc[10, ['phas_A', 'phas_B']] = 2 # 177(i2) 추가수정
self.match1 = self.match1.reset_index(drop=True)
self.match1.to_csv('Intermediates/match1.csv', index=0)
print(self.match1)
print(self.match1)

+ 535
- 525
Results/sn_1704417600.add.xml
File diff suppressed because it is too large
View File


+ 619
- 662
Results/sn_1704418800.add.xml
File diff suppressed because it is too large
View File


+ 518
- 464
Results/sn_1704419700.add.xml
File diff suppressed because it is too large
View File


BIN
Scripts/__pycache__/preprocess_daily.cpython-38.pyc View File


+ 53
- 21
Scripts/preprocess_daily.py View File

@ -748,7 +748,7 @@ class DailyPreprocessor():
u_turn_conn = inc_edge.getConnections(out_edge)[0]
self.u2uindex[child_id] = u_turn_conn.getTLLinkIndex()
self.p2UPLindices = dict() # parent id to unprotected left index
self.p2UPLindices2inc_edge_ids = dict() # parent id to unprotected left index
for parent_id in self.parent_ids:
init_state = self.node2init[parent_id]
# 우회전 이동류 인덱스
@ -775,9 +775,14 @@ class DailyPreprocessor():
indices = [conn.getTLLinkIndex() for conn in conns]
indices_left.extend(indices)
# 비보호좌회전 인덱스 (unprotected left index)
UPLindices = list((set(range(len(init_state))) - set(indices_right) - set(indices_assigned)).intersection(indices_left))
self.p2UPLindices[parent_id] = UPLindices
UPLindices2inc_edge_ids = list((set(range(len(init_state))) - set(indices_right) - set(indices_assigned)).intersection(indices_left))
self.p2UPLindices2inc_edge_ids[parent_id] = dict()
for UPLindex in UPLindices2inc_edge_ids:
node = self.net.getNode(parent_id)
conns = node.getConnections()
conns = [conn for conn in conns if conn.getTLLinkIndex() == UPLindex]
inc_edge_ids = [conn.getFrom().getID() for conn in conns]
self.p2UPLindices2inc_edge_ids[parent_id][UPLindex] = inc_edge_ids
print('2-3. 유턴 인덱스 / 비보호좌회전 인덱스를 지정했습니다.')
# 2-4 신호배정
@ -806,30 +811,57 @@ class DailyPreprocessor():
self.matching = self.matching.reset_index(drop=True)
self.matching = self.matching[['inter_no', 'node_id', 'move_no', 'inc_edge_id', 'out_edge_id', 'state']]
# assign signals on match6
self.match6 = self.match6.reset_index(drop=True)
self.match6['init_state'] = self.match6['node_id'].map(self.node2init)
self.match6['state'] = self.match6['init_state'].map(lambda x:''.join(x))
# match6의 각 행을 순회
# match6 : 신호 배정
for i, row in self.match6.iterrows():
node_id = row.node_id
move_no = row.move_no
inc_edge_id = row.inc_edge_id
out_edge_id = row.out_edge_id
state = copy.deepcopy(self.node2init)[node_id]
state_list = copy.deepcopy(self.node2init[node_id])
self.match6.at[i, 'state'] = ''.join(state_list)
if (pd.isna(inc_edge_id)) or (pd.isna(out_edge_id)):
continue
if (move_no != 21):
# print(i, node_id, move_no, ''.join(state))
inc_edge = self.net.getEdge(inc_edge_id)
out_edge = self.net.getEdge(out_edge_id)
for conn in inc_edge.getConnections(out_edge):
index = conn.getTLLinkIndex()
if index >= 0:
state[index] = 'G'
# print(i, node_id, move_no, index, ''.join(state))
self.match6.at[i, 'state'] = ''.join(state)
inc_edge = self.net.getEdge(inc_edge_id)
out_edge = self.net.getEdge(out_edge_id)
for conn in inc_edge.getConnections(out_edge):
index = conn.getTLLinkIndex()
if index >= 0:
state_list[index] = 'G'
self.match6.at[i, 'state'] = ''.join(state_list)
# mactch6 : 비보호좌회전 신호 배정
for i, row in self.match6[self.match6.node_id.isin(self.parent_ids)].iterrows():
parent_id = row.node_id
state = row.state
UPLindices2inc_edge_ids = self.p2UPLindices2inc_edge_ids[parent_id]
for UPLindex in UPLindices2inc_edge_ids:
inc_edge_ids = UPLindices2inc_edge_ids[UPLindex]
if inc_edge_ids:
if inc_edge_id in inc_edge_ids:
state = state[:UPLindex] + 'g' + state[UPLindex+1:]
self.match6.at[i, 'state'] = state
else: # modify_match1.py : self.match1.at[7, 'move_A'] = 17
raise Exception(
f"비보호좌회전 신호를 부여할 수 없습니다. \
\
(node_id : {parent_id}, index : {UPLindex})\
(inc_edge_id : {inc_edge_id}) .")
# mactch6 : 유턴 신호가 한번도 배정되지 않은 경우에 대해서는 유턴이동류의 신호를 항상 g로 배정
for node_id in self.u_turn_ids:
m6 = self.match6[self.match6.node_id==node_id]
if not len(m6):
continue
state_list = copy.deepcopy(self.node2init[node_id])
state = ''.join(state_list)
uindex = self.u2uindex[node_id]
values_at_uindex = [state[uindex] for state in m6.state]
uturn_assigned = ('G' in values_at_uindex)
if not uturn_assigned:
print('uturn not assigned')
state = state[:uindex] + 'g' + state[uindex+1:]
print(i, state)
self.match6.loc[self.match6.node_id==node_id, 'state'] = state
self.match6 = self.match6.dropna(subset='state')
self.match6 = self.match6.reset_index(drop=True)

Loading…
Cancel
Save