{ "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
inter_nophase_noring_typemove_noinc_direout_direinc_angleout_angleinc_edge_idout_edge_idnode_idturn_type
922101A6090270-571542115_01571500535_01i6straight
932101B18NaNNaNNaNNaNNaNNaNi6NaN
942102A5270000571500535_02.18571511538_01i6left
952102B2270090571500535_02.18571542115_01i6straight
962103A7000090571511538_02.121571542115_01i6left
972103B4000180571511538_02.121571500585_01i6straight
982104A8180000571500585_02571511538_01i6straight
992104B3180270571500585_02571500535_01i6left
\n", "
" ], "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 }