cspy
cspy: A Python package with a collection of algorithms for the (Resource) Constrained Shortest Path problem - Published in JOSS (2020)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 5 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: researchgate.net, sciencedirect.com, joss.theoj.org -
✓Committers with academic emails
2 of 10 committers (20.0%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Keywords from Contributors
Scientific Fields
Repository
A collection of algorithms for the (Resource) Constrained Shortest Path problem in Python / C++ / C#
Basic Info
- Host: GitHub
- Owner: torressa
- License: mit
- Language: C++
- Default Branch: master
- Homepage: https://torressa.github.io/cspy/
- Size: 14.6 MB
Statistics
- Stars: 88
- Watchers: 8
- Forks: 26
- Open Issues: 22
- Releases: 19
Topics
Metadata Files
README.md
| OS | C++ | Python | Dotnet |
|:-------|-----|--------|--------|
| Unix (linux + macos) | |
|
|
| Windows |
|
|
|
cspy
A collection of algorithms for the (resource) Constrained Shortest Path (CSP) problem.
Documentation here.
The CSP problem was popularised by Inrich and Desaulniers (2005). It was initially introduced as a subproblem for the bus driver scheduling problem, and has since then widely studied in a variety of different settings including: the vehicle routing problem with time windows (VRPTW), the technician routing and scheduling problem, the capacitated arc-routing problem, on-demand transportation systems, and, airport ground movement; among others.
More generally, in the applied column generation framework, particularly in the scheduling related literature, the CSP problem is commonly employed to generate columns.
Therefore, this library is of interest to the operational research community, students and academics alike, that wish to solve an instance of the CSP problem.
Algorithms
Currently, the exact and metaheuristic algorithms implemented include:
- [x] Bidirectional labeling algorithm with dynamic halfway point (exact) (also monodirectional) Tilk et al. (2017);
- [x] Heuristic Tabu search (metaheuristic);
- [x] Greedy elimination procedure (metaheuristic);
- [x] Greedy Randomised Adaptive Search Procedure (GRASP) (metaheuristic). Adapted from Ferone et al. (2019);
- [x] Particle Swarm Optimization with combined Local and Global Expanding Neighborhood Topology (PSOLGENT) (metaheuristic) Marinakis et al. (2017).
Please see the docs for individual algorithms Python or C++ API documentation, as well as some toy examples and further details.
- Bidirectional and monodirectional algorithms
- Heuristic Tabu Search
- Greedy Elimination Procedure
- GRASP
- PSOLGENT
Getting Started
Prerequisites
Conceptual background and input formatting is discussed in the docs.
Module dependencies are:
Note that requirements.txt contains modules for development purposes.
Installing
Installing the cspy package with pip should also install all the required packages. You can do this by running the following command in your terminal
none
pip install cspy
or
none
python3 -m pip install cspy
Quick start
Python
```python
Imports
from cspy import BiDirectional from networkx import DiGraph from numpy import array
maxres, minres = [4, 20], [1, 0]
Create a DiGraph
G = DiGraph(directed=True, nres=2) G.addedge("Source", "A", rescost=[1, 2], weight=0) G.addedge("A", "B", rescost=[1, 0.3], weight=0) G.addedge("A", "C", rescost=[1, 0.1], weight=0) G.addedge("B", "C", rescost=[1, 3], weight=-10) G.addedge("B", "Sink", rescost=[1, 2], weight=10) G.addedge("C", "Sink", res_cost=[1, 10], weight=0)
init algorithm
bidirec = BiDirectional(G, maxres, minres)
Call and query attributes
bidirec.run() print(bidirec.path) print(bidirec.totalcost) print(bidirec.consumedresources) ```
For more details see the Python API
Cpp
```cpp
include "bidirectional.h"
namespace bidirectional {
void wrap() {
// Init
const std::vector
// Populate graph bidirectional->addNodes({0, 1, 2, 3, 4}); bidirectional->addEdge(0, 1, 0.0, {1, 2}); bidirectional->addEdge(1, 2, 0.0, {1, 0.3}); bidirectional->addEdge(2, 3, -10.0, {1, 3}); bidirectional->addEdge(2, 4, 10.0, {1, 2}); bidirectional->addEdge(3, 4, 0.0, {1, 10});
// Run and query attributes bidirectional->run();
auto path = bidirectional->getPath(); auto res = bidirectional->getConsumedResources(); auto cost = bidirectional->getTotalCost(); }
} // namespace bidirectional ```
C
```csharp
DoubleVector maxres = new DoubleVector(new List
// Populate graph
alg.addNodes(new IntVector(new List
// Run and query attributes alg.run();
IntVector path = alg.getPath(); DoubleVector res = alg.getConsumedResources(); double cost = alg.getTotalCost(); ```
Examples
vrpy: External vehicle routing framework which usescspyto solve different variants of the vehicle routing problem using column generation. Particulatly, seesubproblem_cspy.py.jpath: Simple example showing the necessary graph adptations and the use of custom resource extension functions.
Building
Docker
Using docker, docker-compose is the easiest way.
To run the tests first, clone the repository into a path in your machine ~/path/newfolder by running
none
git clone https://github.com/torressa/cspy.git ~/path/newfolder
Running the Cpp tests
cd ~/path/newfolder/tools/dev
./build
Running the Python tests
cd ~/path/newfolder/tools/dev
./build -c -p
Locally
Requirements:
- CMake (>=v3.14)
- Standard C++ toolchain
- Python (>=3.6)
Then use the wrapper Makefile e.g. make in the root dir runs the unit tests
License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Contributing
Issues
If you find a bug or there are some improvements you'd like to see (e.g. more algorithms), please raise a new issue with a clear explanation.
Contributing to the Software
When contributing to this repository, please first discuss the change you wish to make via an issue or email. After that feel free to send a pull request.
Pull Request Process
- If necessary, please perform documentation updates where appropriate (e.g. README.md, docs and CHANGELOG.md).
- Increase the version numbers and reference the changes appropriately. Note that the versioning scheme used is based on Semantic Versioning.
- Wait for approval for merging.
Seeking Support
If you have a question or need help, feel free to raise an issue explaining it.
Alternatively, email me at torressa at tutanota.com.
Citing
If you'd like to cite this package, please use the following bib format:
none
@article{torressa2020,
doi = {10.21105/joss.01655},
url = {https://doi.org/10.21105/joss.01655},
year = {2020},
publisher = {The Open Journal},
volume = {5},
number = {49},
pages = {1655},
author = {{Torres Sanchez}, David},
title = {cspy: A Python package with a collection of algorithms for the
(Resource) Constrained Shortest Path problem},
journal = {Journal of Open Source Software}
}
Owner
- Name: David Torres
- Login: torressa
- Kind: user
- Location: Lancaster
- Company: Gurobi Optimization
- Repositories: 3
- Profile: https://github.com/torressa
Optimization Engineer @ Gurobi
JOSS Publication
cspy: A Python package with a collection of algorithms for the (Resource) Constrained Shortest Path problem
Authors
Tags
Resource Constrained Shortest Path Networks Graph TheoryGitHub Events
Total
- Issues event: 3
- Watch event: 5
- Issue comment event: 2
- Fork event: 2
Last Year
- Issues event: 3
- Watch event: 5
- Issue comment event: 2
- Fork event: 2
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| torressa | 2****a | 200 |
| kermit-z | d****z@l****k | 155 |
| torressa | d****z@s****o | 20 |
| Sourcery AI | 3 | |
| David Torres Sánchez | d****z@s****o | 3 |
| sourcery-ai[bot] | 5****] | 1 |
| felicze | 7****e | 1 |
| Daniel S. Katz | d****z@i****g | 1 |
| Dan Van Boxel | t****b@g****m | 1 |
| David Torres Sánches | d****s@s****o | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 74
- Total pull requests: 35
- Average time to close issues: 3 months
- Average time to close pull requests: 6 days
- Total issue authors: 31
- Total pull request authors: 4
- Average comments per issue: 3.42
- Average comments per pull request: 0.97
- Merged pull requests: 26
- Bot issues: 0
- Bot pull requests: 8
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- torressa (26)
- Kuifje02 (5)
- dvbuntu (4)
- mgalati13 (3)
- the-soomin-woo (3)
- steveharenberg (3)
- saahaand (3)
- glanch (2)
- tomatoes-prog (2)
- andrea-cassioli-maersk (2)
- ericburrell-23-1 (1)
- MariaSKAF (1)
- jujaramillo (1)
- malokesnila (1)
- ransari74 (1)
Pull Request Authors
- torressa (24)
- sourcery-ai[bot] (8)
- dvbuntu (2)
- felicze (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 6
-
Total downloads:
- nuget 1,787 total
- pypi 5,629 last-month
-
Total dependent packages: 3
(may contain duplicates) -
Total dependent repositories: 8
(may contain duplicates) - Total versions: 24
- Total maintainers: 2
pypi.org: cspy
(Resource) Constrained Shortest Path algorithms in Python
- Homepage: https://github.com/torressa/cspy
- Documentation: https://cspy.readthedocs.io/
- License: mit
-
Latest release: 1.0.3
published almost 3 years ago
Rankings
Maintainers (1)
nuget.org: cspy.dotnet
.NET wrapper for the cspy BiDirection algorithm
- Homepage: https://github.com/torressa/cspy
- License: MIT
-
Latest release: 1.0.1
published almost 126 years ago
Rankings
nuget.org: cspy.dotnet.runtime.linux-x64
.NET native wrapper for the cspy BiDirectional algorithm
- Homepage: https://github.com/torressa/cspy
- License: MIT
-
Latest release: 1.0.1
published almost 126 years ago
Rankings
nuget.org: cspy.dn
.NET wrapper for the cspy BiDirection algorithm
- Homepage: https://github.com/torressa/cspy
- License: MIT
-
Latest release: 1.0.2
published almost 126 years ago
Rankings
nuget.org: cspy.dn.runtime.osx-x64
.NET native wrapper for the cspy BiDirectional algorithm
- Homepage: https://github.com/torressa/cspy
- License: MIT
-
Latest release: 1.0.2
published almost 126 years ago
Rankings
nuget.org: cspy.dotnet.runtime.osx-arm64
.NET native wrapper for the cspy BiDirectional algorithm
- Homepage: https://github.com/torressa/cspy
- License: MIT
-
Latest release: 1.0.3
published almost 3 years ago
Rankings
Maintainers (1)
Dependencies
- breathe *
- cspy *
- nbsphinx *
- recommonmark *
- sphinx *
- sphinx_copybutton *
- sphinx_material *
- osmnx *
- networkx * development
- numpy * development
- pandas * development
- parameterized * development
- networkx >=2.2
- numpy >=1.13.3
