batch_processing.ipynb 23.7 KB
Newer Older
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Tutorial: Batch Processing"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This tutorial shows how to solve for solutions to different scenarios in a batch processing fashion. You can find all realted files in [this](https://gitlab.lrz.de/tum-cps/commonroad_io/tree/batch_processing) repository. The main components are:\n",
    "* a configuration file (.yaml format),\n",
    "* some helper functions,\n",
    "* and the script below to call the planer function.\n",
    "\n",
    "Before proceeding, you should make sure the configuration file is set correctly. Here are the explanation for each of the parameters in the configuration file:\n",
    "* **input_path**: input directory of CommonRoad scenarios that you indend to solve.\n",
    "* **output_path**: output directory of the solution files.\n",
    "* **overwrite**: flag to determine whether the existing solution files should be overwritten.\n",
    "* **timeout**: timeout time for your motion planner, unit in seconds\n",
    "* **motion_planner_path**: directory where the module containing the function to execute your motion planner is located\n",
    "* **motion_planner_module_name**: name of the module that contains the function to execute your motion planner\n",
    "* **motion_planner_function_name**: name of the function that executes your motion planner\n",
    "* **default**: parameters specified under this section will be applied to all scenarios. If you wish to specify a different paramter for specific scenarios, simply copy the section and replace 'default' with the id of your scenario.\n",
    "* **vehicle_model**: model of the vehicle, valid values: **PM, KS, ST and MB**. Please refer to [Vehicle Models](https://gitlab.lrz.de/tum-cps/commonroad-vehicle-models/blob/master/vehicleModels_commonRoad.pdf) for more information.\n",
    "* **vehicle_type**: type of the vehicle, valid values: **FORD_ESCORT, BMW_320i and VW_VANAGON**.\n",
    "* **cost_function**: identifier of cost function. Please refer to [Cost Functions](https://gitlab.lrz.de/tum-cps/commonroad-cost-functions/blob/master/costFunctions_commonRoad.pdf) for more information.\n",
    "* **planner_id**: id of the planner that is used to solve for solutions. in this example, 1 = Greedy Best First Search, 2 = A*, else = Your own planner.\n",
    "* **planning_problem_idx**: planner problem index. for cooperative scenarios: 0, 1, 2, ..., otherwise: 0\n",
    "* **max_tree_depth**: maximum permissible depth of the search tree\n",
    "\n",
    "Note: the paths can be either **relative** to this script or **absolute**.\n",
    "\n",
    "Simply run the following script to start batch processing. The results here is just exemplary, you will see different output as your configuration varies."
   ]
  },
  {
   "cell_type": "code",
42
   "execution_count": 1,
43
   "metadata": {},
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total number of files to be processed: 297\n",
      "Timeout setting: 120 seconds\n",
      "\n",
      "Processing file No. 1 / 297. Scenario ID: CHN_Sha-16_2_T-1\n",
      "Reading motion primitives...\n",
      "Automata created.\n",
      "Number of loaded primitives: 3066\n",
      "add_initial_state_to_automata() got an unexpected keyword argument 'flag_print_states'\n",
      "<FAILURE> Solution not Found\n",
      "======================================================================\n",
      "Processing file No. 2 / 297. Scenario ID: CHN_Sha-17_1_T-1\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[0;31mKeyboardInterrupt\u001B[0m                         Traceback (most recent call last)",
      "\u001B[0;32m<ipython-input-1-c4fa63224ee7>\u001B[0m in \u001B[0;36m<module>\u001B[0;34m\u001B[0m\n\u001B[1;32m     27\u001B[0m     \u001B[0mprint\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m\"Processing file No. {} / {}. Scenario ID: {}\"\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mformat\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mcount_processed\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mnum_files\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mfile_scenario\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m-\u001B[0m\u001B[0;36m4\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     28\u001B[0m     \u001B[0;31m# parse the scenario file\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m---> 29\u001B[0;31m     \u001B[0mresult_parse\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mparse_scenario_file\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mconfiguration\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mfile_scenario\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     30\u001B[0m     \u001B[0;31m# execute target function\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m     31\u001B[0m     \u001B[0msolution_trajectories\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mexecute_target_function\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mfunction_target\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mresult_parse\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mtime_timeout\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m/media/sebastian/TUM/05_teaching/gems_of_informatic/commonroad-search-cps/notebooks/batch_processing/script/helper_functions.py\u001B[0m in \u001B[0;36mparse_scenario_file\u001B[0;34m(configuration, file_scenario)\u001B[0m\n\u001B[1;32m    120\u001B[0m     '''\n\u001B[1;32m    121\u001B[0m     \u001B[0mpath_file_full\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mos\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mpath\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mjoin\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mconfiguration\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0;34m'input_path'\u001B[0m\u001B[0;34m]\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mfile_scenario\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 122\u001B[0;31m     \u001B[0mscenario\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mplanning_problem_set\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mCommonRoadFileReader\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mpath_file_full\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mopen\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    123\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    124\u001B[0m     \u001B[0;31m# get configuration for each scenario\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py\u001B[0m in \u001B[0;36mopen\u001B[0;34m(self)\u001B[0m\n\u001B[1;32m     81\u001B[0m         \"\"\"\n\u001B[1;32m     82\u001B[0m         \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_read_header\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---> 83\u001B[0;31m         \u001B[0mscenario\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_open_scenario\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     84\u001B[0m         \u001B[0mplanning_problem_set\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_open_planning_problem_set\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mscenario\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mlanelet_network\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m     85\u001B[0m         \u001B[0;32mreturn\u001B[0m \u001B[0mscenario\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mplanning_problem_set\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py\u001B[0m in \u001B[0;36m_open_scenario\u001B[0;34m(self)\u001B[0m\n\u001B[1;32m    101\u001B[0m         \"\"\"\n\u001B[1;32m    102\u001B[0m         scenario = ScenarioFactory.create_from_xml_node(self._tree, self._dt, self._benchmark_id,\n\u001B[0;32m--> 103\u001B[0;31m                                                         self._commonroad_version, self._meta_data)\n\u001B[0m\u001B[1;32m    104\u001B[0m         \u001B[0;32mreturn\u001B[0m \u001B[0mscenario\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    105\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py\u001B[0m in \u001B[0;36mcreate_from_xml_node\u001B[0;34m(cls, xml_node, dt, benchmark_id, commonroad_version, meta_data)\u001B[0m\n\u001B[1;32m    203\u001B[0m         \u001B[0mscenario\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0madd_objects\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mLaneletNetworkFactory\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mcreate_from_xml_node\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mxml_node\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    204\u001B[0m         \u001B[0;32mif\u001B[0m \u001B[0mcommonroad_version\u001B[0m \u001B[0;34m==\u001B[0m \u001B[0;34m'2018b'\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 205\u001B[0;31m             \u001B[0mscenario\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0madd_objects\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mcls\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_obstacles_2018b\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mxml_node\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mscenario\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mlanelet_network\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    206\u001B[0m             \u001B[0;32mfor\u001B[0m \u001B[0mkey\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mvalue\u001B[0m \u001B[0;32min\u001B[0m \u001B[0mLaneletFactory\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_speed_limits\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mitems\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    207\u001B[0m                 \u001B[0;32mfor\u001B[0m \u001B[0mlanelet\u001B[0m \u001B[0;32min\u001B[0m \u001B[0mvalue\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py\u001B[0m in \u001B[0;36m_obstacles_2018b\u001B[0;34m(cls, xml_node, lanelet_network)\u001B[0m\n\u001B[1;32m    240\u001B[0m                 \u001B[0mobstacles\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mappend\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mStaticObstacleFactory\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mcreate_from_xml_node\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mo\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mlanelet_network\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    241\u001B[0m             \u001B[0;32melif\u001B[0m \u001B[0mo\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mfind\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m'role'\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mtext\u001B[0m \u001B[0;34m==\u001B[0m \u001B[0;34m'dynamic'\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 242\u001B[0;31m                 \u001B[0mobstacles\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mappend\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mDynamicObstacleFactory\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mcreate_from_xml_node\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mo\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mlanelet_network\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    243\u001B[0m             \u001B[0;32melse\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    244\u001B[0m                 \u001B[0;32mraise\u001B[0m \u001B[0mValueError\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m'Role of obstacle is unknown. Got role: {}'\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mformat\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mxml_node\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mfind\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m'role'\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mtext\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/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py\u001B[0m in \u001B[0;36mcreate_from_xml_node\u001B[0;34m(cls, xml_node, lanelet_network)\u001B[0m\n\u001B[1;32m   1047\u001B[0m                                                                         lanelet_network, obstacle_id, shape)\n\u001B[1;32m   1048\u001B[0m             center_lanelet_assignment = cls.find_obstacle_center_lanelets(initial_state, trajectory.state_list,\n\u001B[0;32m-> 1049\u001B[0;31m                                                                           lanelet_network)\n\u001B[0m\u001B[1;32m   1050\u001B[0m             \u001B[0mprediction\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mTrajectoryPrediction\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mtrajectory\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mshape\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mcenter_lanelet_assignment\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mshape_lanelet_assignment\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m   1051\u001B[0m         \u001B[0;32melif\u001B[0m \u001B[0mxml_node\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mfind\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m'occupancySet'\u001B[0m\u001B[0;34m)\u001B[0m \u001B[0;32mis\u001B[0m \u001B[0;32mnot\u001B[0m \u001B[0;32mNone\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/common/file_reader.py\u001B[0m in \u001B[0;36mfind_obstacle_center_lanelets\u001B[0;34m(initial_state, state_list, lanelet_network)\u001B[0m\n\u001B[1;32m   1020\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m   1021\u001B[0m         \u001B[0;32mfor\u001B[0m \u001B[0mstate\u001B[0m \u001B[0;32min\u001B[0m \u001B[0mcompl_state_list\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m-> 1022\u001B[0;31m             \u001B[0mlanelet_ids\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mlanelet_network\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mfind_lanelet_by_position\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0mstate\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mposition\u001B[0m\u001B[0;34m]\u001B[0m\u001B[0;34m)\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[0m\n\u001B[0m\u001B[1;32m   1023\u001B[0m             \u001B[0mlanelet_ids_per_state\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0mstate\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mtime_step\u001B[0m\u001B[0;34m]\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mset\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mlanelet_ids\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m   1024\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/scenario/lanelet.py\u001B[0m in \u001B[0;36mfind_lanelet_by_position\u001B[0;34m(self, point_list)\u001B[0m\n\u001B[1;32m   1206\u001B[0m             \u001B[0mmapped\u001B[0m \u001B[0;34m=\u001B[0m \u001B[0mlist\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   1207\u001B[0m             \u001B[0;32mfor\u001B[0m \u001B[0mlanelet_id\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mpoly\u001B[0m \u001B[0;32min\u001B[0m \u001B[0mpolygons\u001B[0m\u001B[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m-> 1208\u001B[0;31m                 \u001B[0;32mif\u001B[0m \u001B[0mpoly\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mcontains_point\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mpoint\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   1209\u001B[0m                     \u001B[0mmapped\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mappend\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mlanelet_id\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m   1210\u001B[0m             \u001B[0mres\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mappend\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mmapped\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m/media/sebastian/TUM/06_code/commonroad/commonroad-io/commonroad-io-cps/commonroad/geometry/shape.py\u001B[0m in \u001B[0;36mcontains_point\u001B[0;34m(self, point)\u001B[0m\n\u001B[1;32m    375\u001B[0m                                                 \u001B[0;34m'not a vector of real numbers of length 2. point = {}'\u001B[0m\u001B[0;31m\\\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    376\u001B[0m                                                 \u001B[0;34m.\u001B[0m\u001B[0mformat\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mpoint\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 377\u001B[0;31m         \u001B[0;32mreturn\u001B[0m \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_shapely_polygon\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mintersects\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mshapely\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mgeometry\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mPoint\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mpoint\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    378\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    379\u001B[0m     \u001B[0;32mdef\u001B[0m \u001B[0m__str__\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mself\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~/anaconda3/envs/commonroad-py36/lib/python3.6/site-packages/shapely/geometry/base.py\u001B[0m in \u001B[0;36mintersects\u001B[0;34m(self, other)\u001B[0m\n\u001B[1;32m    709\u001B[0m     \u001B[0;32mdef\u001B[0m \u001B[0mintersects\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[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    710\u001B[0m         \u001B[0;34m\"\"\"Returns True if geometries intersect, else False\"\"\"\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0;32m--> 711\u001B[0;31m         \u001B[0;32mreturn\u001B[0m \u001B[0mbool\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0mimpl\u001B[0m\u001B[0;34m[\u001B[0m\u001B[0;34m'intersects'\u001B[0m\u001B[0;34m]\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[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[0m\u001B[1;32m    712\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m    713\u001B[0m     \u001B[0;32mdef\u001B[0m \u001B[0moverlaps\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[0;34m:\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n",
      "\u001B[0;32m~/anaconda3/envs/commonroad-py36/lib/python3.6/site-packages/shapely/predicates.py\u001B[0m in \u001B[0;36m__call__\u001B[0;34m(self, this, other, *args)\u001B[0m\n\u001B[1;32m     10\u001B[0m \u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m     11\u001B[0m     \u001B[0;32mdef\u001B[0m \u001B[0m__call__\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mself\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mthis\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mother\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0;34m*\u001B[0m\u001B[0margs\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---> 12\u001B[0;31m         \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_validate\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mthis\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     13\u001B[0m         \u001B[0mself\u001B[0m\u001B[0;34m.\u001B[0m\u001B[0m_validate\u001B[0m\u001B[0;34m(\u001B[0m\u001B[0mother\u001B[0m\u001B[0;34m,\u001B[0m \u001B[0mstop_prepared\u001B[0m\u001B[0;34m=\u001B[0m\u001B[0;32mTrue\u001B[0m\u001B[0;34m)\u001B[0m\u001B[0;34m\u001B[0m\u001B[0;34m\u001B[0m\u001B[0m\n\u001B[1;32m     14\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;31mKeyboardInterrupt\u001B[0m: "
     ]
    }
   ],
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
   "source": [
    "# import helper functions\n",
    "from helper_functions import *\n",
    "\n",
    "# specify path to configuration file\n",
    "path_file_config = \"../configuration/batch_processing_config.yaml\"\n",
    "\n",
    "# load configuration file\n",
    "configuration = load_configuration(path_file_config)\n",
    "\n",
    "# get target function\n",
    "function_target = get_target_function(configuration)\n",
    "\n",
    "# get a list of scenario files\n",
    "list_files_input = get_input_files(configuration)\n",
    "\n",
    "# get length of the list and time before timeout\n",
    "num_files = len(list_files_input)\n",
    "time_timeout = configuration['timeout']\n",
    "\n",
    "print(\"Total number of files to be processed: {}\".format(num_files))\n",
    "print(\"Timeout setting: {} seconds\\n\".format(time_timeout))\n",
    "count_processed = 0\n",
    "\n",
    "# iterate through scenarios\n",
    "for file_scenario in list_files_input:\n",
    "    count_processed += 1\n",
    "    print(\"Processing file No. {} / {}. Scenario ID: {}\".format(count_processed, num_files, file_scenario[:-4]))\n",
    "    # parse the scenario file\n",
    "    result_parse = parse_scenario_file(configuration, file_scenario)\n",
    "    # execute target function\n",
    "    solution_trajectories = execute_target_function(function_target, result_parse, time_timeout)\n",
    "    # save solution file\n",
    "    save_solution(configuration, solution_trajectories, result_parse)\n",
    "    print(\"{:=^70s}\".format(''))"
   ]
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
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
159
160
161
162
  }
 ],
 "metadata": {
  "kernelspec": {
163
   "display_name": "Python 3",
164
   "language": "python",
165
   "name": "python3"
166
167
168
169
170
171
172
173
174
175
176
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
177
   "version": "3.6.7"
178
179
180
181
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
182
}