cspy: A Python package with a collection of algorithms for the (Resource) Constrained Shortest Path problem

When solving the shortest path problem and considering multiple operational restrictions, one may resort to the (resource) constrained shortest path (CSP) problem. It consists, as its name suggests, in finding, among all paths, the shortest path from source to sink nodes that satisfies a set of constraints for a defined set of resources. Such set of resources and the way they evolve throughout the path are user defined and controlled. This allows the modelling of a wide variety of problems including: the vehicle routing problem with time windows, the technician routing and scheduling problem, the capacitated arc-routing problem, on-demand transportation systems, and, airport ground movement (Bode & Irnich, 2014; Chen, Weiszer, Stewart, & Shabani, 2016; Desrochers & Soumis, 1988; Feillet, Dejax, Gendreau, & Gueguen, 2004; Garaix, Artigues, Feillet, & Josselin, 2010; Irnich & Villeneuve, 2006; Righini & Salani, 2008; Tilk, Rothenbächer, Gschwind, & Irnich, 2017; Zamorano & Stolletz, 2017).


Introduction
When solving the shortest path problem and considering multiple operational restrictions, one may resort to the (resource) constrained shortest path (CSP) problem. It consists, as its name suggests, in finding, among all paths, the shortest path from source to sink nodes that satisfies a set of constraints for a defined set of resources. Such set of resources and the way they evolve throughout the path are user defined and controlled. This allows the modelling of a wide variety of problems including: the vehicle routing problem with time windows, the technician routing and scheduling problem, the capacitated arc-routing problem, on-demand transportation systems, and, airport ground movement (Bode & Irnich, 2014;Chen, Weiszer, Stewart, & Shabani, 2016;Desrochers & Soumis, 1988;Feillet, Dejax, Gendreau, & Gueguen, 2004;Garaix, Artigues, Feillet, & Josselin, 2010;Irnich & Villeneuve, 2006;Righini & Salani, 2008;Tilk, Rothenbächer, Gschwind, & Irnich, 2017;Zamorano & Stolletz, 2017).
cspy is a Python package that allows you to solve instances of the CSP problem using up to eight different algorithms.
cspy is of interest to the operational research community and others that wish to solve an instance of the CSP problem.

Algorithms
Even though the CSP problem is N P-hard (Garey & Johnson, 1990), several algorithms have been developed to solve it. The most common algorithms are dynamic programming labelling algorithms. Irnich & Desaulniers (2005) presented an exact algorithm based on DP, the monodirectional forward labelling algorithm, based on the pioneering work by Desrochers & Soumis (1988).
Advanced and efficient algorithms have been developed since. Boland, Dethridge, & Dumitrescu (2006) published a state augmenting algorithm that uses a monodirectional labelling algorithm to find an elementary path (one without repeating nodes). Such algorithm has been implemented by Weyens (2018). Righini & Salani (2006) introduced a bidirectional labelling algorithm for the SPPRC. The bidirectional algorithm is an extension of the monodirectional algorithm that supports search from both ends of the graph, hence, reducing the computational efforts. More recently, Tilk et al. (2017) developed a bidirectional labelling algorithm with dynamic halfway point. The bidirectional search is bounded for both directions and these bounds are dynamically updated as the search in either direction advances. The algorithm has shown to be significantly more efficient that monodirectional ones (Gschwind, Irnich, Rothenbächer, & Tilk, 2018).
Even with some of the most recent algorithms, solving an instance of the SPPRC can be slow, thus, heuristic algorithms have been developed. Local search or metaheuristics start with a given path and perform a series of moves (edge/node deletion, insertion, or exchange) to obtain another feasible path with lower cost. Some metaheuristics developed include, Tabu search (Desaulniers, Lessard, & Hadjar, 2008), hybrid particle swarm algorithm (Marinakis, Migdalas, & Sifaleras, 2017), and, greedy randomised adaptive search procedure (GRASP) (Ferone, Festa, & Guerriero, 2019).
cspy implements several of these recent exact and metaheuristic algorithms including: • Bidirectional labeling algorithm with dynamic halfway point (Tilk et al., 2017); which includes the bidirectional labeling algorithm with static halfway point, and the monodirectional forward and backward labeling algorithms; • Tabu

Features
A key component of a CSP problem is to define a set of resources and a function to apply for these to evolve through the graph. Such functions are typically referred to as resource extension functions (REFs). The simplest REF is an additive one, where every time an edge is traversed a constant unit of a certain resource is consumed. However, custom and more generic REFs can be used.
cspy allows for custom and generic REFs to be used. Hence, allowing for a custom consumption of the resources through the graph.

Examples
The package has been used in the following examples: • vrpy : vehicle routing framework which solves different variants of the vehicle routing problem (including capacity constraints and time-windows) using column generation. The framework has been tested on standard vehicle routing instances. • cgar : Complex example using column generation applied to the aircraft recovery problem. • jpath : Simple example showing the necessary graph adaptations and the use of custom resource extension functions.