Browse Source

In make_match5, simplify the way to calculate cosine similarity. It should be equivalent to the former.

master
김선중 1 year ago
parent
commit
9e97e80d92
4 changed files with 236 additions and 1057 deletions
  1. +230
    -1048
      Analysis/0411_unp-left_p-right-uturn/0415_matching.ipynb
  2. BIN
      Documents/1127_table_definition/table_definition_v0.8.5.xlsx
  3. BIN
      Scripts/__pycache__/preprocess_daily.cpython-38.pyc
  4. +6
    -9
      Scripts/preprocess_daily.py

+ 230
- 1048
Analysis/0411_unp-left_p-right-uturn/0415_matching.ipynb
File diff suppressed because it is too large
View File


BIN
Documents/1127_table_definition/table_definition_v0.8.5.xlsx View File


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


+ 6
- 9
Scripts/preprocess_daily.py View File

@ -366,11 +366,11 @@ class DailyPreprocessor():
# 교차로의 모든 (from / to) edges # 교차로의 모든 (from / to) edges
inc_edges = [edge for edge in node.getIncoming() if edge.getFunction() == ''] # incoming edges inc_edges = [edge for edge in node.getIncoming() if edge.getFunction() == ''] # incoming edges
out_edges = [edge for edge in node.getOutgoing() if edge.getFunction() == ''] # outgoing edges out_edges = [edge for edge in node.getOutgoing() if edge.getFunction() == ''] # outgoing edges
# 교차로의 모든 (from / to) directions (unit vector)
# 교차로의 모든 (from / to) unit vector
inc_vecs = [] inc_vecs = []
for inc_edge in inc_edges: for inc_edge in inc_edges:
start = inc_edge.getShape()[-2]
end = inc_edge.getShape()[-1]
start = inc_edge.getShape()[-1]
end = inc_edge.getShape()[-2]
inc_vec = np.array(end) - np.array(start) inc_vec = np.array(end) - np.array(start)
inc_vec = inc_vec / (inc_vec ** 2).sum() ** 0.5 inc_vec = inc_vec / (inc_vec ** 2).sum() ** 0.5
inc_vecs.append(inc_vec) inc_vecs.append(inc_vec)
@ -386,7 +386,7 @@ class DailyPreprocessor():
inc_angle = int(row.inc_angle) inc_angle = int(row.inc_angle)
out_angle = int(row.out_angle) out_angle = int(row.out_angle)
# 방위각을 일반각으로 가공, 라디안 변환, 단위벡터로 변환 # 방위각을 일반각으로 가공, 라디안 변환, 단위벡터로 변환
inc_angle = (-90 - inc_angle) % 360
inc_angle = (90 - inc_angle) % 360
inc_angle = inc_angle * np.pi / 180. inc_angle = inc_angle * np.pi / 180.
inc_vec_true = np.array([np.cos(inc_angle), np.sin(inc_angle)]) inc_vec_true = np.array([np.cos(inc_angle), np.sin(inc_angle)])
out_angle = (90 - out_angle) % 360 out_angle = (90 - out_angle) % 360
@ -564,8 +564,8 @@ class DailyPreprocessor():
# 2-1-7 # 2-1-7
def make_matching(self): def make_matching(self):
''' '''
, (1~18, 21) ·ID를
*
, (1~16) ·ID를
*
: inter_no, move_no, inc_dire, out_dire, inc_edge_id, out_edge_id, node_id : inter_no, move_no, inc_dire, out_dire, inc_edge_id, out_edge_id, node_id
''' '''
@ -573,9 +573,6 @@ class DailyPreprocessor():
self.match7 = self.match6.copy() self.match7 = self.match6.copy()
self.match7 = self.match7[['inter_no', 'move_no', 'inc_dire', 'out_dire', 'inc_edge_id', 'out_edge_id', 'node_id']] self.match7 = self.match7[['inter_no', 'move_no', 'inc_dire', 'out_dire', 'inc_edge_id', 'out_edge_id', 'node_id']]
# parent_ids = sorted(self.inter_node[self.inter_node.inter_type=='parent'].node_id.unique())
# child_ids = sorted(self.inter_node[self.inter_node.inter_type=='child'].node_id.unique())
# (1) 가능한 (진입방향, 진출방향) 목록 # (1) 가능한 (진입방향, 진출방향) 목록
flows = self.nema.dropna().apply(lambda row: (row['inc_dire'], row['out_dire']), axis=1).tolist() flows = self.nema.dropna().apply(lambda row: (row['inc_dire'], row['out_dire']), axis=1).tolist()
# (2) 각 교차로별 방향 목록 : pdires (possible directions) # (2) 각 교차로별 방향 목록 : pdires (possible directions)

Loading…
Cancel
Save