Browse Source

new uturn allocation code is applied (allocate for unallocated uturn nodes)

master
김선중 1 year ago
parent
commit
a811c07d09
5 changed files with 669 additions and 340 deletions
  1. +595
    -312
      Analysis/0307_red_yellow/0307_red_yellow.ipynb
  2. +23
    -0
      Analysis/0307_red_yellow/0307_red_yellow_2.ipynb
  3. +7
    -7
      Intermediates/match6.csv
  4. +5
    -5
      Intermediates/matching.csv
  5. +39
    -16
      Scripts/preprocess_daily.py

+ 595
- 312
Analysis/0307_red_yellow/0307_red_yellow.ipynb
File diff suppressed because it is too large
View File


+ 23
- 0
Analysis/0307_red_yellow/0307_red_yellow_2.ipynb View File

@ -6973,6 +6973,8 @@
" parent_id = row.parent_id\n",
" direction = row.direction\n",
" condition = row.condition\n",
" inc_edge_id = row.inc_edge\n",
" out_edge_id = row.out_edge\n",
"\n",
" # match5에서 부모노드id에 해당하는 행들을 가져옴 (cmatch)\n",
" cmatch = self.match5.copy()[self.match5.node_id==parent_id] # match dataframe for a child node\n",
@ -7020,6 +7022,27 @@
" cmatch.loc[right_exists, ['inc_edge', 'out_edge']] = [inc_edge_id, out_edge_id]"
]
},
{
"cell_type": "code",
"execution_count": 229,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'DailyPreprocessor' object has no attribute 'matches'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[229], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmatches\u001b[49m\n",
"\u001b[1;31mAttributeError\u001b[0m: 'DailyPreprocessor' object has no attribute 'matches'"
]
}
],
"source": [
"self.matches"
]
},
{
"cell_type": "markdown",
"metadata": {},

+ 7
- 7
Intermediates/match6.csv View File

@ -9,7 +9,7 @@
7,175,i0,4,B,2,grrrgrrrgrrrrrgGr
8,175,u00,1,A,8,ggggrgggg
9,175,u00,1,B,4,ggggrgggg
10,175,u00,2,A,19,ggggGgggg
10,175,u00,2,A,7,ggggGgggg
11,175,u00,2,B,3,ggggrgggg
12,175,u00,3,A,6,ggggrgggg
13,175,u00,3,B,1,ggggrgggg
@ -33,8 +33,8 @@
31,177,u20,1,B,4,ggrggg
32,177,u20,2,A,7,ggrggg
33,177,u20,2,B,3,ggrggg
34,177,u20,3,A,17,ggGggg
35,177,u20,3,B,18,ggrggg
34,177,u20,3,A,17,ggrggg
35,177,u20,3,B,18,ggGggg
36,177,u20,4,A,5,ggrggg
37,177,u20,4,B,1,ggrggg
38,178,c30,1,A,20,rrrrrr
@ -59,9 +59,9 @@
57,178,u30,2,B,3,ggggrggg
58,178,u30,3,A,5,ggggrggg
59,178,u30,3,B,2,ggggrggg
60,178,u30,4,A,19,ggggGggg
60,178,u30,4,A,6,ggggGggg
61,178,u30,4,B,1,ggggrggg
62,178,u31,1,A,19,ggggGggg
62,178,u31,1,A,8,ggggGggg
63,178,u31,1,B,4,ggggrggg
64,178,u31,2,A,7,ggggrggg
65,178,u31,2,B,3,ggggrggg
@ -70,7 +70,7 @@
68,178,u31,4,A,6,ggggrggg
69,178,u31,4,B,1,ggggrggg
70,178,u32,1,A,8,gggggggr
71,178,u32,1,B,19,gggggggG
71,178,u32,1,B,4,gggggggG
72,178,u32,2,A,7,gggggggr
73,178,u32,2,B,3,gggggggr
74,178,u32,3,A,5,gggggggr
@ -109,7 +109,7 @@
107,210,i6,4,B,3,grrrgrrrrgrrgrrr
108,210,u60,1,A,6,ggggggggr
109,210,u60,1,B,18,ggggggggr
110,210,u60,2,A,19,ggggggggG
110,210,u60,2,A,5,ggggggggG
111,210,u60,2,B,2,ggggggggr
112,210,u60,3,A,7,ggggggggr
113,210,u60,3,B,4,ggggggggr

+ 5
- 5
Intermediates/matching.csv View File

@ -11,7 +11,7 @@
9,175,i0,21,grrrgrrrgrrrrrgrr
10,175,i0,21,grrrgrrrgrrrrrgrr
11,175,i0,21,grrrgrrrgrrrrrgrr
12,175,u00,19,ggggGgggg
12,175,u00,7,ggggGgggg
13,176,i1,3,grrrrrGgrr
14,176,i1,4,gGGrrrrgrr
15,176,i1,5,grrrrrrgGG
@ -42,9 +42,9 @@
40,178,i3,21,grrrrgrrrrgrrrrgrrrr
41,178,i3,21,grrrrgrrrrgrrrrgrrrr
42,178,i3,21,grrrrgrrrrgrrrrgrrrr
43,178,u30,19,ggggGggg
44,178,u31,19,ggggGggg
45,178,u32,19,gggggggG
43,178,u30,6,ggggGggg
44,178,u31,8,ggggGggg
45,178,u32,4,gggggggG
46,201,i8,1,grrrrrrGgrrrgrrr
47,201,i8,2,grrrrrrrgrrrgGGr
48,201,i8,3,grrrrrrrgrrGgrrr
@ -73,4 +73,4 @@
71,210,i6,21,grrrgrrrrgrrgrrr
72,210,i6,21,grrrgrrrrgrrgrrr
73,210,i6,21,grrrgrrrrgrrgrrr
74,210,u60,19,ggggggggG
74,210,u60,5,ggggggggG

+ 39
- 16
Scripts/preprocess_daily.py View File

@ -448,28 +448,51 @@ class DailyPreprocessor():
condition = row.condition
inc_edge_id = row.inc_edge
out_edge_id = row.out_edge
# match5에서 parent_id에 해당하는 행들을 가져옴
# 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)
cmatch['node_id'] = child_id
cmatch[['inc_edge', 'out_edge']] = np.nan
# condition 별로 inc_dire, out_dire를 정함
# 보행신호시/좌회전시 진입/진출방향
ind = directions.index(direction)
inc_dire_pedes = directions[(ind + 2) % len(directions)]
out_dire_pedes = directions[(ind - 2) % len(directions)]
inc_dire_right = direction
out_dire_right = directions[(ind + 2) % len(directions)]
# 보행신호시/좌회전시 조건
pedes_exists = (cmatch.inc_dir==inc_dire_pedes) & (cmatch.out_dir==out_dire_pedes)
right_exists = (cmatch.inc_dir==inc_dire_right) & (cmatch.out_dir==out_dire_right)
# 보행신호시/좌회전시 진입/진출 엣지id 배정
ind = directions.index(direction)
if condition == "좌회전시":
inc_dire = direction
out_dire = directions[(ind + 2) % len(directions)]
elif condition == "보행신호시":
inc_dire = directions[(ind + 2) % len(directions)]
out_dire = directions[(ind - 2) % len(directions)]
# (inc_dire, out_dire) 별로 inc_edge_id, out_edge_id를 정함
cmatch.loc[(cmatch.inc_dir==inc_dire) & (cmatch.out_dir==out_dire), ['inc_edge', 'out_edge']] = [inc_edge_id, out_edge_id]
if condition == '보행신호시':
# 이동류번호가 17(보행신호)이면서 유턴노드방향으로 가는 신호가 없으면 (inc_edge_id, out_edge_id)를 부여한다.
cmatch.loc[(cmatch.move_no==17) & (cmatch.out_dir!=direction), ['inc_edge', 'out_edge']] = [inc_edge_id, out_edge_id]
# 유턴신호의 이동류번호를 19로 부여한다.
cmatch.loc[(cmatch.inc_dir==inc_dire) & (cmatch.out_dir==out_dire), 'move_no'] = 19
if condition == "보행신호시":
cmatch.loc[pedes_exists, ['inc_edge', 'out_edge']] = [inc_edge_id, out_edge_id]
elif condition == "좌회전시":
cmatch.loc[right_exists, ['inc_edge', 'out_edge']] = [inc_edge_id, out_edge_id]
# 신호없음이동류발생시/보행신호이동류발생시 조건
all_redsigns = cmatch.move_no == 18
crosswalk_on = cmatch.move_no == 17
# 만약 어떤 유턴신호도 배정되지 않았다면
# 신호없음이동류발생시 → 보행신호이동류발생시 → 보행신호시 → 좌회전시 순으로 진입/진출 엣지id 배정
uturn_not_assigned = cmatch[['inc_edge','out_edge']].isna().any(axis=1).all()
if uturn_not_assigned:
# 신호없음이동류(18) 발생시
if all_redsigns.any():
cmatch.loc[all_redsigns, ['inc_edge', 'out_edge']] = [inc_edge_id, out_edge_id]
# 보행신호이동류(17) 발생시
elif crosswalk_on.any():
cmatch.loc[crosswalk_on & (cmatch.out_dir!=direction), ['inc_edge', 'out_edge']] = [inc_edge_id, out_edge_id]
# 보행신호시
elif pedes_exists.any():
cmatch.loc[pedes_exists, ['inc_edge', 'out_edge']] = [inc_edge_id, out_edge_id]
# 좌회전시
elif right_exists.any():
cmatch.loc[right_exists, ['inc_edge', 'out_edge']] = [inc_edge_id, out_edge_id]
cmatches.append(cmatch)
# 각 연등교차로(coordination node)에 대하여 (inc_edge_id, out_edge_id) 부여

Loading…
Cancel
Save