From 92db67817277b028a521f8ea4e2ca115edb7c42c Mon Sep 17 00:00:00 2001 From: govin08 Date: Wed, 17 Apr 2024 10:54:34 +0900 Subject: [PATCH] assign_indices : assigning u_turn indices and unprotected_left indices is now located in one method. --- Results/sn_1704419400.add.xml | 776 ++++++++++++++++++---------------- Scripts/preprocess_daily.py | 26 +- 2 files changed, 430 insertions(+), 372 deletions(-) diff --git a/Results/sn_1704419400.add.xml b/Results/sn_1704419400.add.xml index 124820561..1e3aa312b 100644 --- a/Results/sn_1704419400.add.xml +++ b/Results/sn_1704419400.add.xml @@ -1,189 +1,201 @@ - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + @@ -241,326 +253,366 @@ - + - - + + + + - - + + + + - - + + + + - - + + + + - - + + + + - - + + + + - - + + + + - - + + + + - - + + + + - - + + + + - - + + + + - - + + + + - - + + + + - - + + + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + - - - - + - - + + - - - - - + + - + + + + - - + + - - - - - + + - + + + + - - + + + + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + diff --git a/Scripts/preprocess_daily.py b/Scripts/preprocess_daily.py index 1752eaf64..956da0487 100644 --- a/Scripts/preprocess_daily.py +++ b/Scripts/preprocess_daily.py @@ -229,6 +229,7 @@ class DailyPreprocessor(): print('2. 중간산출물을 생성합니다.') self.get_matches() self.initialize_state() + self.assign_indices() self.assign_signals() self.get_node2num_cycles() @@ -438,8 +439,6 @@ class DailyPreprocessor(): out_angle2edge = dict(zip(m5.out_angle.astype(int), m5.out_edge_id)) p2out_angle2edge[node_id] = out_angle2edge - self.u2uindex = dict() # u_turn node id to u_turn index - # 각 uturn node에 대하여 (inc_edge_id, out_edge_id) 부여 cmatches = [] for row in self.u_turn.itertuples(): @@ -451,12 +450,6 @@ class DailyPreprocessor(): adj_inc_edge_id = row.adj_inc_edge_id adj_out_edge_id = row.adj_out_edge_id - # self.u2uindex 지정 - inc_edge = self.net.getEdge(inc_edge_id) - out_edge = self.net.getEdge(out_edge_id) - u_turn_conn = inc_edge.getConnections(out_edge)[0] - self.u2uindex[child_id] = u_turn_conn.getTLLinkIndex() - # match5에서 부모노드id에 해당하는 행들을 가져옴 (cmatch) cmatch = self.match5.copy()[self.match5.node_id==parent_id] # match dataframe for a child node cmatch = cmatch.sort_values(by=['phase_no', 'ring_type']).reset_index(drop=True) @@ -744,6 +737,19 @@ class DailyPreprocessor(): with open(os.path.join(self.path_intermediates, 'node2init.json'), 'w') as file: json.dump(self.node2init, file) + # 2-3 유턴 인덱스 / 비보호좌회전 인덱스 지정 + def assign_indices(self): + self.u2uindex = dict() # u_turn node id to u_turn index + for row in self.u_turn.itertuples(): + child_id = row.child_id + inc_edge_id = row.inc_edge_id + out_edge_id = row.out_edge_id + # self.u2uindex 지정 + inc_edge = self.net.getEdge(inc_edge_id) + out_edge = self.net.getEdge(out_edge_id) + u_turn_conn = inc_edge.getConnections(out_edge)[0] + self.u2uindex[child_id] = u_turn_conn.getTLLinkIndex() + self.p2PLindices = dict() # parent id to protected left index for parent_id in self.parent_ids: init_state = self.node2init[parent_id] @@ -776,7 +782,7 @@ class DailyPreprocessor(): print('2-2. 비보호우회전(g)을 배정했습니다.') - # 2-3 신호배정 + # 2-4 신호배정 def assign_signals(self): # assign signals on matching self.matching['init_state'] = self.matching['node_id'].map(self.node2init) @@ -834,7 +840,7 @@ class DailyPreprocessor(): self.matching.to_csv(os.path.join(self.path_intermediates, 'matching.csv'), index=0) print('2-3. 직진 및 좌회전(G)을 배정했습니다.') - # 2-4 node2num_cycles : A dictionary that maps a node_id to the number of cycles + # 2-5 node2num_cycles : A dictionary that maps a node_id to the number of cycles def get_node2num_cycles(self): Aplan = self.plan.copy()[['inter_no'] + [f'dura_A{j}' for j in range(1,9)] + ['cycle']] grouped = Aplan.groupby('inter_no')