Browse Source

a value of self.p2UPLindices is now set to dictionary that maps UPLindex into inc_edge_ids

master
김선중 1 year ago
parent
commit
60bbf8e03c
5 changed files with 1009 additions and 3140 deletions
  1. +124
    -2478
      Analysis/0411_unp-left_p-right-uturn/0416_initialize_state.ipynb
  2. +304
    -0
      Analysis/0411_unp-left_p-right-uturn/0417_assign_signal.ipynb
  3. +580
    -662
      Data/tables/raw_tables/0409_make_sample_table.ipynb
  4. BIN
      Scripts/__pycache__/preprocess_daily.cpython-38.pyc
  5. +1
    -0
      Scripts/preprocess_daily.py

+ 124
- 2478
Analysis/0411_unp-left_p-right-uturn/0416_initialize_state.ipynb
File diff suppressed because it is too large
View File


+ 304
- 0
Analysis/0411_unp-left_p-right-uturn/0417_assign_signal.ipynb View File

@ -0,0 +1,304 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import pandas as pd\n",
"import numpy as np\n",
"import sys\n",
"import copy\n",
"sys.path.append('../../Scripts')\n",
"from preprocess_daily import DailyPreprocessor\n",
"from generate_signals import SignalGenerator"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1. 데이터를 로드합니다.\n",
"1-1. 네트워크가 로드되었습니다.\n",
"1-2. 테이블들이 로드되었습니다.\n",
"1-3. 네트워크의 모든 clean state requirement들을 체크했습니다.\n",
"1-4. 테이블들의 무결성 검사를 완료했습니다.\n",
"1-5. 주요 객체 (리스트, 딕셔너리)들을 저장했습니다.\n",
"2-1. 매칭 테이블들을 생성했습니다.\n",
"2-2. 초기화 신호가 지정되었습니다. (우회전 : g)\n",
"2-3. 유턴 인덱스 / 비보호좌회전 인덱스를 지정했습니다.\n",
"i6\n",
"[8]\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>inter_no</th>\n",
" <th>phase_no</th>\n",
" <th>ring_type</th>\n",
" <th>move_no</th>\n",
" <th>inc_dire</th>\n",
" <th>out_dire</th>\n",
" <th>inc_angle</th>\n",
" <th>out_angle</th>\n",
" <th>inc_edge_id</th>\n",
" <th>out_edge_id</th>\n",
" <th>node_id</th>\n",
" <th>turn_type</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>92</th>\n",
" <td>210</td>\n",
" <td>1</td>\n",
" <td>A</td>\n",
" <td>6</td>\n",
" <td>동</td>\n",
" <td>서</td>\n",
" <td>090</td>\n",
" <td>270</td>\n",
" <td>-571542115_01</td>\n",
" <td>571500535_01</td>\n",
" <td>i6</td>\n",
" <td>straight</td>\n",
" </tr>\n",
" <tr>\n",
" <th>93</th>\n",
" <td>210</td>\n",
" <td>1</td>\n",
" <td>B</td>\n",
" <td>18</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>i6</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>94</th>\n",
" <td>210</td>\n",
" <td>2</td>\n",
" <td>A</td>\n",
" <td>5</td>\n",
" <td>서</td>\n",
" <td>북</td>\n",
" <td>270</td>\n",
" <td>000</td>\n",
" <td>571500535_02.18</td>\n",
" <td>571511538_01</td>\n",
" <td>i6</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>95</th>\n",
" <td>210</td>\n",
" <td>2</td>\n",
" <td>B</td>\n",
" <td>2</td>\n",
" <td>서</td>\n",
" <td>동</td>\n",
" <td>270</td>\n",
" <td>090</td>\n",
" <td>571500535_02.18</td>\n",
" <td>571542115_01</td>\n",
" <td>i6</td>\n",
" <td>straight</td>\n",
" </tr>\n",
" <tr>\n",
" <th>96</th>\n",
" <td>210</td>\n",
" <td>3</td>\n",
" <td>A</td>\n",
" <td>7</td>\n",
" <td>북</td>\n",
" <td>동</td>\n",
" <td>000</td>\n",
" <td>090</td>\n",
" <td>571511538_02.121</td>\n",
" <td>571542115_01</td>\n",
" <td>i6</td>\n",
" <td>left</td>\n",
" </tr>\n",
" <tr>\n",
" <th>97</th>\n",
" <td>210</td>\n",
" <td>3</td>\n",
" <td>B</td>\n",
" <td>4</td>\n",
" <td>북</td>\n",
" <td>남</td>\n",
" <td>000</td>\n",
" <td>180</td>\n",
" <td>571511538_02.121</td>\n",
" <td>571500585_01</td>\n",
" <td>i6</td>\n",
" <td>straight</td>\n",
" </tr>\n",
" <tr>\n",
" <th>98</th>\n",
" <td>210</td>\n",
" <td>4</td>\n",
" <td>A</td>\n",
" <td>8</td>\n",
" <td>남</td>\n",
" <td>북</td>\n",
" <td>180</td>\n",
" <td>000</td>\n",
" <td>571500585_02</td>\n",
" <td>571511538_01</td>\n",
" <td>i6</td>\n",
" <td>straight</td>\n",
" </tr>\n",
" <tr>\n",
" <th>99</th>\n",
" <td>210</td>\n",
" <td>4</td>\n",
" <td>B</td>\n",
" <td>3</td>\n",
" <td>남</td>\n",
" <td>서</td>\n",
" <td>180</td>\n",
" <td>270</td>\n",
" <td>571500585_02</td>\n",
" <td>571500535_01</td>\n",
" <td>i6</td>\n",
" <td>left</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" inter_no phase_no ring_type move_no inc_dire out_dire inc_angle \\\n",
"92 210 1 A 6 동 서 090 \n",
"93 210 1 B 18 NaN NaN NaN \n",
"94 210 2 A 5 서 북 270 \n",
"95 210 2 B 2 서 동 270 \n",
"96 210 3 A 7 북 동 000 \n",
"97 210 3 B 4 북 남 000 \n",
"98 210 4 A 8 남 북 180 \n",
"99 210 4 B 3 남 서 180 \n",
"\n",
" out_angle inc_edge_id out_edge_id node_id turn_type \n",
"92 270 -571542115_01 571500535_01 i6 straight \n",
"93 NaN NaN NaN i6 NaN \n",
"94 000 571500535_02.18 571511538_01 i6 left \n",
"95 090 571500535_02.18 571542115_01 i6 straight \n",
"96 090 571511538_02.121 571542115_01 i6 left \n",
"97 180 571511538_02.121 571500585_01 i6 straight \n",
"98 000 571500585_02 571511538_01 i6 straight \n",
"99 270 571500585_02 571500535_01 i6 left "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"self = DailyPreprocessor()\n",
"self.load_data() # 1. 데이터 불러오기\n",
"self.get_matches() # 2-1\n",
"self.initialize_state() # 2-2\n",
"self.assign_indices() # 2-3\n",
"\n",
"parent_id = self.parent_ids[4]\n",
"print(parent_id)\n",
"UPLindices = self.p2UPLindices[parent_id]\n",
"print(UPLindices)\n",
"m6 = self.match6[self.match6.node_id==parent_id].copy()\n",
"\n",
"# matching에 신호 배정\n",
"for i, row in self.match6.iterrows():\n",
" node_id = row.node_id\n",
" move_no = row.move_no\n",
" if (pd.isna(row.inc_edge_id)) or (pd.isna(row.out_edge_id)):\n",
" continue\n",
" inc_edge = self.net.getEdge(row.inc_edge_id)\n",
" out_edge = self.net.getEdge(row.out_edge_id)\n",
" state = copy.deepcopy(self.node2init[node_id])\n",
" for conn in inc_edge.getConnections(out_edge):\n",
" index = conn.getTLLinkIndex()\n",
" if index >= 0:\n",
" state[index] = 'G'\n",
" self.match6.at[i, 'state'] = ''.join(state)\n",
" if node_id in self.parent_ids:\n",
" UPLindices = self.p2UPLindices[node_id]\n",
" self.match6.at[i, 'unprotected_left'] = ''.join([state[j] for j in UPLindices])\n",
"display(self.match6[self.match6.node_id==parent_id])"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['b', 'c']"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"L = 'abcd'\n",
"UPLindices = [1,2]\n",
"[L[i] for i in UPLindices]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "sts",
"language": "python",
"name": "sts"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

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


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


+ 1
- 0
Scripts/preprocess_daily.py View File

@ -733,6 +733,7 @@ class DailyPreprocessor():
# json 파일로 저장
with open(os.path.join(self.path_intermediates, 'node2init.json'), 'w') as file:
json.dump(self.node2init, file)
print('2-2. 초기화 신호가 지정되었습니다. (우회전 : g)')
# 2-3 유턴 인덱스 / 비보호좌회전 인덱스 지정
def assign_indices(self):

Loading…
Cancel
Save