Skip to main content

A solver for real-time vehicle routing problems

Project description

Online-RTV

Code example

Initialize

from online_rtv_solver import OnlineRTVSolver

# Initialize the RTV solver with the URL of the OSRM server
online_rtv_solver = OnlineRTVSolver("http://127.0.0.1:50000/")

Initialize

driver_runs = online_rtv_solver.solve_rtv(current_time,new_payload)

Generating a manifest

current_time = 5*3600+30*60 # 05:30:00 pm
driver_runs = online_rtv_solver.solve_rtv(current_time,new_payload)

Simulate the vehicles

current_time = 5*3600+40*60+00 # Simulate to 05:40:00 pm
new_driver_runs = online_rtv_solver.simulate_manifest(current_time,new_payload["date"],driver_runs)

Payload format

Common format

{
    
    'depot': {
        'loc': {'lat': float, 'lon': float, 'node_id': int}
    }, 
    'date': 'yyyy-mm-dd', 
    'driver_runs': [],
    'requests': []
    
}

Requests

{
    
    'requests': [ {
        'am': int,
        'wc': int,
        'pickup_time_window_start': int,
        'pickup_time_window_end': int,
        'pickup_pt': {'lat': float, 'lon': float, 'node_id': int},
        'booking_id': int,
        'dropoff_time_window_start': int,
        'dropoff_time_window_end': int,
        'dropoff_pt': {'lat': float, 'lon': float, 'node_id': int}
    }] 
    
}

DriverRun

{
    
    'DriverRun': [ {
        'state': {
            'run_id': int,
            'start_time': int,
            'end_time': int,
            'am_capacity': int,
            'wc_capacity': int,
            'locations_already_serviced': int,
            'locations_dt_seconds': int,
            'loc': {'lat': float, 'lon': float, 'node_id': int},
            'total_locations': int,
        },
        'manifest': Stop[list]
    }] 
    
}

Stop

{
    
    'Stop': [ {
        'run': int,
        'booking_id': int,
        'order': int,
        'action': string,
        'loc': {'lat': float, 'lon': float, 'node_id': int}
        'scheduled_time': int,
        'am': int,
        'wc': int,
        'time_window_start': int,
        'time_window_end': int,
    }] 
    
}

rolling-horizen-RTV

Running

  • Set up an osrm server. Follow https://github.com/Project-OSRM/osrm-backend
  • cd into the src folder.
  • run python main.py --server_url "" --input_file "" --out_put_dir "" --interval 300 --rh_factor 0 --max_cardinality 4
  • Required parameters:
    • server_url: Url of the OSRM server (ex: "http://127.0.0.1:5000/")
    • input_file: path to the payload.pkl file
    • out_put_dir: directory to record outputs
    • interval: interval for the rolling horizon and batching
    • rh_factor: rolling horizon factor
    • max_cardinality: meximum size of shared trips

Set up the OSRM Server

wget https://download.geofabrik.de/north-america/us/north-carolina-latest.osm.pbf
docker run -t -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-extract -p /opt/car.lua /data/north-carolina-latest.osm.pbf || echo "osrm-extract failed"
docker run -t -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-partition /data/north-carolina-latest.osrm || echo "osrm-partition failed"
docker run -t -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-customize /data/north-carolina-latest.osrm || echo "osrm-customize failed"
docker run -t -i -p 5000:5000 -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-routed --algorithm mld /data/north-carolina-latest.osrm

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rtv_solver-0.1.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rtv_solver-0.1.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file rtv_solver-0.1.1.tar.gz.

File metadata

  • Download URL: rtv_solver-0.1.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for rtv_solver-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a1565e020554a7031ded96bff19b4703a6959aa3dcd4b183a2e22566eb96d87c
MD5 d0ea668fe091678cf4e6091ac50a6fc0
BLAKE2b-256 39ff8aa3663663d9a47d7406d87e885bd2705978569e8044e8c4d2b73a22a5a7

See more details on using hashes here.

File details

Details for the file rtv_solver-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: rtv_solver-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for rtv_solver-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a7cdf30dbd676d46dd6b18be1facdba806323fbdb92e06fe36b243ebbd5f51a
MD5 9a0b6d5c53d896e4f68de9019f09107c
BLAKE2b-256 7a4adfc6dab7314353870949beaf8eff6424ac5f5aabf641a435ba87facd09c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page