Chapter 8. Configure and run OptaWeb Vehicle Routing manually

The easiest way to run OptaWeb Vehicle Routing is to use the runlocally.sh script. However, if Bash is not available on your system you can manually complete the steps that the runlocally.sh script performs.

Prerequisites

Procedure

  1. Download routing data.

    The routing engine requires geographical data to calculate the time it takes vehicles to travel between locations. You must download and store OpenStreetMap (OSM) data files on the local file system before you run OptaWeb Vehicle Routing.

    Note

    The OSM data files are typically between 100 MB to 1 GB and take time to download so it is a good idea to download the files before building or starting the OptaWeb Vehicle Routing application.

    1. Open http://download.geofabrik.de/ in a web browser.
    2. Click a region in the Sub Region list, for example Europe. The subregion page opens.
    3. In the Sub Regions table, download the OSM file (.osm.pbf) for a country, for example Belgium.
  2. Create the data directory structure.

    OptaWeb Vehicle Routing reads and writes several types of data on the file system. It reads OSM (OpenStreetMap) files from the openstreetmap directory, writes a road network graph to the graphhopper directory, and persists user data in a directory called db. Create a new directory dedicated to storing all of these data to make it easier to upgrade to a newer version of OptaWeb Vehicle Routing in the future and continue working with the data you created previously.

    1. Create the $HOME/{VRP-DATA-DIR} directory.
    2. Create the openstreetmap directory in the $HOME/{VRP-DATA-DIR} directory:

      $HOME/{VRP-DATA-DIR}
      └── openstreetmap
    3. Move all of your downloaded OSM files (files with the extension .osm.pbf) to the openstreetmap directory.

      The rest of the directory structure is created by the OptaWeb Vehicle Routing application when it runs for the first time. After that, your directory structure is similar to the following example:

      $HOME/{VRP-DATA-DIR}
      
      ├── db
      │   └── vrp.mv.db
      ├── graphhopper
      │   └── belgium-latest
      └── openstreetmap
          └── belgium-latest.osm.pbf
  3. Change directory to optaweb-vehicle-routing-distribution-7.48.0.Final-redhat-00004/sources/optaweb-vehicle-routing-standalone/target.
  4. To run OptaWeb Vehicle Routing, enter the following command:

    java -jar optaweb-vehicle-routing-standalone-7.48.0.Final-redhat-00004.jar \
    --app.persistence.h2-dir=$HOME/{VRP-DATA-DIR}/db \
    --app.routing.gh-dir=$HOME/{VRP-DATA-DIR}/graphhopper \
    --app.routing.osm-dir=$HOME/{VRP-DATA-DIR}/openstreetmap \
    --app.routing.osm-file=<OSM_FILE_NAME> \
    --app.region.country-codes=<COUNTRY_CODE_LIST> \

    In this command, replace the following variables:

    • <OSM_FILE_NAME>: The OSM file for the region that you want to use and that you downloaded previously
    • <COUNTRY_CODE_LIST>: A comma-separated list of country codes used to filter geosearch queries. For a list of country codes, see ISO 3166 Country Codes.

      The application starts after the OSM file is downloaded.

      In the following example, OptaWeb Vehicle Routing downloads the OSM map of Central America (central-america-latest.osm.pbf) and searches in the countries Belize (BZ) and Guatemala (GT).

      java -jar optaweb-vehicle-routing-standalone-7.48.0.Final-redhat-00004.jar \
      --app.persistence.h2-dir=/home/user/.optaweb-vehicle-routing/db \
      --app.routing.osm-dir=/home/user/.optaweb-vehicle-routing/openstreetmap \
      --app.routing.gh-dir=/home/user/.optaweb-vehicle-routing/graphhopper \
      --app.routing.osm-file=central-america-latest.osm.pbf \
      --app.region.country-codes=BZ,GT
  5. To open the OptaWeb Vehicle Routing user interface, enter the following URL in a web browser:

    http://localhost:8080