Tutorial: Batch Processing

This tutorial explains how to use the batch processing script to solve CommonRoad planning problems in parallel. The configuration for batch processing is stored in batch_processing_config.yaml. Some of the parameters are explained as follows:

  • input_path: input directory of your intended CommonRoad scenarios.
  • output_path: output directory of CommonRoad solution files.
  • overwrite: whether the existing solution files should be overwritten.
  • validate_solution: check the validity of the solutions with the feasibility checker.
  • num_worker_processes: the number of parallel executions of motion planners.

Parameters specified under the default block will be applied to all scenarios. If you wish to specify a different paramter for specific scenarios, simply insert a new block with the content of the default block copied, and overwrite parameters therein. This new block should be named after the ID of the sceanrio that you wish to aplly the parameters to. Related parameters are explained as follows:

  • vehicle_model: model of the vehicle, valid values: PM, KS, ST and MB. Refer to Vehicle Models for more information.
  • vehicle_type: type of the vehicle, valid values: FORD_ESCORT, BMW_320i and VW_VANAGON.
  • cost_function: id of cost function. Refer to Cost Functions for more information.
  • planner: the planner that is used to solve for solutions, possible values are: bfs, dfs, dls, ucs, gbfs, astar, student, student_example
  • planning_problem_idx: index of the planning problem. for cooperative scenarios: 0, 1, 2, ..., otherwise: 0
  • max_tree_depth: maximum depth of the search tree
  • timeout: timeout time for motion planner [s].

Note: the paths can either be relative or absolute. To start the search with batch processing, you can either directly run SMP/batch_processing/batch_processing_parallel.py in IDEs (e.g. PyCharm) with commonroad-search/ marked as sources root, or run the following script.

Parallel Batch Processing

In parallel batch processing, the search are carried out on multiple threads simultaneously. This reduces the overall time required to test your algorithm on all the given scenarios. One drawback is that it is not very easy to debug your code with parallel batch processing.

In [1]:
%load_ext autoreload
%autoreload 2

import os
import sys

# add the folder containing batch processing script into python path
sys.path.append(os.path.join(os.getcwd(), "../../"))

from SMP.batch_processing.batch_processing_parallel import run_parallel_processing
In [2]:
run_parallel_processing()
Config file loaded and logger created.
18 scenarios skipped.
ScenarioLoader Mode <RANDOM>
Processing 3 scenarios:
   1 DEU_Guetersloh-40_4_T-1
   2 DEU_Speyer-2_4_T-1
   3 HRV_Pula-7_2_T-1
Automaton loaded for vehicle type: BMW_320i
Motion planner: astar
Number of parallel processes: 6

==================================================
Scenario being processed:	         1
Solution found:               	         0
Solution found but invalid:   	         0
Solution not found:           	         0
Exception occurred:           	         0
Time out:                     	         0
==================================================

==================================================
Scenario being processed:	         2
Solution found:               	         0
Solution found but invalid:   	         0
Solution not found:           	         0
Exception occurred:           	         0
Time out:                     	         0
==================================================

==================================================
Scenario being processed:	         3
Solution found:               	         0
Solution found but invalid:   	         0
Solution not found:           	         0
Exception occurred:           	         0
Time out:                     	         0
==================================================
==============================        Search Results        ==============================
[DEU_Guetersloh-40_4_T-1       ]	<SUCCESS>	 Time [ms]:	   545	
[DEU_Speyer-2_4_T-1            ]	<SUCCESS>	 Time [ms]:	   431	
[HRV_Pula-7_2_T-1              ]	<SUCCESS>	 Time [ms]:	  1517	
==============================        Solution found        ==============================
	- DEU_Speyer-2_4_T-1
	- DEU_Guetersloh-40_4_T-1
	- HRV_Pula-7_2_T-1

==============================        Result Summary        ==============================
Total number of scenarios:  	         3
Solution found:               	         3
Solution found but invalid:   	         0
Solution not found:           	         0
Exception occurred:           	         0
Time out:                     	         0

Sequential Batch Processing

Alternatively, one can use the SMP/batch_processing/batch_processing_sequential.py script to carry out the search sequentially on a single thread. This is a more user-friendly approach if you wish you debug your code in IDES (e.g. creating breakpoints in PyCharm) but still have it run against multiple scenarios.

In [ ]:
from SMP.batch_processing.batch_processing_sequential import run_sequential_processing
run_sequential_processing()