Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A python library for OptimoRoute's web service

Project Description

Optimo Python library

This is a python library for OptimoRoute’s web service.


Note:
Although this is used internally and we continually improve it, it is still Beta software. Use with care.

Requirements

  • Python (has only been tested with python 2.7)
  • An access key provided to you by OptimoRoute

Installation

Installation using pip:

pip install optimo

Usage

from datetime import datetime
from decimal import Decimal
from optimo import OptimoAPI, Driver, WorkShift, Order, RoutePlan


# Instantiate the interface to optimoroute's API.
optimo_api = OptimoAPI('https://api.optimoroute.com', 'some_access_key')

# Create a workshift for the driver.
work_shift = WorkShift(
    start_work=datetime(year=2014, month=12, day=5, hour=8, minute=0),
    end_work=datetime(year=2014, month=12, day=5, hour=14, minute=0),
)

# Create the driver and also pass the workshift we created above.
driver = Driver(
    id='123',
    start_lat=Decimal('53.350046'),
    start_lng=Decimal('-6.274655'),
    end_lat=Decimal('53.341191'),
    end_lng=Decimal('-6.260402'),
    work_shifts=[work_shift],
)

order1 = Order(
    id='123',
    lat=Decimal('53.343204'),
    lng=Decimal('-6.269798'),
    duration=20,
)

order2 = Order(
    id='456',
    lat=Decimal('53.341820'),
    lng=Decimal('-6.264991'),
    duration=25,
)

# Create the route plan, and also pass the orders and the driver created above.
# The 'request_id' is the one we'll use later to check the results of the
# plan optimization.
routeplan = RoutePlan(
    request_id='1234',
    callback_url='https://callback.com/1234',
    status_callback_url='https://status.callback.com/1234',
    drivers=[driver],
    orders=[order1, order2],
)

# Start the plan optimization. If there is no exception raised then we assume
# success.
optimo_api.plan(routeplan)

# Get the result of the optimization. We use the 'request_id' we provided to
# optimoroute previously.
data = optimo_api.get('1234')

# If the optimization has finished we can see the result. Otherwise the data
# will be None.
{
    u'creationTime': u'2014-12-04T17:01:52',
    u'requestId': u'1234',
    u'result': {
        u'routes': [
            {
                u'driverId': u'123',
                u'orders': [
                    {u'id': u'123', u'scheduledAt': u'2014-12-05T08:04'},
                    {u'id': u'456', u'scheduledAt': u'2014-12-05T08:27'}
                ]
            }
        ],
        u'unservedOrders': []
    },
    u'success': True
}

# We can stop an already running optimization. If stopped previously no
# exceptions will be raised, it will return None implying it was successful.
optimo_api.stop('1234')
Release History

Release History

This version
History Node

0.2.2

History Node

0.2.1

History Node

0.1.0

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

History Node

0.0.1a2

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
optimo-0.2.2.tar.gz (19.8 kB) Copy SHA256 Checksum SHA256 Source Oct 11, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting