diff --git a/notebooks/MC_RAPTOR.ipynb b/notebooks/MC_RAPTOR.ipynb index 62e53f2..c337d73 100644 --- a/notebooks/MC_RAPTOR.ipynb +++ b/notebooks/MC_RAPTOR.ipynb @@ -1,3159 +1,2378 @@ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Reversed MC RAPTOR\n", "\n", "## Left out at this stage:\n", "\n", "- Realistic time to get out of one transport and walk to the platform of the next. Instead, we just set it to 2 minutes, no matter what.\n", "\n", "## Encoding the data structures\n", "### General considerations\n", "We adhere to the data structures proposed by Delling et al. These structures aim to minimize read times in memory by making use of consecutive in-memory adresses. Thus, structures with varying dimensions (e.g dataframes, python lists) are excluded. We illustrate the difficulty with an example. \n", "\n", "Each route has a potentially unique number of stops. Therefore, we cannot store stops in a 2D array of routes by stops, as the number of stops is not the same for each route. We adress this problem by storing stops consecutively by route, and keeping track of the index of the first stop for each route.\n", "\n", "This general strategy is applied to all the required data structures, where possible.\n", "\n", "### routes\n", "The `routes` array will contain arrays `[n_trips, n_stops, pt_1st_stop, pt_1st_trip]` where all four values are `int`. To avoid overcomplicating things and try to mimic pointers in python, `pt_1st_stop` and `pt_1st_trip` contain integer indices." ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 15, "metadata": { "lines_to_next_cell": 0 }, "outputs": [], "source": [ "import numpy as np\n", "import pickle\n", "\n", "def pkload(path):\n", " with open(path, 'rb') as f:\n", " obj = pickle.load(f)\n", " return obj" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 16, "metadata": { "lines_to_next_cell": 0 }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(1461, 4)\n" ] }, { "data": { "text/plain": [ - "array([[ 1, 2, 0, 0],\n", - " [ 1, 26, 2, 2],\n", - " [ 1, 8, 28, 28],\n", + "array([[ 1, 26, 0, 0],\n", + " [ 1, 8, 26, 26],\n", + " [ 1, 17, 34, 34],\n", " ...,\n", " [ 1, 3, 15297, 260396],\n", " [ 2, 16, 15300, 260399],\n", " [ 1, 28, 15316, 260431]], dtype=uint32)" ] }, - "execution_count": 3, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "routes = pkload(\"../data/routes_array_cyril.pkl\").astype(np.uint32)\n", "print(routes.shape)\n", "routes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### routeStops\n", "`routeStops` is an array that contains the ordered lists of stops for each route. `pt_1st_stop` in `routes` is required to get to the first stop of the route. is itself an array that contains the sequence of stops for route $r_i$." ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(15344,)\n", "1406\n" ] }, { "data": { "text/plain": [ - "array([ 298, 1295, 1222, ..., 1349, 1042, 549], dtype=uint16)" + "array([1221, 816, 776, ..., 1349, 1037, 552], dtype=uint16)" ] }, - "execution_count": 4, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "routeStops = pkload(\"../data/route_stops_array_cyril.pkl\").astype(np.uint16)\n", "print(routeStops.shape)\n", "print(routeStops.max())\n", "routeStops" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### stopTimes\n", "\n", "The i-th entry in the `stopTimes` array is itself an array which contains the arrival and departure time at a particular stop for a particular trip. `stopTimes` is sorted by routes, and then by trips. We retrieve the index of the first (earliest) trip of the route with the pointer `pt_1st_trip` stored in `routes`. We may use the built-in `numpy` [date and time data structures](https://blog.finxter.com/how-to-work-with-dates-and-times-in-python/). In short, declaring dates and times is done like this: `np.datetime64('YYYY-MM-DDThh:mm')`. Entries with a `NaT` arrival or departure times correspond to beginning and end of trips respectively.\n", "\n", "Note that trips are indexed implicitely in stopTimes, but we decided to change a little bit from the paper and index them according to their parent route instead of giving them an absolute index. It makes things a bit easier when coding the algorithm." ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(260459, 2)\n" ] }, { "data": { "text/plain": [ - "array([['2020-05-22T07:00:00.000000000', '2020-05-22T07:01:00.000000000'],\n", - " ['2020-05-22T07:02:00.000000000', 'NaT'],\n", - " ['2020-05-22T07:00:00.000000000', '2020-05-22T07:00:00.000000000'],\n", + "array([[ 'NaT', '2020-05-23T07:00:00.000000000'],\n", + " ['2020-05-23T07:01:00.000000000', '2020-05-23T07:01:00.000000000'],\n", + " ['2020-05-23T07:02:00.000000000', '2020-05-23T07:02:00.000000000'],\n", " ...,\n", - " ['2020-05-22T07:35:00.000000000', '2020-05-22T07:35:00.000000000'],\n", - " ['2020-05-22T07:36:00.000000000', '2020-05-22T07:36:00.000000000'],\n", - " ['2020-05-22T07:37:00.000000000', 'NaT']],\n", + " ['2020-05-23T07:35:00.000000000', '2020-05-23T07:35:00.000000000'],\n", + " ['2020-05-23T07:36:00.000000000', '2020-05-23T07:36:00.000000000'],\n", + " ['2020-05-23T07:37:00.000000000', 'NaT']],\n", " dtype='datetime64[ns]')" ] }, - "execution_count": 5, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stopTimes = pkload(\"../data/stop_times_array_cyril.pkl\")\n", "print(stopTimes.shape)\n", "stopTimes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`NaT` is the `None` equivalent for `numpy datetime64`." ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[False False]\n" + "[ True False]\n" ] } ], "source": [ "print(np.isnat(stopTimes[0]))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### stopRoutes\n", "\n", "`stopRoutes` contains the routes (as `int`s representing an index in `routes`) associated with each stop. We need the pointer in `stops` to index `stopRoutes` correctly." ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "(15486,)\n" + "(15344,)\n" ] }, { "data": { "text/plain": [ - "array([ 82, 129, 187, ..., 855, 977, 1087], dtype=uint32)" + "array([ 17, 116, 126, ..., 861, 982, 1087], dtype=uint32)" ] }, - "execution_count": 7, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stopRoutes = pkload(\"../data/stop_routes_array_cyril.pkl\").flatten().astype(np.uint32)\n", "print(stopRoutes.shape)\n", "stopRoutes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## transfers\n", "`transfers` is a 2D `np.ndarray` where each entry `[p_j, time]` represents (in seconds) the time it takes to walk from stop p_j to the implicitely given stop p_i.\n", "p_i is given implicitely by the indexing, in conjunction with `stops`. In other words:\n", "`transfers[stops[p_i][2]:stops[p_i][3]]` returns all the footpaths arriving at stop p_i.\n", "\n", "As we cannot store different data types in numpy arras, `time` will have to be converted to `np.timedelta64`, the format used to make differences between `np.datetime.64` variables. We will consider all `time` values as **positive values in seconds**." ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "(6342, 2)\n" + "(6264, 2)\n" ] }, { "data": { "text/plain": [ - "array([[ 0, 8],\n", - " [ 51, 564],\n", - " [ 274, 441],\n", + "array([[ 815, 267],\n", + " [1350, 569],\n", + " [ 63, 470],\n", " ...,\n", - " [1120, 345],\n", - " [1266, 561],\n", - " [1406, 8]], dtype=uint16)" + " [1113, 382],\n", + " [1122, 338],\n", + " [1270, 553]], dtype=uint16)" ] }, - "execution_count": 11, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "transfers = pkload(\"../data/transfer_array_cyril.pkl\").astype(np.uint16) # [:,1:3]\n", + "transfers = pkload(\"../data/transfer_array_cyril.pkl\").astype(np.uint16)\n", "print(transfers.shape)\n", "transfers" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## stops\n", "\n", "`stops` stores the indices in `stopRoutes` and in `transfers` corresponding to each stop.\n", "\n", "`stopRoutes[stops[p][0]:stops[p][1]]` returns the routes serving stop p.\n", "\n", "`transfers[stops[p][2]:stops[p][3]]` returns the footpaths arriving at stop p." ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[ 0 65]\n", - "(1407, 2)\n" + "[ 0 70]\n", + "[0 0]\n", + "(1407, 2)\n", + "[ 0 0 0 70]\n" ] }, { "data": { "text/plain": [ - "array([[ 0, 18, 0, 16],\n", - " [ 18, 29, 16, 18],\n", - " [ 29, 52, 18, 22],\n", + "array([[ 0, 11, 0, 2],\n", + " [ 11, 20, 2, 7],\n", + " [ 20, 38, 7, 22],\n", " ...,\n", - " [15329, 15334, 6322, 6329],\n", - " [15334, 15339, 6329, 6334],\n", - " [15339, 15486, 6334, 6342]], dtype=uint32)" + " [15303, 15334, 6242, 6250],\n", + " [15334, 15339, 6250, 6257],\n", + " [15339, 15344, 6257, 6264]], dtype=uint32)" ] }, - "execution_count": 12, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stops = pkload(\"../data/stops_array_cyril.pkl\")\n", + "print(np.isnan(stops.astype(np.float64)).sum(axis=0))\n", "print(np.equal(stops, None).sum(axis=0))\n", "print(stops.shape)\n", "stops = stops[:,[0,0,1,1]]\n", "# Make column 1 contain the start_index of the next stop in stopRoutes\n", "stops[:-1,1] = stops[1:,0]\n", "stops[-1, 1] = stopRoutes.shape[0]\n", "# Make column 2 contain the start_index of the next stop in stopRoutes\n", - "for i in np.where(np.equal(stops[:,2], None))[0]:\n", + "for i in np.isnan(stops[:,2].astype(np.float64)).nonzero()[0]:\n", " stops[i,2] = stops[i-1,2]\n", + "print(np.isnan(stops.astype(np.float64)).sum(axis=0))\n", "stops[:-1,3] = stops[1:,2]\n", "stops[-1, 3] = transfers.shape[0]\n", "# Convert to int\n", "stops = stops.astype(np.uint32)\n", "stops" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "routes serving stop 0: [ 82 129 187 211 251 302 470 546 558 614 695 801 810 838\n", - " 871 1039 1078 1316]\n", - "stops of route 82: [ 0 48 1209]\n", - "stops of route 129: [ 669 408 445 239 1343 533 510 1373 262 114 48 0]\n", - "stops of route 187: [ 0 48]\n", - "stops of route 211: [1085 1355 1182 1209 48 0]\n", - "stops of route 251: [ 0 48 114 262 1373 510 533 1343 239 445 669]\n", - "stops of route 302: [ 0 48 114 262 1373 510 533 1343 239 445 408 669 848]\n", - "stops of route 470: [ 420 212 1045 1085 1355 1182 1209 48 0]\n", - "stops of route 546: [ 0 48 114 262 1373 510 533 1343 239 445 408 669]\n", - "stops of route 558: [ 848 669 408 445 239 1343 533 510 1373 262 114 48 0]\n", - "stops of route 614: [ 212 1045 1085 1355 1182 1209 48 0]\n", - "stops of route 695: [ 669 445 239 1343 533 510 1373 262 114 48 0]\n", - "stops of route 801: [1182 1209 48 0]\n", - "stops of route 810: [ 0 48 1209 1182 1355 1085 1045 212 420]\n", - "stops of route 838: [ 0 48 1209 1182 1355 1085]\n", - "stops of route 871: [ 510 1373 262 114 48 0]\n", - "stops of route 1039: [ 669 239 1343 533 510 1373 262 114 48 0]\n", - "stops of route 1078: [ 0 48 114 262 1373 510 533 1343 239 445 408]\n", - "stops of route 1316: [ 0 48 114 262 1373 510 533 1343 239 669]\n", - "stop 0 can be reached from stop 0 by walking for 8 seconds.\n", - "stop 0 can be reached from stop 51 by walking for 564 seconds.\n", - "stop 0 can be reached from stop 274 by walking for 441 seconds.\n", - "stop 0 can be reached from stop 375 by walking for 594 seconds.\n", - "stop 0 can be reached from stop 462 by walking for 489 seconds.\n", - "stop 0 can be reached from stop 602 by walking for 232 seconds.\n", - "stop 0 can be reached from stop 616 by walking for 150 seconds.\n", - "stop 0 can be reached from stop 781 by walking for 287 seconds.\n", - "stop 0 can be reached from stop 819 by walking for 497 seconds.\n", - "stop 0 can be reached from stop 880 by walking for 339 seconds.\n", - "stop 0 can be reached from stop 946 by walking for 557 seconds.\n", - "stop 0 can be reached from stop 1033 by walking for 459 seconds.\n", - "stop 0 can be reached from stop 1176 by walking for 277 seconds.\n", - "stop 0 can be reached from stop 1196 by walking for 44 seconds.\n", - "stop 0 can be reached from stop 1249 by walking for 272 seconds.\n", - "stop 0 can be reached from stop 1289 by walking for 460 seconds.\n" + "routes serving stop 0: [ 17 116 126 144 169 250 267 356 573 617 1054]\n", + "stops of route 17: [ 168 1365 504 434 715 454 1236 186 959 81 130 774 284 958\n", + " 815 0 1350 265 780 305 490 16 180 1397]\n", + "stops of route 116: [1397 180 16 490 305 780 265 1350 0 815 958 284 774 130\n", + " 81 959 186 1236 454]\n", + "stops of route 126: [ 0 1350 265 780 490 16 180 1397]\n", + "stops of route 144: [1397 180 16 490 780 265 1350 0 815 958 284 774 130 81\n", + " 959 186 1236 454 715 434 504 1365 168]\n", + "stops of route 169: [ 0 1350 265 780 305 490 16 180 1397]\n", + "stops of route 250: [ 0 815 958 284 774 130 81 959 186 1236 454 715 434 504\n", + " 1365 168]\n", + "stops of route 267: [1397 180 16 490 780 265 1350 0 815 958 284 774 130 81\n", + " 959 186 1236 454]\n", + "stops of route 356: [1397 180 16 490 305 780 265 1350 0 815 958 284 774 130\n", + " 81 959 186 1236 454 715 434 504 1365 168]\n", + "stops of route 573: [ 454 1236 186 959 81 130 774 284 958 815 0 1350 265 780\n", + " 490 16 180 1397]\n", + "stops of route 617: [ 454 1236 186 959 81 130 774 284 958 815 0 1350 265 780\n", + " 305 490 16 180 1397]\n", + "stops of route 1054: [ 168 1365 504 434 715 454 1236 186 959 81 130 774 284 958\n", + " 815 0 1350 265 780 490 16 180 1397]\n", + "stop 0 can be reached from stop 815 by walking for 267 seconds.\n", + "stop 0 can be reached from stop 1350 by walking for 569 seconds.\n" ] } ], "source": [ "p = 0\n", "routes_serving_p = stopRoutes[stops[p][0]:stops[p][1]]\n", "print(\"routes serving stop 0:\", routes_serving_p)\n", "for r in routes_serving_p:\n", " print(\"stops of route {}:\".format(r), routeStops[routes[r][2]:routes[r][2]+routes[r][1]])\n", "for pPrime, walking_seconds in transfers[stops[p][2]:stops[p][3]]:\n", " print(\"stop {} can be reached from stop {} by walking for {} seconds.\".format(p, pPrime, walking_seconds))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Distribution of delays" ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[0. , 0.01501502, 0.03603604, 0.06306306, 0.09009009,\n", " 0.12012012, 0.15015015, 0.18018018, 0.21321321, 0.24624625,\n", " 0.27927928, 0.31231231, 0.34534535, 0.37837838, 0.41141141,\n", " 0.44444444, 0.47747748, 0.51051051, 0.54354354, 0.57657658,\n", " 0.60960961, 0.64264264, 0.67567568, 0.71171171, 0.74774775,\n", " 0.78378378, 0.81981982, 0.85585586, 0.89189189, 0.92792793,\n", " 0.96396396, 1. ],\n", " [0. , 0.01501502, 0.03603604, 0.06306306, 0.09009009,\n", " 0.12012012, 0.15015015, 0.18018018, 0.21321321, 0.24624625,\n", " 0.27927928, 0.31231231, 0.34534535, 0.37837838, 0.41141141,\n", " 0.44444444, 0.47747748, 0.51051051, 0.54354354, 0.57657658,\n", " 0.60960961, 0.64264264, 0.67567568, 0.71171171, 0.74774775,\n", " 0.78378378, 0.81981982, 0.85585586, 0.89189189, 0.92792793,\n", " 0.96396396, 1. ]])" ] }, - "execution_count": 14, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import gzip \n", "with gzip.open(\"../data/join_distribution_cumulative_p_2.pkl.gz\") as distrib_pkl:\n", " distrib_delays = pickle.load(distrib_pkl)\n", " \n", "distrib_delays[0:2]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Relate `stop_id`s and `route_id`s to the integer indices used in the algorithm" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 58, "metadata": {}, "outputs": [ { "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", + " \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", "
indexroute_idstop_id_generaltrip_idstop_idarrival_timedeparture_timestop_sequencestop_namestop_lat...trip_headsigntrip_short_namedirection_iddeparture_first_stoproute_intstop_countstop_introute_descmonotonically_increasing_iddeparture_first_shift_1
9311126-10-j19-18573205Zürich Flughafen, Bahnhof0298
9311226-10-j19-18588553Zürich Flughafen, Fracht01295
93113020186026-13-j19-185762402064.TA.26-13-j19-1.24.H8576240NaT2020-05-23 07:00:005Zürich, Meierhofplatz1122247.402010...Zürich, Albisgütli1831007:00:000261221Tram007:00:00
93114120186126-13-j19-185913532064.TA.26-13-j19-1.24.H85913532020-05-23 07:01:002020-05-23 07:01:006Zürich, Schwert147.399730...Zürich, Albisgütli1831007:00:00026816Tram107:00:00
93115220186226-13-j19-185910392064.TA.26-13-j19-1.24.H85910392020-05-23 07:02:002020-05-23 07:02:007Zürich, Alte Trotte177847.397766...Zürich, Albisgütli1831007:00:00026776Tram207:00:00
320186326-13-j19-185911212064.TA.26-13-j19-1.24.H85911212020-05-23 07:03:002020-05-23 07:03:008Zürich, Eschergutweg47.396270...Zürich, Albisgütli1831007:00:00026307Tram307:00:00
420186426-13-j19-185914172064.TA.26-13-j19-1.24.H85914172020-05-23 07:05:002020-05-23 07:05:009Zürich, Waidfussweg47.395498...Zürich, Albisgütli1831007:00:00026347Tram407:00:00
\n", + "

5 rows × 21 columns

\n", "
" ], "text/plain": [ - " route_id stop_id_general stop_name route_int \\\n", - "93111 26-10-j19-1 8573205 Zürich Flughafen, Bahnhof 0 \n", - "93112 26-10-j19-1 8588553 Zürich Flughafen, Fracht 0 \n", - "93113 26-13-j19-1 8576240 Zürich, Meierhofplatz 1 \n", - "93114 26-13-j19-1 8591353 Zürich, Schwert 1 \n", - "93115 26-13-j19-1 8591039 Zürich, Alte Trotte 1 \n", + " index route_id stop_id_general trip_id stop_id \\\n", + "0 201860 26-13-j19-1 8576240 2064.TA.26-13-j19-1.24.H 8576240 \n", + "1 201861 26-13-j19-1 8591353 2064.TA.26-13-j19-1.24.H 8591353 \n", + "2 201862 26-13-j19-1 8591039 2064.TA.26-13-j19-1.24.H 8591039 \n", + "3 201863 26-13-j19-1 8591121 2064.TA.26-13-j19-1.24.H 8591121 \n", + "4 201864 26-13-j19-1 8591417 2064.TA.26-13-j19-1.24.H 8591417 \n", + "\n", + " arrival_time departure_time stop_sequence \\\n", + "0 NaT 2020-05-23 07:00:00 5 \n", + "1 2020-05-23 07:01:00 2020-05-23 07:01:00 6 \n", + "2 2020-05-23 07:02:00 2020-05-23 07:02:00 7 \n", + "3 2020-05-23 07:03:00 2020-05-23 07:03:00 8 \n", + "4 2020-05-23 07:05:00 2020-05-23 07:05:00 9 \n", + "\n", + " stop_name stop_lat ... trip_headsign trip_short_name \\\n", + "0 Zürich, Meierhofplatz 47.402010 ... Zürich, Albisgütli 1831 \n", + "1 Zürich, Schwert 47.399730 ... Zürich, Albisgütli 1831 \n", + "2 Zürich, Alte Trotte 47.397766 ... Zürich, Albisgütli 1831 \n", + "3 Zürich, Eschergutweg 47.396270 ... Zürich, Albisgütli 1831 \n", + "4 Zürich, Waidfussweg 47.395498 ... Zürich, Albisgütli 1831 \n", + "\n", + " direction_id departure_first_stop route_int stop_count stop_int \\\n", + "0 0 07:00:00 0 26 1221 \n", + "1 0 07:00:00 0 26 816 \n", + "2 0 07:00:00 0 26 776 \n", + "3 0 07:00:00 0 26 307 \n", + "4 0 07:00:00 0 26 347 \n", + "\n", + " route_desc monotonically_increasing_id departure_first_shift_1 \n", + "0 Tram 0 07:00:00 \n", + "1 Tram 1 07:00:00 \n", + "2 Tram 2 07:00:00 \n", + "3 Tram 3 07:00:00 \n", + "4 Tram 4 07:00:00 \n", "\n", - " stop_int \n", - "93111 298 \n", - "93112 1295 \n", - "93113 1222 \n", - "93114 816 \n", - "93115 778 " + "[5 rows x 21 columns]" ] }, - "execution_count": 16, + "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "stop_times_df = pkload(\"../data/stop_times_df.pkl\")[['route_id', 'stop_id_general', 'stop_name', 'route_int', 'stop_int']]\n", + "stop_times_df = pkload(\"../data/stop_times_df_cyril.pkl\")#[['route_id', 'stop_id_general', 'stop_name', 'route_int', 'stop_int']]\n", "stop_times_df.head()" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([8503088, 8502508, 8591190, ..., 8590772, 8588311, 8503509])" + "array([8502508, 8503078, 8503088, ..., 8591173, 8590772, 8503509])" ] }, - "execution_count": 17, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_ids = stop_times_df[['stop_id_general', 'stop_int']].drop_duplicates()\n", "assert np.all(stop_ids == stop_ids.drop_duplicates(subset='stop_int'))\n", "assert np.all(stop_ids == stop_ids.drop_duplicates(subset='stop_id_general'))\n", "stop_ids = stop_ids.sort_values(by='stop_int')['stop_id_general'].to_numpy()\n", "stop_ids" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "922 8590548\n" + "999 8503312\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", "
route_idstop_id_generalstop_nameroute_intstop_int
3773026-759-j19-18590548Dübendorf, Bahnhof Nord1329226406726-9-A-j19-18503312Oberglatt420999
4005626-759-j19-18590548Dübendorf, Bahnhof Nord1659229555326-15-j19-18503312Oberglatt560999
\n", "
" ], "text/plain": [ - " route_id stop_id_general stop_name route_int \\\n", - "37730 26-759-j19-1 8590548 Dübendorf, Bahnhof Nord 132 \n", - "40056 26-759-j19-1 8590548 Dübendorf, Bahnhof Nord 165 \n", - "\n", - " stop_int \n", - "37730 922 \n", - "40056 922 " + " route_id stop_id_general stop_name route_int stop_int\n", + "64067 26-9-A-j19-1 8503312 Oberglatt 420 999\n", + "95553 26-15-j19-1 8503312 Oberglatt 560 999" ] }, - "execution_count": 18, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p = np.random.randint(stops.shape[0])\n", "print(p, stop_ids[p])\n", "stop_times_df[stop_times_df['stop_int'] == p].head(2)" ] }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 33, "metadata": {}, "outputs": [ { - "ename": "ValueError", - "evalue": "Can only compare identically-labeled DataFrame objects", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mroute_ids\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mstop_times_df\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'route_id'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'route_int'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdrop_duplicates\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32massert\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mall\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mroute_ids\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mroute_ids\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdrop_duplicates\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msubset\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'route_int'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;32massert\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mall\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mroute_ids\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mroute_ids\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdrop_duplicates\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msubset\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'route_id'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mroute_ids\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mroute_ids\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msort_values\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mby\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'route_int'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'route_id'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_numpy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mroute_ids\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/opt/conda/lib/python3.7/site-packages/pandas/core/ops/__init__.py\u001b[0m in \u001b[0;36mf\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 837\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_indexed_same\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 838\u001b[0m raise ValueError(\n\u001b[0;32m--> 839\u001b[0;31m \u001b[0;34m\"Can only compare identically-labeled DataFrame objects\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 840\u001b[0m )\n\u001b[1;32m 841\u001b[0m \u001b[0mnew_data\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdispatch_to_series\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mop\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstr_rep\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mValueError\u001b[0m: Can only compare identically-labeled DataFrame objects" + "name": "stdout", + "output_type": "stream", + "text": [ + "(1507, 2) (1461, 2)\n", + "(1507, 2) (249, 2)\n" ] } ], "source": [ "route_ids = stop_times_df[['route_id', 'route_int']].drop_duplicates()\n", - "assert np.all(route_ids == route_ids.drop_duplicates(subset='route_int'))\n", - "assert np.all(route_ids == route_ids.drop_duplicates(subset='route_id'))\n", - "route_ids = route_ids.sort_values(by='route_int')['route_id'].to_numpy()\n", - "route_ids" + "print(route_ids.shape, route_ids.drop_duplicates(subset='route_int').shape)\n", + "print(route_ids.shape, route_ids.drop_duplicates(subset='route_id').shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(1507, 2) (1461, 2)\n", + "(1507, 2) (249, 2)\n" + ] + } + ], + "source": [ + "# assert np.all(route_ids == route_ids.drop_duplicates(subset='route_int'))\n", + "# assert np.all(route_ids == route_ids.drop_duplicates(subset='route_id'))\n", + "# route_ids = route_ids.sort_values(by='route_int')['route_id'].to_numpy()\n", + "# route_ids" ] }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 15, "metadata": {}, "outputs": [ { "ename": "KeyError", - "evalue": "46", + "evalue": "8", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m/opt/conda/lib/python3.7/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 2645\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2646\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2647\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", - "\u001b[0;31mKeyError\u001b[0m: 46", + "\u001b[0;31mKeyError\u001b[0m: 8", "\nDuring handling of the above exception, another exception occurred:\n", "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrandint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mroutes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mroute_ids\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mstop_times_df\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstop_times_df\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'route_int'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrandom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrandint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mroutes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mroute_ids\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mstop_times_df\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstop_times_df\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'route_int'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/opt/conda/lib/python3.7/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 2798\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2799\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2800\u001b[0;31m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2801\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2802\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/opt/conda/lib/python3.7/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 2646\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2647\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2648\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_maybe_cast_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2649\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2650\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mindexer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mindexer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", - "\u001b[0;31mKeyError\u001b[0m: 46" + "\u001b[0;31mKeyError\u001b[0m: 8" ] } ], "source": [ "r = np.random.randint(routes.shape[0])\n", "print(r, route_ids[r])\n", "stop_times_df[stop_times_df['route_int'] == r].head(2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Implementing the reversed Multiple Criteria RAPTOR\n", "\n", "Based on modified version of RAPTOR (reversed RAPTOR), we implement a multiple criteria RAPTOR algorithm.\n", "The optimization criteria are:\n", "- Latest departure\n", "- Highest probability of success of the entire trip\n", "- Lowest number of connections (implicit with the round-based approach)" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "numpy.datetime64('2020-05-11T15:28')" ] }, - "execution_count": 20, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# absolute constants:\n", "\n", "tau_change_platform = np.timedelta64(2, 'm')\n", "np.datetime64('2020-05-11T15:30') - tau_change_platform" ] }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "# helper functions\n", "\n", "def arr_and_dep_time(r, t, offset_p):\n", " \"\"\"This function should not be called directly.\n", " Use arrival_time and departure_time.\n", " In particular, this function relies on \"t is not None\"-\n", " \"\"\"\n", " return stopTimes[routes[r][3] # 1st trip of route\n", " + t * routes[r][1] # offset for the right trip\n", " + offset_p # offset for the right stop\n", " ]\n", "\n", "def arrival_time(r, t, offset_p):\n", " \"\"\"Returns 2000 (instead of 0) if t is None.\n", " Otherwise, returns the arrival time of the t-th trip of route r\n", " at the offset_p-th stop of route r.\n", " trips and stops of route r start at t=0, offset_p=0.\n", " \"\"\"\n", " if t is None:\n", " return np.datetime64('2000-01-01T01:00')\n", " \n", " return arr_and_dep_time(r,t,offset_p)[0] # 0 for arrival time\n", "\n", "def departure_time(r, t, offset_p):\n", " \"\"\"Throws TypeError if t is None.\n", " Otherwise, returns the departure time of the t-th trip of route r\n", " at the offset_p-th stop of route r.\n", " trips and stops of route r start at t=0 & offset_p=0.\n", " \"\"\"\n", " if t is None:\n", " raise TypeError(\"Requested departure time of None trip!\")\n", " \n", " return arr_and_dep_time(r,t,offset_p)[1] # 1 for departure time\n", "\n", "def get_stops(r):\n", " \"\"\"Returns the stops of route r\"\"\"\n", " idx_first_stop = routes[r][2]\n", " return routeStops[idx_first_stop:idx_first_stop+routes[r][1]] # n_stops = routes[r][1] " ] }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "class InstantiationException(Exception):\n", " pass\n", "\n", "class BaseLabel:\n", " \"\"\"An abstract base class for Labels. Do not instantiate.\n", " A label corresponds to a recursive (partial) solution, going\n", " to the target stop from the stop currently under consideration.\n", " \"\"\"\n", " def __init__(self, stop, tau_dep, Pr):\n", " self.stop = stop\n", " self.tau_dep = tau_dep\n", " self.Pr = Pr\n", " \n", " def dominates(self, other):\n", " \"\"\"Returns True if self dominates other, else returns False.\n", " other: another Label instance.\n", " \"\"\"\n", " if self.tau_dep >= other.tau_dep and self.Pr >= other.Pr:\n", " return True\n", " return False\n", " \n", " def print_journey(self):\n", " print(\"Journey begins at stop {stop} at time {tau}, with an \"\n", " \"overall probability of success = {Pr} \\n\".format(\n", " stop = self.stop,\n", " tau = self.tau_dep,\n", " Pr = self.Pr\n", " )\n", " )\n", " self.print_instructions()\n", " \n", " def to_str(self):\n", " s = \"Departure at {0} from stop {1}.\".format(self.tau_dep, self.stop)\n", " return repr(type(self)) + s\n", " \n", " def pprint(self, indent=''):\n", " print(indent, self.to_str())\n", " \n", " def copy(self):\n", " raise InstantiationException(\"class BaseLabel should never \"\n", " \"be instantiated.\"\n", " )\n", "\n", "class ImmutableLabel(BaseLabel):\n", " \"\"\"Base class for immutable Labels\"\"\"\n", " def copy(self):\n", " return self\n", "\n", "class TargetLabel(ImmutableLabel):\n", " \"\"\"A special type of label reserved for the target stop.\"\"\"\n", " def __init__(self, stop, tau_dep):\n", " BaseLabel.__init__(self, stop, tau_dep, 1.)\n", " \n", " def print_instructions(self):\n", " \"\"\"Finish printing instructions for the journey.\"\"\"\n", " print(\"You have arrived at the target stop ({stop}) \"\n", " \"before the target time of {tau}.\".format(\n", " stop=self.stop,\n", " tau=self.tau_dep\n", " ))\n", "\n", "class WalkLabel(ImmutableLabel):\n", " \"\"\"A special type of label for walking connections.\"\"\"\n", " def __init__(self, stop, tau_walk, next_label):\n", " \"\"\"Creat a new WalkLabel instance.\n", " stop: stop where you start walking.\n", " tau_walk: (np.timedelta64) duration of the walk.\n", " next_label: label describing the rest of the trip after walking.\n", " \"\"\"\n", " if isinstance(next_label, WalkLabel):\n", " raise ValueError(\"Cannot chain two consecutive WalkLabels!\")\n", " tau_dep = next_label.tau_dep - tau_walk - tau_change_platform\n", " BaseLabel.__init__(self, stop, tau_dep, next_label.Pr)\n", " self.tau_walk = tau_walk\n", " self.next_label = next_label\n", " \n", " def print_instructions(self):\n", " \"\"\"Recursively print instructions for the whole journey.\"\"\"\n", " print(\"Walk {tau} seconds from stop {p1} to stop {p2}\"\n", " \".\".format(\n", " tau = self.tau_walk.astype(int),\n", " p1 = self.stop,\n", " p2 = self.next_label.stop\n", " ))\n", " self.next_label.print_instructions()\n", "\n", "class RouteLabel(BaseLabel):\n", " \"\"\"A type of label for regular transports.\"\"\"\n", " def __init__(self,\n", " stop,\n", " tau_dep,\n", " r,\n", " t,\n", " next_label,\n", " Pr_connection_success):\n", " \n", " Pr = Pr_connection_success * next_label.Pr\n", " BaseLabel.__init__(self, stop, tau_dep, Pr)\n", " \n", " self.r = r\n", " self.t = t\n", " self.next_label = next_label\n", " self.route_stops = get_stops(r)\n", " self.offset_p = np.where(self.route_stops == stop)[0][0]\n", " # Store Pr_connection_success for self.copy()\n", " self.Pr_connection_success = Pr_connection_success\n", " \n", " def update_stop(self, stop):\n", " self.stop = stop\n", " self.offset_p = self.offset_p - 1\n", " # Sanity check:\n", " assert self.route_stops[self.offset_p] == stop\n", " assert self.offset_p >= 0\n", " self.tau_dep = departure_time(self.r, self.t, self.offset_p)\n", " \n", " def print_instructions(self):\n", " \"\"\"Recursively print instructions for the whole journey.\"\"\"\n", " print(\" \"*4 + \"At stop {stop}, take route {r} at time \"\n", " \"{tau}.\".format(stop=self.stop,\n", " r=self.r,\n", " tau=self.tau_dep\n", " )\n", " )\n", " tau_arr = arrival_time(\n", " self.r,\n", " self.t,\n", " np.where(self.route_stops == self.next_label.stop)\n", " )\n", " print(\" \"*4 + \"Get out at stop {stop} at time {tau}\"\n", " \".\".format(stop=self.next_label.stop, tau=tau_arr)\n", " )\n", " self.next_label.print_instructions()\n", " \n", " def copy(self):\n", " \"\"\"When RouteLabels are merged into the bag of a stop,\n", " they must be copied (because they will subsequently\n", " be changed with self.update_stop()).\n", " \"\"\"\n", " return RouteLabel(self.stop,\n", " self.tau_dep,\n", " self.r,\n", " self.t,\n", " self.next_label,\n", " self.Pr_connection_success\n", " )" ] }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 56, "metadata": {}, "outputs": [], "source": [ "def run_mc_raptor(p_s, p_t, tau_0, Pr_min\n", " , incoherences\n", " ):\n", " \"\"\"Run MC RAPTOR, using the data defined in cells above (stopRoutes etc.).\n", " Inputs:\n", " p_s: source stop\n", " p_t: target stop\n", " tau_0: latest acceptable arrival time\n", " Pr_min: minimum acceptable probability of success\n", " Output:\n", " bags_p_s: bags_p_s[k] contains the pareto set of non-dominated journeys\n", " from p_s to p_t that use at most k different trips (i.e,\n", " getting in at most k different vehicles), under the given\n", " constraints:\n", " 1. Each journey must succeed with a probability\n", " greater or equal to Pr_min.\n", " 2. The journey is a success if and only if all individual\n", " connections succeed, including the user's appointment\n", " in p_t at tau_0.\n", " 3. A connection succeeds if, and only if, the user reaches\n", " the platform before or on the scheduled departure time\n", " (allowing some time to change platforms)\n", " Non-dominated:\n", " A journey J1 is *dominated* by another journey J2, if\n", " J2 departs no earlier than J1 AND the probability of\n", " success of J2 is no less than that of J1.\n", " Pareto set:\n", " Each bag in bags_p_s contains only journeys that are not\n", " dominated by any other possible journey. Such a collection\n", " of non-dominated solutions is called a *Pareto set*.\n", " \n", " Each journey is represented as a Label that forms the start of a chain.\n", " The journey can be reconstructed by calling label.print_journey().\n", " \"\"\"\n", "# initialization\n", " # For each route and for each label at each stop p, we will look at the n latest\n", " # trips until we find a trip for which the individual connection at stop p\n", " # succeeds with a probability at least equal to Pr_threshold.\n", " # Under some reasonable assumptions, setting Pr_threshold = Pr_min**(1/k)\n", " # guarantees that we will find a solution, if a solution exists involving at\n", " # most k connections (including the user's appointment in p_t at tau_0).\n", " Pr_threshold = Pr_min**(0.1)\n", " \n", "\n", " # Initialize empty bags for each stop for round 0:\n", " n_stops = stops.shape[0]\n", " bags = [\n", " [\n", " [] # an empty bag\n", " for _ in range(n_stops)] # one empty bag per stop\n", " ]\n", "\n", " # Create a TargetLabel for p_t, and mark p_t\n", " bags[0][p_t].append(TargetLabel(p_t, tau_0))\n", " marked = {p_t}\n", "\n", "# Define bag operations (they depend on p_s and Pr_min for target pruning):\n", " def update_bag(bag, label, k):\n", " \"\"\"Add label to bag and remove dominated labels.\n", " bag is altered in-place.\n", "\n", " k: Round number, used for target pruning.\n", "\n", " returns: Boolean indicating whether bag was altered.\n", " \"\"\"\n", " # Apply the Pr_min constraint to label:\n", " if label.Pr < Pr_min:\n", " return False\n", "\n", " # Prune label if it is dominated by bags[k][p_s]:\n", " for L_star in bags[k][p_s]:\n", " if L_star.dominates(label):\n", " return False\n", "\n", " # Otherwise, merge label into bag1\n", " changed = False\n", " for L_old in bag:\n", " if L_old.dominates(label):\n", " return changed\n", " if label.dominates(L_old):\n", " bag.remove(L_old)\n", " changed = True\n", " bag.append(label.copy())\n", " return True\n", "\n", " def merge_bags(bag1, bag2, k):\n", " \"\"\"Merge bag2 into bag1 in-place.\n", " k: Round number, used for target pruning.\n", " returns: Boolean indicating whether bag was altered.\n", " \"\"\"\n", " changed = False\n", " for label in bag2:\n", " changed = changed or update_bag(bag1, label, k)\n", " return changed\n", " \n", "# Define the footpaths-checking function (depends on update_bag)\n", " def check_footpaths(bags, marked, k):\n", " \"\"\"Modify bags and marked in-place to account for foot-paths.\"\"\"\n", " q = []\n", " for p in marked:\n", " for pPrime, delta_seconds in transfers[stops[p][2]:stops[p][3]]:\n", " q.append((p, pPrime, delta_seconds))\n", " for p, pPrime, delta_seconds in q:\n", " for L_k in bags[k][p]:\n", " # We do not allow two consecutive walking trips\n", " if not isinstance(L_k, WalkLabel):\n", " L_new = WalkLabel(pPrime, np.timedelta64(delta_seconds, 's'), L_k)\n", " if update_bag(bags[k][pPrime], L_new, k):\n", " marked.add(pPrime)\n", "\n", "# main loop\n", " indent= ' '*4\n", "\n", " k = 0\n", " # Check footpaths leading to p_t at k=0:\n", " check_footpaths(bags, marked, k)\n", " while True:\n", " k += 1 # k=1 at fist round, as it should.\n", "\n", " # Instead of using best bags, carry over the bags from last round.\n", " # if len(bags <= k):\n", "\n", " bags.append([bags[-1][p].copy() for p in range(n_stops)])\n", "\n", " print('\\n******************************STARTING round k={}******************************'.format(k))\n", " # accumulate routes serving marked stops from previous rounds\n", " q = []\n", " print('Marked stops at the start of the round: {}'.format(marked))\n", " for p in marked:\n", " for r in stopRoutes[stops[p][0]:stops[p][1]]: # foreach route r serving p\n", " append_r_p = True\n", " for idx, (rPrime, pPrime) in enumerate(q): # is there already a stop from the same route in q ?\n", " if rPrime == r:\n", " append_r_p = False\n", " p_pos_in_r = np.where(get_stops(r) == p)\n", " pPrime_pos_in_r = np.where(get_stops(r) == pPrime)\n", " if p_pos_in_r > pPrime_pos_in_r:\n", " q[idx] = (r, p) # substituting (rPrime, pPrime) by (r, p)\n", " if append_r_p:\n", " q.append((r, p))\n", " marked.clear() # unmarking all stops\n", + "# print(\"Queue:\", q)\n", "\n", "# print('Queue before traversing each route: {}'.format(q))\n", " # traverse each route\n", " for (r, p) in q:\n", "# print('\\n****TRAVERSING ROUTE r={0} from stop p={1}****'.format(r, p))\n", " B_route = [] # new empty route bag\n", "\n", " # we traverse the route backwards (starting at p, not from the end of the route)\n", " stops_of_current_route = get_stops(r)\n", "# print('Stops of current route:', stops_of_current_route)\n", " offset_p = np.asarray(stops_of_current_route == p).nonzero()[0]\n", " if offset_p.size < 1:\n", " if not p in incoherences:\n", " incoherences[p] = set()\n", " incoherences[p].add(r)\n", "# print(\"WARNING: route {r} is said to serve stop {p} in stopRoutes, but stop {p} \"\n", "# \"is not included as a stop of route {r} in routeStops...\".format(p=p, r=r))\n", " offset_p = -1\n", " else:\n", " offset_p = offset_p[0]\n", " for offset_p_i in range(offset_p, -1, -1):\n", " p_i = stops_of_current_route[offset_p_i]\n", "# print('\\n\\n'+indent+\"p_i: {}\".format(p_i))\n", "\n", " # Update the labels of the route bag:\n", " for L in B_route:\n", " L.update_stop(p_i)\n", "\n", " # Merge B_route into bags[k][p_i]\n", " if merge_bags(bags[k][p_i], B_route, k):\n", + "# print(\"marking stop\", p_i)\n", " marked.add(p_i)\n", "\n", " # Can we step out of a later trip at p_i ?\n", " # This is only possible if we already know a way to get from p_i to p_t in < k vehicles\n", " # (i.e., if there is at least one label in bags[k][p_i])\n", " for L_k in bags[k][p_i]:\n", " # Note that k starts at 1 and bags[0][p_t] contains a TargetLabel.\n", "# print('\\n'+indent+'----scanning arrival times for route r={0} at stop p_i={1}----'.format(r, p_i))\n", "\n", " # We check the trips from latest to earliest\n", " for t in range(routes[r][0]-1, -1, -1): # n_trips = routes[r][0]\n", " # Does t_r arrive early enough for us to make the rest \n", " # of the journey from here (tau[k-1][p_i])?\n", " tau_arr = arrival_time(r, t, offset_p_i)\n", "# print(indent+'arrival time: ', tau_arr)\n", " if tau_arr <= L_k.tau_dep - tau_change_platform:\n", "\n", " max_delay = L_k.tau_dep - tau_arr - tau_change_platform\n", " max_delay_int = min(max_delay.astype('timedelta64[m]').astype('int'), 30)\n", " \n", " idx_stop_time = routes[r][3] + t * routes[r][1] + offset_p_i \n", " \n", " Pr_connection = distrib_delays[idx_stop_time, max_delay_int + 1]\n", - " #Pr_connection = 1 # This is a placeholder.\n", - " \n", + "# print(Pr_connection)\n", " L_new = RouteLabel(p_i,\n", " departure_time(r, t, offset_p_i),\n", " r,\n", " t,\n", " L_k,\n", " Pr_connection\n", " )\n", " update_bag(B_route, L_new, k)#:\n", "# print(indent+\"Explored connection from\")\n", "# L_new.pprint(indent*2)\n", "# print(indent+\"to\")\n", "# L_k.pprint(indent*2)\n", "\n", " # We don't want to add a label for every trip that's earlier than tau_dep.\n", " # Instead, we stop once we've found a trip that's safe enough.\n", " if Pr_connection > Pr_threshold:\n", " break\n", " \n", + " print(marked)\n", " # Look at foot-paths (bags and marked are altered in-place):\n", " check_footpaths(bags, marked, k)\n", - " \n", + " print(marked)\n", " # stopping criteria (1: reached equilibrium, 2: Found a solution with k-2 trips)\n", " if not marked:\n", " print(\"\\n\" + \"*\"*15 + \" THE END \" + \"*\"*15)\n", " print(\"Equilibrium reached. The end.\")\n", " break\n", "# if k > 10:\n", "# break\n", " if k>3:\n", " if bags[k-3][p_s]:\n", " print(\"\\n\" + \"*\"*15 + \" THE END \" + \"*\"*15)\n", " print(\"There is a solution with {0} connections. We shall not \"\n", " \"search for solutions with {1} or more connections\"\n", " \".\".format(k-4, k)\n", " )\n", " break\n", - " return [bags[K][p_s] for K in range(len(bags))], bags" + " return [bags[K][p_s] for K in range(len(bags))], bags\n", + "\n", + "def time_sorted_unique(bags_p):\n", + " \"\"\"Input: list of bags, e.g. for one stop and various k.\n", + " It is assumed that Pr >= Pr_min for each label.\n", + " Output: A np.array of unique labels, sorted by decreasing\n", + " departure time.\n", + " \"\"\"\n", + " res = set()\n", + " for bag in bags_p:\n", + " for label in bag:\n", + " set.add(label)\n", + " res = np.array(list(res))\n", + " return res[np.argsort([label.tau_dep for label in res])[::-1]]\n", + "\n", + "def print_solutions(bags_p):\n", + " for i, label in enumerate(time_sorted_unique(bags_p)):\n", + " print('\\n'*2,'-'*10, 'OPTION', i+1)\n", + " label.print_journey()" ] }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 57, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1033\n", "\n", "******************************STARTING round k=1******************************\n", - "Marked stops at the start of the round: {1029, 1031, 1032, 1033, 1034, 1128, 1129, 1130, 1131, 1132, 1136, 1137}\n", - "\n", - "******************************STARTING round k=2******************************\n", - "Marked stops at the start of the round: {1024, 1025, 1026, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 688, 689, 690, 691, 1125, 1126, 1127, 360, 1129, 1130, 1128, 108, 1133, 1134, 1135, 1136, 1137, 1131, 1021, 1022, 1023}\n", - "\n", - "******************************STARTING round k=3******************************\n", - "Marked stops at the start of the round: {1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 8, 1033, 10, 11, 1034, 1032, 1035, 536, 26, 27, 108, 1127, 554, 1081, 587, 588, 91, 92, 102, 103, 1128, 104, 1129, 1131, 1132, 1130, 107, 1133, 106, 105, 109, 1136, 116, 1137, 1134, 1135, 120, 121, 138, 139, 141, 142, 143, 144, 152, 153, 154, 670, 672, 673, 683, 684, 685, 686, 687, 173, 174, 175, 691, 692, 176, 689, 690, 1232, 721, 1234, 723, 724, 733, 737, 226, 738, 229, 232, 233, 749, 750, 754, 1270, 768, 771, 772, 773, 262, 263, 264, 265, 780, 781, 273, 274, 275, 787, 788, 278, 279, 280, 281, 792, 795, 796, 1320, 820, 826, 315, 827, 318, 840, 841, 332, 333, 334, 844, 845, 846, 1364, 1378, 355, 356, 359, 360, 361, 1385, 1386, 434, 442, 493, 1007, 1008, 1009, 1010, 1011, 1018, 1019, 1020, 1021, 1022, 1023}\n", - "\n", - "******************************STARTING round k=4******************************\n", - "Marked stops at the start of the round: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 31, 42, 43, 44, 45, 46, 48, 49, 50, 55, 60, 61, 68, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 161, 162, 163, 164, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 193, 206, 207, 208, 212, 218, 219, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 240, 241, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 355, 356, 357, 358, 359, 360, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 376, 387, 392, 393, 399, 400, 401, 402, 408, 409, 410, 411, 416, 418, 419, 423, 424, 428, 431, 432, 433, 434, 440, 441, 442, 443, 444, 445, 449, 453, 454, 455, 464, 465, 474, 478, 479, 480, 481, 484, 485, 486, 487, 490, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 535, 536, 537, 538, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 562, 563, 572, 573, 574, 581, 582, 583, 584, 585, 586, 587, 588, 589, 593, 594, 600, 617, 618, 619, 620, 621, 622, 631, 633, 634, 641, 671, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 689, 690, 692, 697, 715, 716, 717, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 786, 787, 788, 789, 790, 791, 792, 794, 795, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 893, 894, 896, 913, 918, 919, 924, 944, 945, 947, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 978, 979, 980, 982, 986, 987, 988, 992, 993, 998, 999, 1000, 1001, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1091, 1123, 1124, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1142, 1143, 1144, 1145, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1189, 1197, 1199, 1209, 1210, 1213, 1216, 1217, 1218, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1264, 1265, 1266, 1267, 1270, 1271, 1272, 1277, 1278, 1282, 1283, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1330, 1331, 1334, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1351, 1357, 1358, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1394, 1397, 1398, 1399}\n", - "\n", - "******************************STARTING round k=5******************************\n", - "Marked stops at the start of the round: {0, 1, 2, 3, 4, 5, 6, 7, 9, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 31, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 60, 61, 62, 63, 64, 65, 66, 68, 89, 90, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 108, 110, 111, 112, 113, 114, 115, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 139, 140, 145, 146, 147, 148, 149, 150, 151, 155, 156, 157, 158, 159, 161, 162, 163, 164, 166, 167, 169, 170, 171, 172, 177, 178, 179, 180, 181, 182, 183, 184, 185, 193, 206, 207, 208, 212, 218, 219, 224, 225, 227, 228, 229, 231, 234, 236, 240, 241, 253, 254, 255, 256, 257, 258, 259, 260, 261, 266, 267, 268, 269, 270, 271, 272, 274, 275, 276, 277, 278, 279, 280, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 303, 304, 307, 308, 309, 310, 311, 312, 313, 314, 316, 317, 319, 320, 321, 322, 323, 326, 327, 328, 329, 330, 331, 332, 333, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 357, 358, 360, 362, 363, 364, 365, 366, 367, 392, 399, 400, 401, 402, 408, 409, 410, 416, 418, 419, 423, 424, 428, 429, 430, 431, 432, 440, 441, 443, 444, 445, 449, 453, 454, 455, 478, 479, 480, 481, 490, 494, 495, 496, 502, 503, 504, 505, 506, 507, 510, 512, 513, 514, 519, 520, 521, 522, 526, 527, 528, 537, 544, 562, 563, 589, 593, 594, 600, 617, 618, 619, 620, 621, 622, 631, 689, 690, 697, 712, 713, 714, 715, 716, 717, 719, 720, 721, 722, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 751, 752, 753, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 769, 770, 774, 775, 776, 777, 778, 779, 782, 783, 784, 785, 786, 789, 790, 791, 793, 794, 801, 802, 804, 805, 806, 807, 808, 809, 810, 811, 814, 815, 816, 817, 818, 819, 826, 827, 838, 846, 849, 850, 862, 863, 864, 865, 866, 867, 868, 869, 873, 878, 879, 880, 881, 882, 883, 913, 918, 919, 944, 945, 947, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 976, 977, 978, 979, 980, 981, 982, 986, 987, 988, 990, 991, 992, 993, 998, 999, 1000, 1001, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1021, 1022, 1023, 1024, 1025, 1026, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1091, 1099, 1100, 1101, 1108, 1109, 1110, 1111, 1112, 1123, 1124, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1142, 1143, 1144, 1145, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1178, 1179, 1180, 1181, 1182, 1185, 1189, 1197, 1199, 1209, 1210, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1264, 1265, 1266, 1267, 1278, 1282, 1283, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1319, 1321, 1322, 1323, 1324, 1330, 1331, 1332, 1334, 1337, 1339, 1340, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1351, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1365, 1366, 1367, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1386, 1387, 1388, 1390, 1391, 1394, 1397, 1398, 1399}\n", - "\n", - "******************************STARTING round k=6******************************\n", - "Marked stops at the start of the round: {6, 9, 17, 18, 19, 20, 25, 31, 46, 47, 55, 102, 108, 114, 121, 122, 123, 124, 125, 131, 132, 133, 134, 135, 136, 137, 139, 140, 145, 146, 147, 148, 149, 150, 151, 159, 162, 163, 164, 206, 207, 212, 227, 228, 229, 230, 231, 234, 253, 254, 255, 256, 257, 259, 260, 261, 266, 267, 268, 269, 270, 271, 272, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 303, 304, 305, 306, 307, 308, 309, 312, 313, 316, 317, 325, 326, 327, 328, 329, 330, 331, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 360, 432, 440, 441, 443, 444, 445, 453, 454, 455, 502, 503, 510, 521, 522, 537, 589, 593, 594, 600, 617, 618, 619, 620, 622, 634, 689, 690, 712, 715, 716, 717, 721, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 739, 740, 741, 742, 743, 744, 745, 746, 748, 751, 752, 753, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 769, 770, 774, 775, 776, 777, 778, 779, 782, 783, 784, 785, 786, 790, 793, 794, 805, 807, 808, 809, 814, 815, 816, 817, 862, 873, 879, 880, 881, 882, 894, 953, 958, 976, 977, 989, 1000, 1012, 1013, 1014, 1015, 1016, 1017, 1019, 1021, 1022, 1023, 1024, 1025, 1026, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1039, 1040, 1041, 1042, 1043, 1045, 1046, 1071, 1072, 1075, 1076, 1077, 1078, 1079, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1158, 1159, 1162, 1163, 1164, 1165, 1191, 1192, 1193, 1216, 1217, 1218, 1219, 1228, 1229, 1230, 1231, 1232, 1233, 1235, 1236, 1237, 1238, 1240, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1264, 1265, 1266, 1267, 1273, 1274, 1275, 1276, 1286, 1287, 1288, 1289, 1290, 1291, 1293, 1294, 1295, 1303, 1305, 1306, 1307, 1308, 1309, 1310, 1312, 1319, 1321, 1330, 1331, 1332, 1339, 1340, 1342, 1343, 1344, 1347, 1348, 1350, 1351, 1357, 1358, 1361, 1365, 1366, 1367, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1383, 1384, 1389, 1403}\n", - "\n", - "******************************STARTING round k=7******************************\n", - "Marked stops at the start of the round: {1024, 1025, 1026, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1040, 1042, 1046, 1229, 721, 1076, 1077, 1078, 1079, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 729, 730, 731, 732, 102, 1127, 733, 1129, 1130, 1128, 1131, 1132, 108, 1133, 1136, 1137, 1134, 1135, 227, 122, 123, 124, 125, 228, 737, 229, 131, 132, 133, 230, 136, 137, 1162, 139, 140, 1163, 1161, 1164, 231, 145, 146, 147, 148, 149, 150, 151, 1251, 159, 162, 163, 164, 689, 690, 1361, 1217, 1218, 1216, 1225, 715, 716, 717, 1230, 1231, 1232, 1233, 1228, 1235, 1236, 1237, 1238, 725, 726, 727, 728, 1243, 1244, 1245, 734, 735, 736, 1246, 1250, 739, 1252, 1253, 1254, 741, 742, 740, 234, 743, 744, 745, 1255, 751, 1264, 1265, 1266, 1267, 753, 752, 755, 756, 760, 761, 762, 763, 757, 253, 254, 255, 765, 769, 770, 764, 260, 261, 1287, 1288, 1289, 266, 267, 268, 269, 270, 271, 272, 1290, 1291, 277, 278, 279, 280, 791, 282, 283, 284, 1309, 286, 285, 1308, 289, 290, 291, 292, 293, 294, 1315, 814, 815, 816, 817, 304, 309, 1337, 1339, 1340, 1342, 1343, 1347, 1348, 326, 327, 328, 329, 330, 331, 1351, 1357, 1358, 335, 337, 338, 339, 340, 341, 342, 343, 344, 345, 1365, 1367, 862, 1375, 1376, 1377, 360, 873, 1389, 879, 880, 881, 882, 1303, 432, 440, 441, 953, 443, 444, 445, 958, 454, 455, 1021, 1022, 1023}\n", - "\n", - "******************************STARTING round k=8******************************\n", - "Marked stops at the start of the round: {1024, 1025, 1026, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1076, 1078, 1079, 1080, 1082, 1083, 1084, 1085, 1086, 1087, 102, 1127, 1128, 1129, 1130, 1131, 1132, 108, 1133, 1134, 1136, 1137, 114, 1135, 122, 135, 136, 137, 1162, 139, 1164, 140, 1163, 1161, 145, 146, 147, 148, 149, 162, 163, 164, 689, 690, 715, 1228, 1229, 717, 1231, 1232, 1233, 716, 721, 1236, 1243, 1244, 1245, 734, 735, 733, 736, 1250, 1251, 1252, 741, 742, 743, 744, 227, 228, 230, 1255, 231, 229, 751, 752, 1265, 753, 755, 756, 757, 1264, 760, 761, 762, 763, 764, 765, 261, 1287, 1288, 1289, 266, 267, 268, 269, 270, 271, 272, 1290, 1291, 277, 278, 279, 280, 1303, 282, 283, 284, 1309, 285, 286, 289, 290, 1321, 1324, 814, 815, 816, 817, 1337, 1342, 1343, 1348, 1350, 1351, 330, 1357, 1358, 1361, 338, 339, 340, 341, 342, 343, 344, 345, 1367, 1377, 360, 432, 440, 441, 953, 443, 444, 445, 454, 1021, 1022, 1023}\n", - "\n", - "******************************STARTING round k=9******************************\n", - "Marked stops at the start of the round: {1024, 1025, 1026, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1078, 1079, 1082, 1083, 1084, 1085, 102, 1127, 1128, 1129, 1130, 1131, 1132, 108, 1133, 1134, 1136, 1137, 1135, 122, 1162, 139, 140, 145, 146, 147, 162, 163, 164, 689, 690, 712, 713, 714, 715, 716, 717, 1225, 1231, 1232, 1233, 721, 1244, 1245, 734, 735, 733, 736, 1250, 227, 228, 741, 229, 1251, 231, 751, 752, 753, 1264, 755, 756, 757, 1265, 760, 761, 762, 763, 764, 765, 261, 1288, 1289, 266, 267, 268, 269, 270, 271, 1291, 1290, 277, 278, 279, 280, 1303, 282, 283, 284, 285, 286, 290, 817, 1337, 1342, 1343, 1348, 1350, 1351, 1357, 1358, 338, 339, 340, 341, 342, 343, 344, 345, 1367, 360, 432, 440, 953, 441, 443, 444, 445, 955, 957, 453, 454, 1021, 1022, 1023}\n", - "\n", - "******************************STARTING round k=10******************************\n", - "Marked stops at the start of the round: {1024, 1025, 1026, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1082, 1083, 1084, 1085, 102, 1127, 1128, 1129, 1130, 1131, 1132, 108, 1133, 1134, 1136, 1137, 1135, 122, 162, 163, 164, 689, 690, 717, 1231, 1233, 721, 1244, 1245, 734, 735, 733, 736, 1250, 1251, 227, 228, 231, 1264, 1265, 760, 761, 762, 763, 764, 765, 1288, 1289, 1290, 1291, 278, 279, 1303, 283, 284, 285, 1343, 1350, 1351, 1358, 341, 342, 343, 344, 345, 1367, 360, 432, 440, 441, 443, 445, 1021, 1022, 1023}\n", - "\n", - "******************************STARTING round k=11******************************\n", - "Marked stops at the start of the round: {1024, 1025, 102, 1026, 1028, 1029, 1030, 1031, 1032, 1033, 1290, 1034, 1035, 1021, 1303, 162, 163, 164, 689, 690, 440, 441, 1082, 1083, 1350, 717, 721, 345, 733, 734, 735, 736, 1250, 1251, 122, 1127, 1128, 1129, 1130, 1131, 1132, 108, 360, 231, 1136, 1137, 1264, 1265, 1133, 1134, 1135, 760, 761, 762, 763, 764, 765, 1022, 1023}\n" + "Marked stops at the start of the round: {2, 616, 1033, 1290, 1196, 272, 785, 880, 947, 820, 1173, 1268, 1080, 602, 1404, 543}\n" + ] + }, + { + "ename": "IndexError", + "evalue": "index 260445 is out of bounds for axis 0 with size 245738", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mincoherences\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m bags_p_s, bags = run_mc_raptor(p_s, p_t, tau_0, Pr_min\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0;34m,\u001b[0m \u001b[0mincoherences\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10\u001b[0m )\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36mrun_mc_raptor\u001b[0;34m(p_s, p_t, tau_0, Pr_min, incoherences)\u001b[0m\n\u001b[1;32m 194\u001b[0m \u001b[0midx_stop_time\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mroutes\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mt\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0mroutes\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0moffset_p_i\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 195\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 196\u001b[0;31m \u001b[0mPr_connection\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdistrib_delays\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0midx_stop_time\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmax_delay_int\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 197\u001b[0m \u001b[0;31m# print(Pr_connection)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 198\u001b[0m L_new = RouteLabel(p_i,\n", + "\u001b[0;31mIndexError\u001b[0m: index 260445 is out of bounds for axis 0 with size 245738" ] } ], "source": [ "p_s = 1000 # start stop\n", "p_t = np.random.randint(stops.shape[0]) # target stop\n", "p_t = 1033\n", "print(p_t)\n", - "tau_0 = np.datetime64('2020-05-21T17:30') # arrival time\n", + "tau_0 = np.datetime64('2020-05-23T17:30') # arrival time\n", "Pr_min = 0.9\n", "incoherences = {}\n", "bags_p_s, bags = run_mc_raptor(p_s, p_t, tau_0, Pr_min\n", " , incoherences\n", " )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "incoherences" ] }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 49, "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n", - " ---------- OPTION 1\n", - "Journey begins at stop 1000 at time 2020-05-21T15:42:00.000000000, with an overall probability of success = 0.9976744186046511 \n", - "\n", - " At stop 1000, take route 640 at time 2020-05-21T15:42:00.000000000.\n", - " Get out at stop 493 at time [['2020-05-21T15:47:00.000000000' '2020-05-21T15:48:00.000000000']].\n", - "Walk 121 seconds from stop 493 to stop 11.\n", - " At stop 11, take route 38 at time 2020-05-21T16:01:00.000000000.\n", - " Get out at stop 108 at time [['2020-05-21T16:35:00.000000000' 'NaT']].\n", - "Walk 14 seconds from stop 108 to stop 689.\n", - " At stop 689, take route 387 at time 2020-05-21T16:57:00.000000000.\n", - " Get out at stop 1034 at time [['2020-05-21T17:04:00.000000000' 'NaT']].\n", - "Walk 267 seconds from stop 1034 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 2\n", - "Journey begins at stop 1000 at time 2020-05-21T15:53:10.000000000, with an overall probability of success = 0.9975903614457831 \n", - "\n", - "Walk 230 seconds from stop 1000 to stop 169.\n", - " At stop 169, take route 98 at time 2020-05-21T15:59:00.000000000.\n", - " Get out at stop 109 at time [['2020-05-21T16:27:00.000000000' 'NaT']].\n", - " At stop 109, take route 77 at time 2020-05-21T16:35:00.000000000.\n", - " Get out at stop 108 at time [['2020-05-21T16:39:00.000000000' '2020-05-21T16:39:00.000000000']].\n", - "Walk 14 seconds from stop 108 to stop 689.\n", - " At stop 689, take route 387 at time 2020-05-21T16:57:00.000000000.\n", - " Get out at stop 1034 at time [['2020-05-21T17:04:00.000000000' 'NaT']].\n", - "Walk 267 seconds from stop 1034 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 3\n", - "Journey begins at stop 1000 at time 2020-05-21T15:53:51.000000000, with an overall probability of success = 0.9952153110047847 \n", - "\n", - "Walk 69 seconds from stop 1000 to stop 177.\n", - " At stop 177, take route 105 at time 2020-05-21T15:57:00.000000000.\n", - " Get out at stop 8 at time [['2020-05-21T16:08:00.000000000' '2020-05-21T16:09:00.000000000']].\n", - " At stop 8, take route 38 at time 2020-05-21T16:15:00.000000000.\n", - " Get out at stop 108 at time [['2020-05-21T16:35:00.000000000' 'NaT']].\n", - "Walk 14 seconds from stop 108 to stop 689.\n", - " At stop 689, take route 387 at time 2020-05-21T16:57:00.000000000.\n", - " Get out at stop 1034 at time [['2020-05-21T17:04:00.000000000' 'NaT']].\n", - "Walk 267 seconds from stop 1034 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 4\n", - "Journey begins at stop 1000 at time 2020-05-21T15:39:22.000000000, with an overall probability of success = 1.0 \n", - "\n", - "Walk 158 seconds from stop 1000 to stop 520.\n", - " At stop 520, take route 211 at time 2020-05-21T15:44:00.000000000.\n", - " Get out at stop 153 at time [['2020-05-21T15:54:00.000000000' 'NaT']].\n", - "Walk 72 seconds from stop 153 to stop 10.\n", - " At stop 10, take route 38 at time 2020-05-21T16:06:00.000000000.\n", - " Get out at stop 108 at time [['2020-05-21T16:35:00.000000000' 'NaT']].\n", - "Walk 14 seconds from stop 108 to stop 689.\n", - " At stop 689, take route 387 at time 2020-05-21T16:57:00.000000000.\n", - " Get out at stop 1034 at time [['2020-05-21T17:04:00.000000000' 'NaT']].\n", - "Walk 267 seconds from stop 1034 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 5\n", - "Journey begins at stop 1000 at time 2020-05-21T15:54:00.000000000, with an overall probability of success = 0.9787358674326366 \n", - "\n", - " At stop 1000, take route 399 at time 2020-05-21T15:54:00.000000000.\n", - " Get out at stop 154 at time [['2020-05-21T16:03:00.000000000' '2020-05-21T16:03:00.000000000']].\n", - "Walk 297 seconds from stop 154 to stop 10.\n", - " At stop 10, take route 125 at time 2020-05-21T16:21:00.000000000.\n", - " Get out at stop 108 at time [['2020-05-21T16:48:00.000000000' '2020-05-21T16:50:00.000000000']].\n", - "Walk 125 seconds from stop 108 to stop 690.\n", - " At stop 690, take route 454 at time 2020-05-21T17:16:00.000000000.\n", - " Get out at stop 1129 at time [['2020-05-21T17:17:00.000000000' '2020-05-21T17:17:00.000000000']].\n", - "Walk 283 seconds from stop 1129 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 6\n", - "Journey begins at stop 1000 at time 2020-05-21T16:11:00.000000000, with an overall probability of success = 0.9558334526412131 \n", - "\n", - " At stop 1000, take route 640 at time 2020-05-21T16:11:00.000000000.\n", - " Get out at stop 493 at time [['2020-05-21T16:17:00.000000000' '2020-05-21T16:17:00.000000000']].\n", - "Walk 121 seconds from stop 493 to stop 11.\n", - " At stop 11, take route 38 at time 2020-05-21T16:31:00.000000000.\n", - " Get out at stop 108 at time [['2020-05-21T17:05:00.000000000' 'NaT']].\n", - "Walk 125 seconds from stop 108 to stop 690.\n", - " At stop 690, take route 454 at time 2020-05-21T17:16:00.000000000.\n", - " Get out at stop 1129 at time [['2020-05-21T17:17:00.000000000' '2020-05-21T17:17:00.000000000']].\n", - "Walk 283 seconds from stop 1129 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 7\n", - "Journey begins at stop 1000 at time 2020-05-21T16:08:51.000000000, with an overall probability of success = 0.975688414785413 \n", - "\n", - "Walk 69 seconds from stop 1000 to stop 177.\n", - " At stop 177, take route 104 at time 2020-05-21T16:12:00.000000000.\n", - " Get out at stop 8 at time [['2020-05-21T16:23:00.000000000' '2020-05-21T16:28:00.000000000']].\n", - " At stop 8, take route 125 at time 2020-05-21T16:30:00.000000000.\n", - " Get out at stop 108 at time [['2020-05-21T16:48:00.000000000' '2020-05-21T16:50:00.000000000']].\n", - "Walk 125 seconds from stop 108 to stop 690.\n", - " At stop 690, take route 454 at time 2020-05-21T17:16:00.000000000.\n", - " Get out at stop 1129 at time [['2020-05-21T17:17:00.000000000' '2020-05-21T17:17:00.000000000']].\n", - "Walk 283 seconds from stop 1129 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 8\n", - "Journey begins at stop 1000 at time 2020-05-21T16:23:51.000000000, with an overall probability of success = 0.9452780110768056 \n", - "\n", - "Walk 69 seconds from stop 1000 to stop 177.\n", - " At stop 177, take route 105 at time 2020-05-21T16:27:00.000000000.\n", - " Get out at stop 10 at time [['2020-05-21T16:29:00.000000000' '2020-05-21T16:30:00.000000000']].\n", - " At stop 10, take route 38 at time 2020-05-21T16:36:00.000000000.\n", - " Get out at stop 108 at time [['2020-05-21T17:05:00.000000000' 'NaT']].\n", - "Walk 125 seconds from stop 108 to stop 690.\n", - " At stop 690, take route 454 at time 2020-05-21T17:16:00.000000000.\n", - " Get out at stop 1129 at time [['2020-05-21T17:17:00.000000000' '2020-05-21T17:17:00.000000000']].\n", - "Walk 283 seconds from stop 1129 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 9\n", - "Journey begins at stop 1000 at time 2020-05-21T16:12:00.000000000, with an overall probability of success = 0.9483550823555521 \n", - "\n", - " At stop 1000, take route 399 at time 2020-05-21T16:12:00.000000000.\n", - " Get out at stop 273 at time [['2020-05-21T16:20:00.000000000' '2020-05-21T16:20:00.000000000']].\n", - "Walk 260 seconds from stop 273 to stop 10.\n", - " At stop 10, take route 38 at time 2020-05-21T16:36:00.000000000.\n", - " Get out at stop 108 at time [['2020-05-21T17:05:00.000000000' 'NaT']].\n", - "Walk 125 seconds from stop 108 to stop 690.\n", - " At stop 690, take route 454 at time 2020-05-21T17:16:00.000000000.\n", - " Get out at stop 1129 at time [['2020-05-21T17:17:00.000000000' '2020-05-21T17:17:00.000000000']].\n", - "Walk 283 seconds from stop 1129 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n" - ] - } - ], + "outputs": [], "source": [ - "for i, label in enumerate(bags_p_s[-1]):\n", - " print('\\n'*2,'-'*10, 'OPTION', i+1)\n", - " label.print_journey()" + "print_solutions(bags_p_s)" ] }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 50, "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n", - " ---------- OPTION 1\n", - "Journey begins at stop 1024 at time 2020-05-21T17:01:31.000000000, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 389 seconds from stop 1024 to stop 1133.\n", - " At stop 1133, take route 454 at time 2020-05-21T17:10:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 2\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 3\n", - "Journey begins at stop 1024 at time 2020-05-21T16:12:00.000000000, with an overall probability of success = 1.0 \n", - "\n", - " At stop 1024, take route 382 at time 2020-05-21T16:12:00.000000000.\n", - " Get out at stop 1027 at time [['2020-05-21T16:16:00.000000000' '2020-05-21T16:16:00.000000000']].\n", - "Walk 267 seconds from stop 1027 to stop 106.\n", - " At stop 106, take route 38 at time 2020-05-21T16:30:00.000000000.\n", - " Get out at stop 108 at time [['2020-05-21T16:35:00.000000000' 'NaT']].\n", - "Walk 14 seconds from stop 108 to stop 689.\n", - " At stop 689, take route 387 at time 2020-05-21T16:57:00.000000000.\n", - " Get out at stop 1034 at time [['2020-05-21T17:04:00.000000000' 'NaT']].\n", - "Walk 267 seconds from stop 1034 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 4\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 5\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 6\n", - "Journey begins at stop 1024 at time 2020-05-21T16:33:31.000000000, with an overall probability of success = 0.9942528735632185 \n", - "\n", - "Walk 389 seconds from stop 1024 to stop 1133.\n", - " At stop 1133, take route 454 at time 2020-05-21T16:42:00.000000000.\n", - " Get out at stop 1134 at time [['2020-05-21T16:44:00.000000000' '2020-05-21T16:44:00.000000000']].\n", - "Walk 375 seconds from stop 1134 to stop 1030.\n", - " At stop 1030, take route 387 at time 2020-05-21T17:00:00.000000000.\n", - " Get out at stop 1034 at time [['2020-05-21T17:04:00.000000000' 'NaT']].\n", - "Walk 267 seconds from stop 1034 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 7\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 8\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 9\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 10\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 11\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 12\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 13\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 14\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 15\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 16\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 17\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 18\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 19\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 20\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 21\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 22\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 23\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 24\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 25\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 26\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 27\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 28\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 29\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 30\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 31\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 32\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 33\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 34\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 35\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 36\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 37\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 38\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 39\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 40\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 41\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 42\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 43\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 44\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 45\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 46\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 47\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 48\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 49\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 50\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 51\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 52\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 53\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 54\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 55\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 56\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 57\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n", - "\n", - "\n", - " ---------- OPTION 58\n", - "Journey begins at stop 1024 at time NaT, with an overall probability of success = 0.9942528735632183 \n", - "\n", - "Walk 525 seconds from stop 1024 to stop 1022.\n", - " At stop 1022, take route 382 at time NaT.\n", - " Get out at stop 1026 at time [['2020-05-21T16:38:00.000000000' '2020-05-21T16:38:00.000000000']].\n", - "Walk 562 seconds from stop 1026 to stop 1134.\n", - " At stop 1134, take route 454 at time 2020-05-21T17:12:00.000000000.\n", - " Get out at stop 1137 at time [['2020-05-21T17:15:00.000000000' '2020-05-21T17:15:00.000000000']].\n", - "Walk 130 seconds from stop 1137 to stop 1033.\n", - "You have arrived at the target stop (1033) before the target time of 2020-05-21T17:30.\n" - ] - } - ], + "outputs": [], "source": [ - "for i, label in enumerate(bags[-1][1024]):\n", + "for i, label in enumerate(bags[-1][p_s]):\n", " print('\\n'*2,'-'*10, 'OPTION', i+1)\n", " label.print_journey()" ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "n_stops: 11\n", "route_stops: [1007 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027]\n" ] }, { "data": { "text/plain": [ "array([[ 'NaT', '2020-05-21T07:03:00.000000000'],\n", " ['2020-05-21T07:05:00.000000000', '2020-05-21T07:05:00.000000000'],\n", " ['2020-05-21T07:06:00.000000000', '2020-05-21T07:06:00.000000000'],\n", " ['2020-05-21T07:08:00.000000000', '2020-05-21T07:08:00.000000000'],\n", " ['2020-05-21T07:09:00.000000000', '2020-05-21T07:09:00.000000000'],\n", " ['2020-05-21T07:10:00.000000000', '2020-05-21T07:10:00.000000000'],\n", " ['2020-05-21T07:11:00.000000000', '2020-05-21T07:11:00.000000000'],\n", " ['2020-05-21T07:12:00.000000000', '2020-05-21T07:12:00.000000000'],\n", " ['2020-05-21T07:14:00.000000000', '2020-05-21T07:14:00.000000000'],\n", " ['2020-05-21T07:15:00.000000000', '2020-05-21T07:15:00.000000000'],\n", " ['2020-05-21T07:16:00.000000000', '2020-05-21T07:16:00.000000000'],\n", " ['2020-05-21T07:17:00.000000000', '2020-05-21T07:17:00.000000000'],\n", " ['2020-05-21T07:18:00.000000000', '2020-05-21T07:18:00.000000000'],\n", " ['2020-05-21T07:19:00.000000000', '2020-05-21T07:19:00.000000000'],\n", " ['2020-05-21T07:20:00.000000000', '2020-05-21T07:20:00.000000000'],\n", " ['2020-05-21T07:21:00.000000000', '2020-05-21T07:21:00.000000000'],\n", " ['2020-05-21T07:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T07:33:00.000000000'],\n", " ['2020-05-21T07:35:00.000000000', '2020-05-21T07:35:00.000000000'],\n", " ['2020-05-21T07:36:00.000000000', '2020-05-21T07:36:00.000000000'],\n", " ['2020-05-21T07:38:00.000000000', '2020-05-21T07:38:00.000000000'],\n", " ['2020-05-21T07:39:00.000000000', '2020-05-21T07:39:00.000000000'],\n", " ['2020-05-21T07:40:00.000000000', '2020-05-21T07:40:00.000000000'],\n", " ['2020-05-21T07:41:00.000000000', '2020-05-21T07:41:00.000000000'],\n", " ['2020-05-21T07:42:00.000000000', '2020-05-21T07:42:00.000000000'],\n", " ['2020-05-21T07:44:00.000000000', '2020-05-21T07:44:00.000000000'],\n", " ['2020-05-21T07:45:00.000000000', '2020-05-21T07:45:00.000000000'],\n", " ['2020-05-21T07:46:00.000000000', '2020-05-21T07:46:00.000000000'],\n", " ['2020-05-21T07:47:00.000000000', '2020-05-21T07:47:00.000000000'],\n", " ['2020-05-21T07:48:00.000000000', '2020-05-21T07:48:00.000000000'],\n", " ['2020-05-21T07:49:00.000000000', '2020-05-21T07:49:00.000000000'],\n", " ['2020-05-21T07:50:00.000000000', '2020-05-21T07:50:00.000000000'],\n", " ['2020-05-21T07:51:00.000000000', '2020-05-21T07:51:00.000000000'],\n", " ['2020-05-21T07:52:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T08:03:00.000000000'],\n", " ['2020-05-21T08:05:00.000000000', '2020-05-21T08:05:00.000000000'],\n", " ['2020-05-21T08:06:00.000000000', '2020-05-21T08:06:00.000000000'],\n", " ['2020-05-21T08:08:00.000000000', '2020-05-21T08:08:00.000000000'],\n", " ['2020-05-21T08:09:00.000000000', '2020-05-21T08:09:00.000000000'],\n", " ['2020-05-21T08:10:00.000000000', '2020-05-21T08:10:00.000000000'],\n", " ['2020-05-21T08:11:00.000000000', '2020-05-21T08:11:00.000000000'],\n", " ['2020-05-21T08:12:00.000000000', '2020-05-21T08:12:00.000000000'],\n", " ['2020-05-21T08:14:00.000000000', '2020-05-21T08:14:00.000000000'],\n", " ['2020-05-21T08:15:00.000000000', '2020-05-21T08:15:00.000000000'],\n", " ['2020-05-21T08:16:00.000000000', '2020-05-21T08:16:00.000000000'],\n", " ['2020-05-21T08:17:00.000000000', '2020-05-21T08:17:00.000000000'],\n", " ['2020-05-21T08:18:00.000000000', '2020-05-21T08:18:00.000000000'],\n", " ['2020-05-21T08:19:00.000000000', '2020-05-21T08:19:00.000000000'],\n", " ['2020-05-21T08:20:00.000000000', '2020-05-21T08:20:00.000000000'],\n", " ['2020-05-21T08:21:00.000000000', '2020-05-21T08:21:00.000000000'],\n", " ['2020-05-21T08:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T08:33:00.000000000'],\n", " ['2020-05-21T08:35:00.000000000', '2020-05-21T08:35:00.000000000'],\n", " ['2020-05-21T08:36:00.000000000', '2020-05-21T08:36:00.000000000'],\n", " ['2020-05-21T08:38:00.000000000', '2020-05-21T08:38:00.000000000'],\n", " ['2020-05-21T08:39:00.000000000', '2020-05-21T08:39:00.000000000'],\n", " ['2020-05-21T08:40:00.000000000', '2020-05-21T08:40:00.000000000'],\n", " ['2020-05-21T08:41:00.000000000', '2020-05-21T08:41:00.000000000'],\n", " ['2020-05-21T08:42:00.000000000', '2020-05-21T08:42:00.000000000'],\n", " ['2020-05-21T08:44:00.000000000', '2020-05-21T08:44:00.000000000'],\n", " ['2020-05-21T08:45:00.000000000', '2020-05-21T08:45:00.000000000'],\n", " ['2020-05-21T08:46:00.000000000', '2020-05-21T08:46:00.000000000'],\n", " ['2020-05-21T08:47:00.000000000', '2020-05-21T08:47:00.000000000'],\n", " ['2020-05-21T08:48:00.000000000', '2020-05-21T08:48:00.000000000'],\n", " ['2020-05-21T08:49:00.000000000', '2020-05-21T08:49:00.000000000'],\n", " ['2020-05-21T08:50:00.000000000', '2020-05-21T08:50:00.000000000'],\n", " ['2020-05-21T08:51:00.000000000', '2020-05-21T08:51:00.000000000'],\n", " ['2020-05-21T08:52:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T09:03:00.000000000'],\n", " ['2020-05-21T09:05:00.000000000', '2020-05-21T09:05:00.000000000'],\n", " ['2020-05-21T09:06:00.000000000', '2020-05-21T09:06:00.000000000'],\n", " ['2020-05-21T09:08:00.000000000', '2020-05-21T09:08:00.000000000'],\n", " ['2020-05-21T09:09:00.000000000', '2020-05-21T09:09:00.000000000'],\n", " ['2020-05-21T09:10:00.000000000', '2020-05-21T09:10:00.000000000'],\n", " ['2020-05-21T09:11:00.000000000', '2020-05-21T09:11:00.000000000'],\n", " ['2020-05-21T09:12:00.000000000', '2020-05-21T09:12:00.000000000'],\n", " ['2020-05-21T09:14:00.000000000', '2020-05-21T09:14:00.000000000'],\n", " ['2020-05-21T09:15:00.000000000', '2020-05-21T09:15:00.000000000'],\n", " ['2020-05-21T09:16:00.000000000', '2020-05-21T09:16:00.000000000'],\n", " ['2020-05-21T09:17:00.000000000', '2020-05-21T09:17:00.000000000'],\n", " ['2020-05-21T09:18:00.000000000', '2020-05-21T09:18:00.000000000'],\n", " ['2020-05-21T09:19:00.000000000', '2020-05-21T09:19:00.000000000'],\n", " ['2020-05-21T09:20:00.000000000', '2020-05-21T09:20:00.000000000'],\n", " ['2020-05-21T09:21:00.000000000', '2020-05-21T09:21:00.000000000'],\n", " ['2020-05-21T09:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T10:03:00.000000000'],\n", " ['2020-05-21T10:05:00.000000000', '2020-05-21T10:05:00.000000000'],\n", " ['2020-05-21T10:06:00.000000000', '2020-05-21T10:06:00.000000000'],\n", " ['2020-05-21T10:08:00.000000000', '2020-05-21T10:08:00.000000000'],\n", " ['2020-05-21T10:09:00.000000000', '2020-05-21T10:09:00.000000000'],\n", " ['2020-05-21T10:10:00.000000000', '2020-05-21T10:10:00.000000000'],\n", " ['2020-05-21T10:11:00.000000000', '2020-05-21T10:11:00.000000000'],\n", " ['2020-05-21T10:12:00.000000000', '2020-05-21T10:12:00.000000000'],\n", " ['2020-05-21T10:14:00.000000000', '2020-05-21T10:14:00.000000000'],\n", " ['2020-05-21T10:15:00.000000000', '2020-05-21T10:15:00.000000000'],\n", " ['2020-05-21T10:16:00.000000000', '2020-05-21T10:16:00.000000000'],\n", " ['2020-05-21T10:17:00.000000000', '2020-05-21T10:17:00.000000000'],\n", " ['2020-05-21T10:18:00.000000000', '2020-05-21T10:18:00.000000000'],\n", " ['2020-05-21T10:19:00.000000000', '2020-05-21T10:19:00.000000000'],\n", " ['2020-05-21T10:20:00.000000000', '2020-05-21T10:20:00.000000000'],\n", " ['2020-05-21T10:21:00.000000000', '2020-05-21T10:21:00.000000000'],\n", " ['2020-05-21T10:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T11:03:00.000000000'],\n", " ['2020-05-21T11:05:00.000000000', '2020-05-21T11:05:00.000000000'],\n", " ['2020-05-21T11:06:00.000000000', '2020-05-21T11:06:00.000000000'],\n", " ['2020-05-21T11:08:00.000000000', '2020-05-21T11:08:00.000000000'],\n", " ['2020-05-21T11:09:00.000000000', '2020-05-21T11:09:00.000000000'],\n", " ['2020-05-21T11:10:00.000000000', '2020-05-21T11:10:00.000000000'],\n", " ['2020-05-21T11:11:00.000000000', '2020-05-21T11:11:00.000000000'],\n", " ['2020-05-21T11:12:00.000000000', '2020-05-21T11:12:00.000000000'],\n", " ['2020-05-21T11:14:00.000000000', '2020-05-21T11:14:00.000000000'],\n", " ['2020-05-21T11:15:00.000000000', '2020-05-21T11:15:00.000000000'],\n", " ['2020-05-21T11:16:00.000000000', '2020-05-21T11:16:00.000000000'],\n", " ['2020-05-21T11:17:00.000000000', '2020-05-21T11:17:00.000000000'],\n", " ['2020-05-21T11:18:00.000000000', '2020-05-21T11:18:00.000000000'],\n", " ['2020-05-21T11:19:00.000000000', '2020-05-21T11:19:00.000000000'],\n", " ['2020-05-21T11:20:00.000000000', '2020-05-21T11:20:00.000000000'],\n", " ['2020-05-21T11:21:00.000000000', '2020-05-21T11:21:00.000000000'],\n", " ['2020-05-21T11:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T12:03:00.000000000'],\n", " ['2020-05-21T12:05:00.000000000', '2020-05-21T12:05:00.000000000'],\n", " ['2020-05-21T12:06:00.000000000', '2020-05-21T12:06:00.000000000'],\n", " ['2020-05-21T12:08:00.000000000', '2020-05-21T12:08:00.000000000'],\n", " ['2020-05-21T12:09:00.000000000', '2020-05-21T12:09:00.000000000'],\n", " ['2020-05-21T12:10:00.000000000', '2020-05-21T12:10:00.000000000'],\n", " ['2020-05-21T12:11:00.000000000', '2020-05-21T12:11:00.000000000'],\n", " ['2020-05-21T12:12:00.000000000', '2020-05-21T12:12:00.000000000'],\n", " ['2020-05-21T12:14:00.000000000', '2020-05-21T12:14:00.000000000'],\n", " ['2020-05-21T12:15:00.000000000', '2020-05-21T12:15:00.000000000'],\n", " ['2020-05-21T12:16:00.000000000', '2020-05-21T12:16:00.000000000'],\n", " ['2020-05-21T12:17:00.000000000', '2020-05-21T12:17:00.000000000'],\n", " ['2020-05-21T12:18:00.000000000', '2020-05-21T12:18:00.000000000'],\n", " ['2020-05-21T12:19:00.000000000', '2020-05-21T12:19:00.000000000'],\n", " ['2020-05-21T12:20:00.000000000', '2020-05-21T12:20:00.000000000'],\n", " ['2020-05-21T12:21:00.000000000', '2020-05-21T12:21:00.000000000'],\n", " ['2020-05-21T12:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T13:03:00.000000000'],\n", " ['2020-05-21T13:05:00.000000000', '2020-05-21T13:05:00.000000000'],\n", " ['2020-05-21T13:06:00.000000000', '2020-05-21T13:06:00.000000000'],\n", " ['2020-05-21T13:08:00.000000000', '2020-05-21T13:08:00.000000000'],\n", " ['2020-05-21T13:09:00.000000000', '2020-05-21T13:09:00.000000000'],\n", " ['2020-05-21T13:10:00.000000000', '2020-05-21T13:10:00.000000000'],\n", " ['2020-05-21T13:11:00.000000000', '2020-05-21T13:11:00.000000000'],\n", " ['2020-05-21T13:12:00.000000000', '2020-05-21T13:12:00.000000000'],\n", " ['2020-05-21T13:14:00.000000000', '2020-05-21T13:14:00.000000000'],\n", " ['2020-05-21T13:15:00.000000000', '2020-05-21T13:15:00.000000000'],\n", " ['2020-05-21T13:16:00.000000000', '2020-05-21T13:16:00.000000000'],\n", " ['2020-05-21T13:17:00.000000000', '2020-05-21T13:17:00.000000000'],\n", " ['2020-05-21T13:18:00.000000000', '2020-05-21T13:18:00.000000000'],\n", " ['2020-05-21T13:19:00.000000000', '2020-05-21T13:19:00.000000000'],\n", " ['2020-05-21T13:20:00.000000000', '2020-05-21T13:20:00.000000000'],\n", " ['2020-05-21T13:21:00.000000000', '2020-05-21T13:21:00.000000000'],\n", " ['2020-05-21T13:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T14:03:00.000000000'],\n", " ['2020-05-21T14:05:00.000000000', '2020-05-21T14:05:00.000000000'],\n", " ['2020-05-21T14:06:00.000000000', '2020-05-21T14:06:00.000000000'],\n", " ['2020-05-21T14:08:00.000000000', '2020-05-21T14:08:00.000000000'],\n", " ['2020-05-21T14:09:00.000000000', '2020-05-21T14:09:00.000000000'],\n", " ['2020-05-21T14:10:00.000000000', '2020-05-21T14:10:00.000000000'],\n", " ['2020-05-21T14:11:00.000000000', '2020-05-21T14:11:00.000000000'],\n", " ['2020-05-21T14:12:00.000000000', '2020-05-21T14:12:00.000000000'],\n", " ['2020-05-21T14:14:00.000000000', '2020-05-21T14:14:00.000000000'],\n", " ['2020-05-21T14:15:00.000000000', '2020-05-21T14:15:00.000000000'],\n", " ['2020-05-21T14:16:00.000000000', '2020-05-21T14:16:00.000000000'],\n", " ['2020-05-21T14:17:00.000000000', '2020-05-21T14:17:00.000000000'],\n", " ['2020-05-21T14:18:00.000000000', '2020-05-21T14:18:00.000000000'],\n", " ['2020-05-21T14:19:00.000000000', '2020-05-21T14:19:00.000000000'],\n", " ['2020-05-21T14:20:00.000000000', '2020-05-21T14:20:00.000000000'],\n", " ['2020-05-21T14:21:00.000000000', '2020-05-21T14:21:00.000000000'],\n", " ['2020-05-21T14:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T15:03:00.000000000'],\n", " ['2020-05-21T15:05:00.000000000', '2020-05-21T15:05:00.000000000'],\n", " ['2020-05-21T15:06:00.000000000', '2020-05-21T15:06:00.000000000'],\n", " ['2020-05-21T15:08:00.000000000', '2020-05-21T15:08:00.000000000'],\n", " ['2020-05-21T15:09:00.000000000', '2020-05-21T15:09:00.000000000'],\n", " ['2020-05-21T15:10:00.000000000', '2020-05-21T15:10:00.000000000'],\n", " ['2020-05-21T15:11:00.000000000', '2020-05-21T15:11:00.000000000'],\n", " ['2020-05-21T15:12:00.000000000', '2020-05-21T15:12:00.000000000'],\n", " ['2020-05-21T15:14:00.000000000', '2020-05-21T15:14:00.000000000'],\n", " ['2020-05-21T15:15:00.000000000', '2020-05-21T15:15:00.000000000'],\n", " ['2020-05-21T15:16:00.000000000', '2020-05-21T15:16:00.000000000'],\n", " ['2020-05-21T15:17:00.000000000', '2020-05-21T15:17:00.000000000'],\n", " ['2020-05-21T15:18:00.000000000', '2020-05-21T15:18:00.000000000'],\n", " ['2020-05-21T15:19:00.000000000', '2020-05-21T15:19:00.000000000'],\n", " ['2020-05-21T15:20:00.000000000', '2020-05-21T15:20:00.000000000'],\n", " ['2020-05-21T15:21:00.000000000', '2020-05-21T15:21:00.000000000'],\n", " ['2020-05-21T15:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T16:03:00.000000000'],\n", " ['2020-05-21T16:05:00.000000000', '2020-05-21T16:05:00.000000000'],\n", " ['2020-05-21T16:06:00.000000000', '2020-05-21T16:06:00.000000000'],\n", " ['2020-05-21T16:08:00.000000000', '2020-05-21T16:08:00.000000000'],\n", " ['2020-05-21T16:09:00.000000000', '2020-05-21T16:09:00.000000000'],\n", " ['2020-05-21T16:10:00.000000000', '2020-05-21T16:10:00.000000000'],\n", " ['2020-05-21T16:11:00.000000000', '2020-05-21T16:11:00.000000000'],\n", " ['2020-05-21T16:12:00.000000000', '2020-05-21T16:12:00.000000000'],\n", " ['2020-05-21T16:14:00.000000000', '2020-05-21T16:14:00.000000000'],\n", " ['2020-05-21T16:15:00.000000000', '2020-05-21T16:15:00.000000000'],\n", " ['2020-05-21T16:16:00.000000000', '2020-05-21T16:16:00.000000000'],\n", " ['2020-05-21T16:17:00.000000000', '2020-05-21T16:17:00.000000000'],\n", " ['2020-05-21T16:18:00.000000000', '2020-05-21T16:18:00.000000000'],\n", " ['2020-05-21T16:19:00.000000000', '2020-05-21T16:19:00.000000000'],\n", " ['2020-05-21T16:20:00.000000000', '2020-05-21T16:20:00.000000000'],\n", " ['2020-05-21T16:21:00.000000000', '2020-05-21T16:21:00.000000000'],\n", " ['2020-05-21T16:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T16:33:00.000000000'],\n", " ['2020-05-21T16:35:00.000000000', '2020-05-21T16:35:00.000000000'],\n", " ['2020-05-21T16:36:00.000000000', '2020-05-21T16:36:00.000000000'],\n", " ['2020-05-21T16:38:00.000000000', '2020-05-21T16:38:00.000000000'],\n", " ['2020-05-21T16:39:00.000000000', '2020-05-21T16:39:00.000000000'],\n", " ['2020-05-21T16:40:00.000000000', '2020-05-21T16:40:00.000000000'],\n", " ['2020-05-21T16:41:00.000000000', '2020-05-21T16:41:00.000000000'],\n", " ['2020-05-21T16:42:00.000000000', '2020-05-21T16:42:00.000000000'],\n", " ['2020-05-21T16:44:00.000000000', '2020-05-21T16:44:00.000000000'],\n", " ['2020-05-21T16:45:00.000000000', '2020-05-21T16:45:00.000000000'],\n", " ['2020-05-21T16:46:00.000000000', '2020-05-21T16:46:00.000000000'],\n", " ['2020-05-21T16:47:00.000000000', '2020-05-21T16:47:00.000000000'],\n", " ['2020-05-21T16:48:00.000000000', '2020-05-21T16:48:00.000000000'],\n", " ['2020-05-21T16:49:00.000000000', '2020-05-21T16:49:00.000000000'],\n", " ['2020-05-21T16:50:00.000000000', '2020-05-21T16:50:00.000000000'],\n", " ['2020-05-21T16:51:00.000000000', '2020-05-21T16:51:00.000000000'],\n", " ['2020-05-21T16:52:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T17:03:00.000000000'],\n", " ['2020-05-21T17:05:00.000000000', '2020-05-21T17:05:00.000000000'],\n", " ['2020-05-21T17:06:00.000000000', '2020-05-21T17:06:00.000000000'],\n", " ['2020-05-21T17:08:00.000000000', '2020-05-21T17:08:00.000000000'],\n", " ['2020-05-21T17:09:00.000000000', '2020-05-21T17:09:00.000000000'],\n", " ['2020-05-21T17:10:00.000000000', '2020-05-21T17:10:00.000000000'],\n", " ['2020-05-21T17:11:00.000000000', '2020-05-21T17:11:00.000000000'],\n", " ['2020-05-21T17:12:00.000000000', '2020-05-21T17:12:00.000000000'],\n", " ['2020-05-21T17:14:00.000000000', '2020-05-21T17:14:00.000000000'],\n", " ['2020-05-21T17:15:00.000000000', '2020-05-21T17:15:00.000000000'],\n", " ['2020-05-21T17:16:00.000000000', '2020-05-21T17:16:00.000000000'],\n", " ['2020-05-21T17:17:00.000000000', '2020-05-21T17:17:00.000000000'],\n", " ['2020-05-21T17:18:00.000000000', '2020-05-21T17:18:00.000000000'],\n", " ['2020-05-21T17:19:00.000000000', '2020-05-21T17:19:00.000000000'],\n", " ['2020-05-21T17:20:00.000000000', '2020-05-21T17:20:00.000000000'],\n", " ['2020-05-21T17:21:00.000000000', '2020-05-21T17:21:00.000000000'],\n", " ['2020-05-21T17:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T17:33:00.000000000'],\n", " ['2020-05-21T17:35:00.000000000', '2020-05-21T17:35:00.000000000'],\n", " ['2020-05-21T17:36:00.000000000', '2020-05-21T17:36:00.000000000'],\n", " ['2020-05-21T17:38:00.000000000', '2020-05-21T17:38:00.000000000'],\n", " ['2020-05-21T17:39:00.000000000', '2020-05-21T17:39:00.000000000'],\n", " ['2020-05-21T17:40:00.000000000', '2020-05-21T17:40:00.000000000'],\n", " ['2020-05-21T17:41:00.000000000', '2020-05-21T17:41:00.000000000'],\n", " ['2020-05-21T17:42:00.000000000', '2020-05-21T17:42:00.000000000'],\n", " ['2020-05-21T17:44:00.000000000', '2020-05-21T17:44:00.000000000'],\n", " ['2020-05-21T17:45:00.000000000', '2020-05-21T17:45:00.000000000'],\n", " ['2020-05-21T17:46:00.000000000', '2020-05-21T17:46:00.000000000'],\n", " ['2020-05-21T17:47:00.000000000', '2020-05-21T17:47:00.000000000'],\n", " ['2020-05-21T17:48:00.000000000', '2020-05-21T17:48:00.000000000'],\n", " ['2020-05-21T17:49:00.000000000', '2020-05-21T17:49:00.000000000'],\n", " ['2020-05-21T17:50:00.000000000', '2020-05-21T17:50:00.000000000'],\n", " ['2020-05-21T17:51:00.000000000', '2020-05-21T17:51:00.000000000'],\n", " ['2020-05-21T17:52:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T18:03:00.000000000'],\n", " ['2020-05-21T18:05:00.000000000', '2020-05-21T18:05:00.000000000'],\n", " ['2020-05-21T18:06:00.000000000', '2020-05-21T18:06:00.000000000'],\n", " ['2020-05-21T18:08:00.000000000', '2020-05-21T18:08:00.000000000'],\n", " ['2020-05-21T18:09:00.000000000', '2020-05-21T18:09:00.000000000'],\n", " ['2020-05-21T18:10:00.000000000', '2020-05-21T18:10:00.000000000'],\n", " ['2020-05-21T18:11:00.000000000', '2020-05-21T18:11:00.000000000'],\n", " ['2020-05-21T18:12:00.000000000', '2020-05-21T18:12:00.000000000'],\n", " ['2020-05-21T18:14:00.000000000', '2020-05-21T18:14:00.000000000'],\n", " ['2020-05-21T18:15:00.000000000', '2020-05-21T18:15:00.000000000'],\n", " ['2020-05-21T18:16:00.000000000', '2020-05-21T18:16:00.000000000'],\n", " ['2020-05-21T18:17:00.000000000', '2020-05-21T18:17:00.000000000'],\n", " ['2020-05-21T18:18:00.000000000', '2020-05-21T18:18:00.000000000'],\n", " ['2020-05-21T18:19:00.000000000', '2020-05-21T18:19:00.000000000'],\n", " ['2020-05-21T18:20:00.000000000', '2020-05-21T18:20:00.000000000'],\n", " ['2020-05-21T18:21:00.000000000', '2020-05-21T18:21:00.000000000'],\n", " ['2020-05-21T18:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T18:33:00.000000000'],\n", " ['2020-05-21T18:35:00.000000000', '2020-05-21T18:35:00.000000000'],\n", " ['2020-05-21T18:36:00.000000000', '2020-05-21T18:36:00.000000000'],\n", " ['2020-05-21T18:38:00.000000000', '2020-05-21T18:38:00.000000000'],\n", " ['2020-05-21T18:39:00.000000000', '2020-05-21T18:39:00.000000000'],\n", " ['2020-05-21T18:40:00.000000000', '2020-05-21T18:40:00.000000000'],\n", " ['2020-05-21T18:41:00.000000000', '2020-05-21T18:41:00.000000000'],\n", " ['2020-05-21T18:42:00.000000000', '2020-05-21T18:42:00.000000000'],\n", " ['2020-05-21T18:44:00.000000000', '2020-05-21T18:44:00.000000000'],\n", " ['2020-05-21T18:45:00.000000000', '2020-05-21T18:45:00.000000000'],\n", " ['2020-05-21T18:46:00.000000000', '2020-05-21T18:46:00.000000000'],\n", " ['2020-05-21T18:47:00.000000000', '2020-05-21T18:47:00.000000000'],\n", " ['2020-05-21T18:48:00.000000000', '2020-05-21T18:48:00.000000000'],\n", " ['2020-05-21T18:49:00.000000000', '2020-05-21T18:49:00.000000000'],\n", " ['2020-05-21T18:50:00.000000000', '2020-05-21T18:50:00.000000000'],\n", " ['2020-05-21T18:51:00.000000000', '2020-05-21T18:51:00.000000000'],\n", " ['2020-05-21T18:52:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T19:03:00.000000000'],\n", " ['2020-05-21T19:05:00.000000000', '2020-05-21T19:05:00.000000000'],\n", " ['2020-05-21T19:06:00.000000000', '2020-05-21T19:06:00.000000000'],\n", " ['2020-05-21T19:08:00.000000000', '2020-05-21T19:08:00.000000000'],\n", " ['2020-05-21T19:09:00.000000000', '2020-05-21T19:09:00.000000000'],\n", " ['2020-05-21T19:10:00.000000000', '2020-05-21T19:10:00.000000000'],\n", " ['2020-05-21T19:11:00.000000000', '2020-05-21T19:11:00.000000000'],\n", " ['2020-05-21T19:12:00.000000000', '2020-05-21T19:12:00.000000000'],\n", " ['2020-05-21T19:14:00.000000000', '2020-05-21T19:14:00.000000000'],\n", " ['2020-05-21T19:15:00.000000000', '2020-05-21T19:15:00.000000000'],\n", " ['2020-05-21T19:16:00.000000000', '2020-05-21T19:16:00.000000000'],\n", " ['2020-05-21T19:17:00.000000000', '2020-05-21T19:17:00.000000000'],\n", " ['2020-05-21T19:18:00.000000000', '2020-05-21T19:18:00.000000000'],\n", " ['2020-05-21T19:19:00.000000000', '2020-05-21T19:19:00.000000000'],\n", " ['2020-05-21T19:20:00.000000000', '2020-05-21T19:20:00.000000000'],\n", " ['2020-05-21T19:21:00.000000000', '2020-05-21T19:21:00.000000000'],\n", " ['2020-05-21T19:22:00.000000000', 'NaT'],\n", " [ 'NaT', '2020-05-21T19:33:00.000000000'],\n", " ['2020-05-21T19:35:00.000000000', '2020-05-21T19:35:00.000000000'],\n", " ['2020-05-21T19:36:00.000000000', '2020-05-21T19:36:00.000000000'],\n", " ['2020-05-21T19:38:00.000000000', '2020-05-21T19:38:00.000000000'],\n", " ['2020-05-21T19:39:00.000000000', '2020-05-21T19:39:00.000000000'],\n", " ['2020-05-21T19:40:00.000000000', '2020-05-21T19:40:00.000000000'],\n", " ['2020-05-21T19:41:00.000000000', '2020-05-21T19:41:00.000000000'],\n", " ['2020-05-21T19:42:00.000000000', '2020-05-21T19:42:00.000000000'],\n", " ['2020-05-21T19:44:00.000000000', '2020-05-21T19:44:00.000000000'],\n", " ['2020-05-21T19:45:00.000000000', '2020-05-21T19:45:00.000000000'],\n", " ['2020-05-21T19:46:00.000000000', '2020-05-21T19:46:00.000000000'],\n", " ['2020-05-21T19:47:00.000000000', '2020-05-21T19:47:00.000000000'],\n", " ['2020-05-21T19:48:00.000000000', '2020-05-21T19:48:00.000000000'],\n", " ['2020-05-21T19:49:00.000000000', '2020-05-21T19:49:00.000000000'],\n", " ['2020-05-21T19:50:00.000000000', '2020-05-21T19:50:00.000000000'],\n", " ['2020-05-21T19:51:00.000000000', '2020-05-21T19:51:00.000000000'],\n", " ['2020-05-21T19:52:00.000000000', 'NaT']],\n", " dtype='datetime64[ns]')" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = 382\n", "print('n_stops:', routes[r][1])\n", "print('route_stops:', get_stops(r))\n", "stopTimes[ routes[r][3] : routes[r+1][3] ]" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(bags_p_s)" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "for i, label in enumerate(bags_p_s[2]):\n", " print('\\n'*2,'-'*10, 'OPTION', i, 'with at most 2 trips')\n", " label.print_journey()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Code for prototyping and debugging:" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "iinfo(min=0, max=4294967295, dtype=uint32)" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.iinfo(np.uint32)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "ename": "RuntimeError", "evalue": "Set changed size during iteration", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0ms1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0ms1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0ms1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0ms1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mRuntimeError\u001b[0m: Set changed size during iteration" ] } ], "source": [ "s1 = {1,2,3}\n", "for i in s1:\n", " s1.add(i*10)\n", "s1" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([99., 80., 47., 22., 15., 11., 3., 0., 1., 1.]),\n", " array([1.0, 6.9, 12.8, 18.700000000000003, 24.6, 30.5, 36.400000000000006,\n", " 42.300000000000004, 48.2, 54.1, 60.0], dtype=object),\n", " )" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAN3klEQVR4nO3df6jd9X3H8edrps5qtyaaS8gS3c0wVGTMH1ysYimd2YbVUv1DxFJGKIH8Yze7Ftq4wWT/KYxaB0MIapuBWJ3tlqCjrUstY38s7Y3aGpM6MxtrJJor03Xrxtqs7/1xvsJddqP3nO89npwPzwdczvl+vt9zvu83+fq6Xz/nfL83VYUkqS2/NOkCJEkrz3CXpAYZ7pLUIMNdkhpkuEtSg1ZNugCAtWvX1uzs7KTLkKSpsn///teramapdadFuM/OzjI/Pz/pMiRpqiR56VTrnJaRpAYZ7pLUIMNdkhr0juGe5IEkx5McWDR2bpInkrzQPa7pxpPkL5IcTvKDJJePs3hJ0tKWc+b+FeDak8Z2AHurajOwt1sG+CiwufvZDty7MmVKkobxjuFeVf8A/OtJwzcAu7rnu4AbF43/VQ38E7A6yfqVKlaStDyjzrmvq6pj3fNXgXXd8w3Ay4u2O9qNSZLeRb0/UK3BPYOHvm9wku1J5pPMLyws9C1DkrTIqOH+2lvTLd3j8W78FeD8Rdtt7Mb+n6raWVVzVTU3M7PkBVaSpBGNeoXqHmArcGf3uHvR+KeTfBX4IPBvi6ZvxmJ2x+PjfPu3deTO6ye2b0l6O+8Y7kkeAj4CrE1yFLiDQag/kmQb8BJwc7f53wHXAYeB/wQ+NYaaJUnv4B3Dvao+cYpVW5bYtoBb+xYlSerHK1QlqUGGuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSgwx3SWqQ4S5JDTLcJalBhrskNchwl6QGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ0y3CWpQYa7JDXIcJekBhnuktQgw12SGmS4S1KDDHdJapDhLkkNMtwlqUGGuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSgwx3SWqQ4S5JDTLcJalBvcI9yR8leS7JgSQPJTkryaYk+5IcTvJwkjNXqlhJ0vKMHO5JNgB/CMxV1W8CZwC3AHcBd1fVhcAbwLaVKFSStHx9p2VWAe9Nsgo4GzgGXAM82q3fBdzYcx+SpCGtGvWFVfVKkj8Hfgz8F/AtYD/wZlWd6DY7CmxY6vVJtgPbAS644IJRy5io2R2PT2S/R+68fiL7lTQ9+kzLrAFuADYBvwacA1y73NdX1c6qmququZmZmVHLkCQtoc+0zO8AP6qqhar6OfB14GpgdTdNA7AReKVnjZKkIfUJ9x8DVyY5O0mALcBB4Engpm6brcDufiVKkoY1crhX1T4GH5w+BTzbvddO4AvAZ5McBs4D7l+BOiVJQxj5A1WAqroDuOOk4ReBK/q8rySpH69QlaQGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ0y3CWpQYa7JDXIcJekBhnuktQgw12SGmS4S1KDDHdJapDhLkkNMtwlqUGGuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSgwx3SWqQ4S5JDTLcJalBhrskNchwl6QGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ0y3CWpQYa7JDXIcJekBvUK9ySrkzya5IdJDiW5Ksm5SZ5I8kL3uGalipUkLU/fM/d7gG9U1UXAJcAhYAewt6o2A3u7ZUnSu2jkcE/yfuDDwP0AVfWzqnoTuAHY1W22C7ixb5GSpOH0OXPfBCwAX07ydJL7kpwDrKuqY902rwLrlnpxku1J5pPMLyws9ChDknSyPuG+CrgcuLeqLgN+yklTMFVVQC314qraWVVzVTU3MzPTowxJ0sn6hPtR4GhV7euWH2UQ9q8lWQ/QPR7vV6IkaVgjh3tVvQq8nOQD3dAW4CCwB9jajW0FdveqUJI0tFU9X/8HwINJzgReBD7F4BfGI0m2AS8BN/fchyRpSL3CvaqeAeaWWLWlz/tKkvrxClVJapDhLkkNMtwlqUGGuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSgwx3SWqQ4S5JDTLcJalBhrskNchwl6QGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ0y3CWpQYa7JDXIcJekBq2adAEa3uyOxye27yN3Xj+xfUtaPs/cJalBhrskNchwl6QGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ0y3CWpQYa7JDXIcJekBvUO9yRnJHk6yWPd8qYk+5IcTvJwkjP7lylJGsZKnLnfBhxatHwXcHdVXQi8AWxbgX1IkobQK9yTbASuB+7rlgNcAzzabbILuLHPPiRJw+t75v4l4PPAL7rl84A3q+pEt3wU2LDUC5NsTzKfZH5hYaFnGZKkxUYO9yQfA45X1f5RXl9VO6tqrqrmZmZmRi1DkrSEPn+s42rg40muA84CfhW4B1idZFV39r4ReKV/mZKkYYx85l5Vt1fVxqqaBW4Bvl1VnwSeBG7qNtsK7O5dpSRpKOP4nvsXgM8mOcxgDv7+MexDkvQ2VuRvqFbVd4DvdM9fBK5YifeVJI3GK1QlqUGGuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSgwx3SWqQ4S5JDTLcJalBhrskNchwl6QGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ0y3CWpQYa7JDXIcJekBhnuktQgw12SGmS4S1KDDHdJapDhLkkNMtwlqUGGuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSgwx3SWqQ4S5JDVo16QI0XWZ3PD6R/R658/qJ7FeaViOfuSc5P8mTSQ4meS7Jbd34uUmeSPJC97hm5cqVJC1Hn2mZE8Dnqupi4Erg1iQXAzuAvVW1GdjbLUuS3kUjh3tVHauqp7rn/w4cAjYANwC7us12ATf2LVKSNJwV+UA1ySxwGbAPWFdVx7pVrwLrTvGa7Unmk8wvLCysRBmSpE7vcE/yPuBrwGeq6ieL11VVAbXU66pqZ1XNVdXczMxM3zIkSYv0Cvck72EQ7A9W1de74deSrO/WrweO9ytRkjSsPt+WCXA/cKiqvrho1R5ga/d8K7B79PIkSaPo8z33q4HfB55N8kw39sfAncAjSbYBLwE39ytRkjSskcO9qv4RyClWbxn1fSVJ/Xn7AUlqkOEuSQ0y3CWpQYa7JDXIu0JqKng3Smk4nrlLUoMMd0lqkOEuSQ0y3CWpQYa7JDXIcJekBhnuktQgw12SGuRFTNLbmNTFU+AFVOrHM3dJapDhLkkNMtwlqUGGuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSgwx3SWqQ4S5JDTLcJalBhrskNchwl6QGGe6S1CDDXZIaZLhLUoP8Yx3SaWpSfyjEPxLSBs/cJalBhrskNWgs4Z7k2iTPJzmcZMc49iFJOrUVn3NPcgbwl8DvAkeB7yXZU1UHV3pfktoyyT9IPinj+oxjHGfuVwCHq+rFqvoZ8FXghjHsR5J0CuP4tswG4OVFy0eBD568UZLtwPZu8T+SPL+M914LvN67wtNHS/201Au01c9QveSuMVayMlr6tyF39ern10+1YmJfhayqncDOYV6TZL6q5sZU0ruupX5a6gXa6qelXsB+lmsc0zKvAOcvWt7YjUmS3iXjCPfvAZuTbEpyJnALsGcM+5EkncKKT8tU1Ykknwa+CZwBPFBVz63Q2w81jTMFWuqnpV6grX5a6gXsZ1lSVeN4X0nSBHmFqiQ1yHCXpAZNTbhP+y0NkjyQ5HiSA4vGzk3yRJIXusc1k6xxuZKcn+TJJAeTPJfktm586vpJclaS7yb5ftfLn3Xjm5Ls6463h7svB0yNJGckeTrJY93y1PaT5EiSZ5M8k2S+G5u6Yw0gyeokjyb5YZJDSa4aVy9TEe6LbmnwUeBi4BNJLp5sVUP7CnDtSWM7gL1VtRnY2y1PgxPA56rqYuBK4Nbu32Ma+/lv4JqqugS4FLg2yZXAXcDdVXUh8AawbYI1juI24NCi5Wnv57er6tJF3wefxmMN4B7gG1V1EXAJg3+j8fRSVaf9D3AV8M1Fy7cDt0+6rhH6mAUOLFp+HljfPV8PPD/pGkfsazeDewlNdT/A2cBTDK6ofh1Y1Y3/n+PvdP9hcG3JXuAa4DEgU97PEWDtSWNTd6wB7wd+RPdFlnH3MhVn7ix9S4MNE6plJa2rqmPd81eBdZMsZhRJZoHLgH1MaT/dFMYzwHHgCeBfgDer6kS3ybQdb18CPg/8ols+j+nup4BvJdnf3bYEpvNY2wQsAF/upszuS3IOY+plWsK9eTX4tT1V30tN8j7ga8Bnquoni9dNUz9V9T9VdSmDM94rgIsmXNLIknwMOF5V+yddywr6UFVdzmBa9tYkH168coqOtVXA5cC9VXUZ8FNOmoJZyV6mJdxbvaXBa0nWA3SPxydcz7IleQ+DYH+wqr7eDU9tPwBV9SbwJINpi9VJ3rrIb5qOt6uBjyc5wuCOrNcwmOed1n6oqle6x+PA3zD4BTyNx9pR4GhV7euWH2UQ9mPpZVrCvdVbGuwBtnbPtzKYuz7tJQlwP3Coqr64aNXU9ZNkJsnq7vl7GXx2cIhByN/UbTYVvQBU1e1VtbGqZhn8d/LtqvokU9pPknOS/Mpbz4HfAw4whcdaVb0KvJzkA93QFuAg4+pl0h8yDPFhxHXAPzOYD/2TSdczQv0PAceAnzP4Db6NwVzoXuAF4O+Bcydd5zJ7+RCD/3X8AfBM93PdNPYD/BbwdNfLAeBPu/HfAL4LHAb+GvjlSdc6Qm8fAR6b5n66ur/f/Tz31n/703isdXVfCsx3x9vfAmvG1Yu3H5CkBk3LtIwkaQiGuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSgwx3SWrQ/wJ3eeD1vPXiQgAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "import matplotlib.pyplot as plt\n", "# Plot distribution of n_stops\n", "plt.hist(routes[:,1])" ] }, { "cell_type": "code", "execution_count": 95, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[0]" ] }, "execution_count": 95, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(range(0,-1,-1))" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[[[], [<__main__.RouteLabel at 0x7fd99af341d0>]],\n", " [[], [<__main__.RouteLabel at 0x7fd99af341d0>]]]" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l = [[[RouteLabel(1,1,0,1,TargetLabel(p_t, tau_0),1)] for _ in range(2)]]\n", "l.append(l[-1].copy())\n", "l[1][0].remove(l[1][0][0])\n", "l" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "None\n" ] }, { "data": { "text/plain": [ "[0, 1, 3, 4, 5]" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l = list(range(6))\n", "ret = l.remove(2)\n", "print(ret)\n", "l" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " Departure at 2020-05-11T08:00 from stop 0.\n", " Departure at 2020-05-11T08:10 from stop 0.\n" ] } ], "source": [ "B = [RouteLabel(1,1,0,0,TargetLabel(p_t, tau_0),0.8), RouteLabel(1,1,0,1,TargetLabel(p_t, tau_0),1)]\n", "B[0].update_stop(0)\n", "B[1].update_stop(0)\n", "for l in B:\n", " l.pprint()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " Departure at 2020-05-11T08:20 from stop 0.\n", "True\n", " Departure at 2020-05-11T08:10 from stop 0.\n", " Departure at 2020-05-11T08:20 from stop 555.\n", "----------\n", " Departure at 2020-05-11T08:20 from stop 555.\n" ] } ], "source": [ "label = RouteLabel(4,0, 2, 0, TargetLabel(p_t, tau_0), 0.9)\n", "label.update_stop(0)\n", "label.pprint()\n", "print(update_bag(B, label, 0))\n", "label.stop = 555\n", "for l in B:\n", " l.pprint()\n", "print('-'*10)\n", "label.pprint()" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[[1, 2, 3], [1, 2, 666]]" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bags = [[1,2,3]]\n", "bags.append(bags[-1].copy())\n", "bags[1][2] = 666\n", "bags" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "p_s = 0 # start stop = A\n", "p_t = 4 # target stop = E\n", "tau_0 = np.datetime64('2020-05-11T08:05') # departure time 08:05\n", "k_max = 10 # we set a maximum number of transports to pre-allocate memory for the numpy array tau_i" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# initialization\n", "n_stops = len(stops)\n", "\n", "# earliest arrival time at each stop for each round.\n", "tau = np.full(shape=(k_max, n_stops), fill_value = np.datetime64('2100-01-01T00:00')) # 2100 instead of infinity # number of stops * max number of transports\n", "\n", "# earliest arrival time at each stop, indep. of round\n", "tau_star = np.full(shape=n_stops, fill_value = np.datetime64('2100-01-01T00:00'))\n", "\n", "marked = [p_s]\n", "q = []\n", "tau[0, p_s] = tau_0" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "np.where(routeStops[routes[r][2]:routes[r][2]+routes[r][1]] == p_i)[0][0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "routeStops[routes[r][2]:routes[r][2]+routes[r][1]] == p_i" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "p_i" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "t_r_dep = stopTimes[routes[r][3]+\\\n", " # offset corresponding to stop p_i in route r\n", " np.where(routeStops[routes[r][2]:routes[r][2]+routes[r][1]] == p_i)[0][0] + \\\n", " routes[r][1]*t_r][1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if np.where(routeStops[routes[1][2]:routes[1][2]+routes[1][1]] == 2) <\\\n", "np.where(routeStops[routes[1][2]:routes[1][2]+routes[1][1]] == 3):\n", " print(\"hello\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "routeStops[routes[1][2] + np.where(routeStops[routes[1][2]:routes[1][2]+routes[1][1]] == 2)[0][0]:routes[1][2]+routes[1][1]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "routeStops[routes[1][2] + np.where(routeStops[routes[1][2]:routes[1][2]+routes[1][1]] == 2)[0][0]:6]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "routeStops[routes[1][2]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "routeStops[np.where(routeStops[routes[1][2]:routes[1][2]+routes[1][1]] == 2)[0][0]]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if True and \\\n", " True:\n", " print(\"hello\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tau[0][0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "stopTimes[3][1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "a = np.arange(1, 10)\n", "a" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "a[1:10:2]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stopTimes[routes[0][3]+\\\n", " # offset corresponding to stop p_i in route r\n", " np.where(routeStops[routes[0][2]:routes[0][2]+routes[0][1]] == 0)[0][0]:\\\n", " # end of the trips of r\n", " routes[0][3]+routes[0][0]*routes[0][1]:\\\n", " # we can jump from the number of stops in r to find the next departure of route r at p_i\n", " routes[0][1]\n", " ]\n", "# we may more simply loop through all trips, and stop as soon as the departure time is after the arrival time\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stopTimes[routes[0][3]+\\\n", " # offset corresponding to stop p_i in route r\n", " np.where(routeStops[routes[0][2]:routes[0][2]+routes[0][1]] == 0)[0][0]][1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stopTimes[routes[1][3]+\\\n", " # offset corresponding to stop p_i in route r\n", " np.where(routeStops[routes[1][2]:routes[1][2]+routes[1][1]] == 3)[0][0] + \\\n", " routes[1][1]*1][1]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# t_r is a trip that belongs to route r. t_r can take value 0 to routes[r][0]-1\n", "t = None\n", "r = 1\n", "tau_k_1 = tau[0][0]\n", "p_i = 3\n", "\n", "t_r = 0\n", "while True:\n", " \n", " t_r_dep = stopTimes[routes[r][3]+\\\n", " # offset corresponding to stop p_i in route r\n", " np.where(routeStops[routes[r][2]:routes[r][2]+routes[r][1]] == p_i)[0][0] + \\\n", " routes[r][1]*t_r][1]\n", " \n", " if t_r_dep > tau_k_1:\n", " # retrieving the index of the departure time of the trip in stopTimes\n", " #t = routes[r][3] + t_r * routes[r][1]\n", " t = t_r\n", " break\n", " t_r += 1\n", " # we could not hop on any trip at this stop\n", " if t_r == routes[r][0]:\n", " break\n", " \n", "print(\"done\")\n", "print(t)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "r = 1\n", "t = 1\n", "p_i = 2\n", "# 1st trip of route + offset for the right trip + offset for the right stop\n", "stopTimes[routes[r][3] + t * routes[r][1] + np.where(routeStops[routes[r][2]:routes[r][2]+routes[r][1]] == p_i)]" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "d = []\n", "not d" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "r = 1\n", "t = 0\n", "p_i = 4\n", "arr_t_p_i = stopTimes[routes[r][3] + \\\n", " t * routes[r][1] + \\\n", " np.where(routeStops[routes[r][2]:routes[r][2]+routes[r][1]] == p_i)[0][0]][0]\n", "arr_t_p_i" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "np.datetime64('NaT') > np.datetime64('2100-01-01')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "np.datetime64('NaT') < np.datetime64('2100-01-01')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "jupytext": { "formats": "ipynb,md,py:percent" }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }