Skip to main content

Routing coverage report

Description

Package to use Ortools combine with Osrm for routing.

Install

  • You should have a OSRM server with the right data section

Options

You can set local search options with params in https://developers.google.com/optimization/routing/routing_options#local_search_options

Usage

  • import package and set the host
from routingoo.routing_data_matrix import RoutingDataMatrix
from routingoo.vrp_solver import VrpSolver

HOST=my_host # eg "localhost:5000" or "router.project-osrm.org"
  • Set location address in one list
add1 = '15 Rue Basse Monaco'
add2 = '1 Avenue des Pins Monaco'
add3 = """ Maison de Stéphanie de Monaco, Avenue Saint-Martin,
Monaco-Ville, Monaco, 98000 """
locations = [add1, add2, add3]
  • Retrive coordinates and distance and duration infos with Nominatim and OSRM
routing_data_matrix = RoutingDataMatrix(host=HOST)
coordinates, points = routing_data_matrix.coordinate_infos(locations)
distance_matrix, duration_matrix = routing_data_matrix.distance_duration_matrix_simple_route(points)
  • Use solver to find a heuristic
num_vehicles = 1
vrp_solver = VrpSolver(num_vehicles)
route = vrp_solver.solver_guided_local_search(distance_matrix, time_max)[0]
  • Retrieve the total distance if needed
total_distance = vrp_solver.compute_total_distance(route, distance_matrix)

Model methods

  • RoutingDataMatrix

    • init(self, host="localhost:5000")
    • coordinate_infos(self, locations)
    • distance_duration_matrix_simple_route(self, points)
  • VrpSolver

    • init(self, num_vehicles)
    • create_data_model(self, distance_matrix)
    • compute_total_distance(self, route, distance_matrix, unite_mesure="m", show_log=False)
    • print_solution(self, manager, routing, solution)
    • get_routes(self, manager, routing, solution)
    • solver_guided_local_search(self, distance_matrix, time_max, heuristic_type="FirstSolutionStrategy", heuristic="PATH_CHEAPEST_ARC",max_travel_distance=False, show_log=False)

Sample for Osrm server with Monaco data on localhost:5OOO

  • Retrieve the data :

wget http://download.geofabrik.de/europe/monaco-latest.osm.pbf

  • Extract data :

docker run -t -v $(pwd):/data osrm/osrm-backend:latest osrm-extract -p /opt/car.lua /data/monaco-latest.osm.pbf

  • Contract data :

docker run -t -v $(pwd):/data osrm/osrm-backend:latest osrm-contract /data/monaco-latest.osrm

  • Run your server on localhost:5000 :

docker run -t -i -p 5000:5000 -v $(pwd):/data osrm/osrm-backend:latest osrm-routed /data/monaco-latest.osrm

Testing

  • use python -m unittest discover -v
  • ⚠️ the tests use VCR if you want fresh call to Nominatim and Osrm remove the folder vcr_cassettes

Resources :

Metadata

Release files for routing-ortools-osrm 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for routing-ortools-osrm 1.0.1
File Size Uploaded
routing-ortools-osrm-1.0.1.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for routing-ortools-osrm 1.0.1
File Interpreter ABI Platform
routing_ortools_osrm-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.0 kB

Release files / routing-ortools-osrm-1.0.1.tar.gz

Download URL routing-ortools-osrm-1.0.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7bf24105880178e573d98016362a08a515b386dcbdc5f30018413550f3847b3f
BLAKE2b-256 checksum
How to use checksums
810ddf17a7c95eb96e1a086ab7c2ae228eb6dc54ce5eecf455c27c0cf9c00372
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

Release files / routing_ortools_osrm-1.0.1-py3-none-any.whl

Download URL routing_ortools_osrm-1.0.1-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6fb28ccce2f8d75549990239784cf86420c8ab968815d34aad28e418c1eeaf0d
BLAKE2b-256 checksum
How to use checksums
b597bf0088dae4384773fad27f271d13e20cbee51abefb99776b1741efdb2ad6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page