This repository contains a simple example of how to create a native extension for the RoutingBlocks package.
This is useful if you want to create high-performance evaluation functions for your routing problem.
Feel free to use this repository as a starting point for your own native extension,
see this section for more information.
git clone
pip install <directory>This example provides a simple CVRP "solver" that uses the implemented evaluation function. To test it, run:
pip install -r example/requirements.txt
python example/usage.py X-n101-k25RoutingBlocks is a native library with Python bindings provided through a package hosted on PyPI. This native library
is
distributed alongside the package, making it accessible to developers for creating extension modules by linking against
it. By implementing the interfaces provided by RoutingBlocks, custom classes can be seamlessly integrated and used
with
the main package, allowing for a more tailored and versatile experience when working with the library.
The example utilizes scikit-build-core and cmake to build the native library extension. The following files are relevant and will likely require changes:
CMakeLists.txt: This file contains the build instructions for the native library.pyproject.toml: This file contains the metadata and build instructions for the python package.
- Adjust the implementation of
CVRPEvaluationand related classes (i.e.,CVRP_*_data) to your problem setting. - Create bindings for any additional members, classes, and functions you've implemented (
cf. pybind11). Make sure to use the pybind11
smart_holderbranch. The example sets this up automatically. - Build and install the library using
pip install .(orpip install -e .for development) or ship it as a wheel ``. - (Optional) Generate type stubs for your library using mypy.