Skip to content
Pablo Hoch edited this page May 21, 2021 · 10 revisions

MOTIS Tools

List of tools

  • motis-generator: Generate random routing requests between stations
  • motis-intermodal-generator: Generate random intermodal routing requests between geo coordinates
  • motis-comparator: Compare routing results
  • motis-intermodal-comparator: Compare routing results (supports all routing responses, including intermodal responses)
  • motis-analyzer: Prints routing statistics (timings, memory usage...)
  • motis-print-journey: Prints routing responses
  • motis-xtract: Creates schedule subsets
  • motis-query-rewrite: Changes the target of all messages in a file

Tools are not built by default. To build an individual tool, specify the tool name as target. To build all tools use targets motis-eval and motis-intermodal-eval:

ninja motis-eval motis-intermodal-eval

Random routing query generation

Random queries between two stations can be generated using motis-generator. Random queries between two geo coordinates can be generated using motis-intermodal-generator. For usage information, invoke the tool using --help.

Example: Generate 100 random PreTrip queries between stations for the routing and csa module:

motis-generator -c config.ini \
  --query_count 100 \
  --query_type pretrip \
  --targets /routing \
  --targets /csa/cpu

config.ini should include the basic dataset configuration (schedule location, date etc.).

This example generates four output files:

  • queries-fwd-routing.txt: Forward queries for target /routing
  • queries-bwd-routing.txt: Backward queries for target /routing
  • queries-fwd-csa_cpu.txt: Forward queries for target /csa/cpu
  • queries-bwd-csa_cpu.txt: Backward queries for target /csa/cpu

Each file contains one query (JSON) per line and can be processed by MOTIS in batch mode. The same queries are generated for each target (in the same order and using the same message ids).

To create a new file for a different target but with the same routing queries, use motis-query-rewrite, e.g.:

motis-query-rewrite --in queries-fwd-routing.txt --out queries-fwd-csa_cpu.txt --target /csa/cpu

Display routing result

Routing results (including intermodal results) can be displayed in a human-readable format using motis-print-journey. Timestamps can be printed in UTC (-u / --utc) or local time (-l / --local).

Examples:

# print all connections in the file
motis-print-journey -l result.txt
# print all connections of the first result
head -n 1 results-fwd-routing.txt | motis-print-journey -l -

Compare routing results

To compare two routing responses (e.g. the results of two different routing algorithms for the same query), motis-comparator or motis-intermodal-comparator can be used. motis-intermodal-comparator supports all routing results, including those without intermodal connections.

Example: You have generated random connections using motis-generator (as described above), executed the queries in batch mode and want to compare the results generated by the routing and csa modules:

motis-intermodal-comparator results-fwd-routing.txt results-fwd-csa_cpu.txt

This will compare all routing results in the specified files. Results are matched by message id. Differences between results are displayed and responses that don't match are written to an output directory (fail by default, see --fail) for further inspection.

Clone this wiki locally