Skip to content

lmr-analyzer: A powerful toolkit to analyze the interaction between last mile operations and the street network design.

License

Notifications You must be signed in to change notification settings

Gui-FernandesBR/Last-Mile-Routing-Analyzer

Repository files navigation

Last-Mile-Routing-Analyzer

DOI License: MPL 2.0 CodeFactor

drawing drawing

drawing drawing

Table of Contents

Motivation

  • Repository referred to a final thesis presented to the University of Sao Paulo in order to achieve the Civil Engineering degree.
  • The main goal was to develop a tool that could be used to analyze the last mile routing problems in a city
  • In the end, a combination of different last-mile statics and street network analysis was made possible, allowing for significant insights to be made on the city's last mile routing problems.
  • The project is still going to be developed and maintained even after the thesis is finished, so any contribution is welcome.

Features

The tool was developed in Python and it is able to analyze the last mile routing problems in a city, considering the following aspects:

  • Last Mile routing data
    • Distance between origin and the destination
      • Shortest driving path by Google Maps API and OpenStreetMap API
      • euclidean distance by Haversine formula;
    • Characterization of different routes
      • Center of gravity
      • Enclosing polygons
      • Percentage of rejected deliveries, and failed attempts
    • Integration with Amazon Last Mile Routing data from public s3 bucket
  • Street networks geometry:
    • Street Network density statistics for different neighborhoods:
      • Node density, edge density, self-loop proportion
      • Street total length, average street length
      • etc.
    • Street Network connectivity and orientation statistics for different neighborhoods:
      • Node degree
      • Polar plots of street orientation

Installation

First you need to certify that you have Python 3.9 installed.

Then you can install the package using pip:

pip install git+https://github.com/Gui-FernandesBR/Last-Mile-Routing-Analyzer/lmr_analyzer.git

The package will automatically install the dependencies listed at requirements.txt file.

Getting started with examples

Here are some of the examples that you can run to get started with the package:

  • Open In Colab - Main example notebook with all the features of lmr_analyzer package.

  • Open In Colab - Example over Los Angeles city using the geometry class.

Read the documentation

The documentation is still under development, please be patient. You can check the current docstring of each method and class individually.

Directory Structure

The repository is organized as follows:

  .github/             - Github related files
  data/                - Data used in or generated with the examples
  docs/                - Documentation files
  source/              - Main package files
  tests/               - Tests for the package
  .gitattributes       - Git attributes file
  .gitignore           - Files to be ignored by git
  CITATION.cff         - Citation file
  LICENSE.md           - License file
  README.md            - This file
  requirements-dev.txt - Python packages required to develop the package
  requirements.txt     - Python packages required to run the package
  setup.py             - Setup file

Library Structure

The lmr_analyzer package is organized as follows:

__init__.py - Main module amz_serializer.py - Amazon S3 data serializer analysis.py - Analysis module, to analyze a set of routes distance_matrix.py - Distance Matrix module geometry.py - Handle with spatial information from shapefiles package.py - Store package information route.py - Store route information stop.py - Store stop information utils.py - Utilities module to be used on other modules vehicle.py - Store vehicle information

The architecture of the package is represented by the following diagram:

classDiagram
    class lmr_analyzer {
    }
    class amzSerializer {
    }
    class analysis {
    }
    class distanceMatrix {
    }
    class geometry {
    }
    class package {
    }
    class route {
    }
    class stop {
    }
    class utils {
    }
    class vehicle {
    }
    lmr_analyzer --> amzSerializer
    lmr_analyzer --> analysis
    lmr_analyzer --> distanceMatrix
    lmr_analyzer --> geometry
    lmr_analyzer --> package
    lmr_analyzer --> route
    lmr_analyzer --> stop
    lmr_analyzer --> utils
    lmr_analyzer --> vehicle
    amzSerializer --> package
    amzSerializer --> route
    amzSerializer --> stop
    amzSerializer --> vehicle
    route --> stop
    route --> utils
    stop --> package

Loading

Data folder description

Due to the large amount of information, the data folder can be a bit confusing, so here is a brief description of what each folder contains:

data/
├── driving_distances/       - Driving distances to be used with Amazon dataset 
│   ├── austin.csv
│   ├── boston.csv
│   ├── ...
│   └── seattle.csv
├── results/                 - Results from the examples
│   ├── dataframes/          - all .csv or .txt files
│   ├── graph_shapefile/     - gespatial data files
│   ├── graphs/              - Report of the Graphs generated with the examples
│   ├── pickles/             - Objects saved as pickle files
│   └── polar_plots/         - Polar plots generated with the examples
└── shapefiles/              - geospatial data files
    ├── austin/              - Neighborhoods of Austin county
    ├── los_angeles_minors/  - Neighborhoods of Los Angeles county
    ├── guarulhos_osm/       - Neighborhoods of Guarulhos city
    ├── ...
    └── urban_regions_Sao_Paulo/ - Urban regions of Sao Paulo state

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Any contributor should be aware of the code of conduct.

You can also contribute by opening an issue with a bug report or a feature request.

License

First of all, thank you for considering contributing to the project!

The quicker step to contribute is by starring the project, which will help it to be more visible to other people.

The project is licensed under the Mozila Public License 2.0, which can be found here. For any questions, please contact the main maintainer.

Citation

If you use this package in your research, please cite it as:

@misc{alves-lmr,
  author = {Guilherme Fernandes Alves},
  title = {Last Mile Routing Analyzer: a powerful toolkit to analyze the interaction between last mile operations and the street network design.},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/Gui-FernandesBR/Last-Mile-Routing-Analyzer}},
  doi = {10.5281/zenodo.6792976}
}

Contact

Send a message to the main maintainer to request more details: Guilherme Fernandes Alves. you can find him (i.e. me) by e-mail: [email protected] or [email protected]