A solver for real-time vehicle routing problems
Project description
Online-RTV
Installation
pip install rtv-solver
Code example
Initialize
from 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/")
Check feasibility of time slots
payload = {
"requests": [
{
'am': int,
'wc': int,
'time_windows' : [
{'pickup_time_window_start': int, 'pickup_time_window_end': int, 'dropoff_time_window_start': int, 'dropoff_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}
}],
"driver_runs": driver_runs
}
feasibility = online_rtv_solver.check_feasibility(payload)
feasibility <-- [(feasible_window,vmt/pmt ratio)]
Generating a manifest
current_time = 5*3600+30*60 # 05:30:00 pm
driver_runs, unserved_requests = online_rtv_solver.solve_rtv(current_time, new_payload)
unserved_requests <-- [list of ids of the requests that are not feasible to serve]
Fast option
driver_runs, unserved_requests = online_rtv_solver.solve_rtv_fast(new_payload)
unserved_requests <-- [list of ids of the requests that are not feasible to serve]
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, 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,
}]
}
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
Building
python -m build
twine upload dist/rtv_solver-[version]*
Project details
Release history Release notifications | RSS feed
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.10.tar.gz
(9.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rtv_solver-0.1.10.tar.gz.
File metadata
- Download URL: rtv_solver-0.1.10.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6063ac323a2667537ba4c2ccc6ea06da3c7fbc242a7682709f489ad19459add
|
|
| MD5 |
74915e74451e72502c13d5c3bc0df4c6
|
|
| BLAKE2b-256 |
b4bd67763f046c59a1c08a301f67c6a97ee1dd5ec0a181bd673f4a2e8a08c169
|
File details
Details for the file rtv_solver-0.1.10-py3-none-any.whl.
File metadata
- Download URL: rtv_solver-0.1.10-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a7b0877e294dca67fa8a2e12fe595968d08c7b4a0c4e4cb977e1b2bae80f8ca
|
|
| MD5 |
ece67bfffb58ae1f08a932437de7801d
|
|
| BLAKE2b-256 |
7fa13fecd0de253ee06f44a0a80b0ddd021704ca8942ef8f474f58f2ce5c8d1a
|