Constraint Programming Algorithms for Route Planning Exploiting Geometrical Information
FF. Ricca, A. Russo et al. (Eds.): Proc. 36th International Conferenceon Logic Programming (Technical Communications) 2020 (ICLP 2020)EPTCS 325, 2020, pp. 286–295, doi:10.4204/EPTCS.325.38 c (cid:13)
A. BertagnonThis work is licensed under theCreative Commons Attribution License.
Constraint Programming Algorithms for Route PlanningExploiting Geometrical Information
Alessandro Bertagnon
Department of EngineeringUniversity of FerraraFerrara, Italy [email protected]
Problems affecting the transport of people or goods are plentiful in industry and commerce and theyalso appear to be at the origin of much more complex problems. In recent years, the logistics andtransport sector keeps growing supported by technological progress, i.e. companies to be competitiveare resorting to innovative technologies aimed at efficiency and effectiveness. This is why companiesare increasingly using technologies such as Artificial Intelligence (AI), Blockchain and Internet ofThings (IoT). Artificial intelligence, in particular, is often used to solve optimization problems inorder to provide users with the most efficient ways to exploit available resources.In this work we present an overview of our current research activities concerning the developmentof new algorithms, based on Constraint Logic Programming (CLP) techniques, for route planningproblems exploiting the geometric information intrinsically present in many of them or in some oftheir variants. The research so far has focused in particular on the Euclidean Traveling SalespersonProblem (Euclidean TSP) with the aim to exploit the results obtained also to other problems of thesame category, such as the Euclidean Vehicle Routing Problem (Euclidean VRP), in the future.
Given a weighted graph G with n vertices the Traveling Salesperson Problem (TSP) requires to computethe shortest cycle that visits each vertex of G exactly once . The name “Traveling Salesman Problem”comes from the problem’s most famous formulation: “A salesman has to visit a set of cities, each ofwhich must be visited only once, and he wants to minimize the length of the tour”. The problem isNP-hard [19]. Currently, the best solver for the TSP is Concorde [1], that includes several techniquesbased on Integer Linear Programming (with branch-and-bound and branch-and-cut) and Local Search.Some significant sub-classes of the general TSP are the metric TSP , in which the distance functionbetween cities enjoys the triangle inequality, and the Euclidean TSP , in which the nodes of the graphrepresent points in the plane and the distance function is the Euclidean distance. These are reasonableassumptions in many important instances: many industrial problem and various benchmarks taken fromthe TSPLIB [26] fall into these classes.Both the metric and the Euclidean TSP, as the general TSP, are NP-hard [15]; nonetheless, differentlyfrom the general TSP, the Euclidean TSP admits a Polynomial Time Approximation Scheme (PTAS)[2, 23], i.e., given a value ε >
0, it is possible to obtain a solution with cost ( + ε ) L ∗ (where L ∗ is thelength of the optimal tour) in polynomial time with respect to the number of nodes n (note, however, thatthe time is exponential with respect to ε ).It is worth noting that in the Euclidean TSP more information is available than in the general TSP:the coordinates of the points to be visited are known, and geometrical concepts (straight line segments, A cycle that visit each vertex exactly once is often referred as Hamiltonian cycle or Hamiltonian circuit. . Bertagnon
As mentioned in the previous section, the best solver currently available for the TSP is Concorde[1]; butConcorde can address only pure
TSPs, i.e., no further side constraints are allowed, while in CP manyvariants can be easily cast, such as the TSP with Time Windows (TSPTW).Three representations have been devised, in CP literature, for defining variables in the Hamiltoniancircuit problem and the TSP: the permutation representation, the successor representation and the setvariable representation [4] later extended to the graph representation [8, 9, 10]. In the following of thispaper, we will be mainly concerned with the successor representation.Given a list L of variables [ Next , Next , ..., Next n ] , where n is the number of vertices of the graph G ,we denote with Dom ( Next i ) the initial domain of the variable Next i , where Dom ( Next i ) = { , . . . , n } \ { i } .In the successor representation, the value of the Next i variable denotes the successor of the vertex i in theresulting tour (e.g. if n = L = [ , , , , ] the corresponding tour will be 1 , , , , , i always corresponds to one point P i = ( x i , y i ) in the plane.The constraint model includes an alldifferent ( L ) constraint [25] on the list L of all variables,that ensures that each node has exactly one incoming edge, as well a circuit ( L ) [3, 6, 20] constraint(sometimes called nocycle ) that avoids sub-tours, i.e., cycles of length less than n .Caseau and Laburthe [6] propose a simple but efficient propagation algorithm for circuit constraint(nocycle) combined with new branching strategies based on the combination of first-fail and max-regret.First-fail selects first the variable with smallest domain because it has a higher probability of running outof elements and thus lead to failure. The regret of a variable is defined, instead, as the cost differencebetween its two best possible assignments, so the strategy is to first select those variables in which theregret is higher in order to avoid a significant increase in the cost of the solution. They also propose tofilter values based on the objective function. For this last purpose, they apply the assignment-based andthe spanning tree relaxations.Another filtering rule proposed for the circuit constraint is that of Kaya and Hooker [20] basedon graph separators theory. Francis and Stuckey [14] compare the effectiveness of different propagationalgorithm for circuit when adding explanation in the context of a lazy clause generation solver.Pesant et al. [24] address the TSPTW, in which cities must be visited within given temporal intervals,and exploit the circuit constraint together with the minimum spanning tree relaxation. Focacci et al.[12, 13] introduce hybrid approaches that merge CP and Operations Research techniques, including:reduced costs filtering, use of the assignment problem and minimum spanning forest relaxation.A filtering technique presented more recently by Benchimol et al. [4] for the Weighted Circuit Con-straint (WCC) has been able to obtain, on medium dimension instances, results comparable with thesolver Concorde. In their work, they use a variety of techniques. In order to obtain an initial upper88 Constraint Programming Algorithms for Route Planning Exploiting Geometrical Information bound to be used for propagation, they first run the Lin-Kernighan-Helsgaun algorithm [22, 17]. Thenthe filtering technique uses the Held and Karp [16] scheme together with a Lagrangian relaxation to ob-tain the reduced costs of the edges and uses it to remove them. The algorithm is also able to identifythe mandatory arcs that if removed would increase the current lower bound. In the experiments withasymmetric TSPs, they also use additive bounding [11] to combine both the 1-tree and the assignmentproblem relaxations.Fages et al. [10], achieve significant improvement by casting the problem in CP(Graph) and throughthe introduction of improved search strategies (i.e. Last Conflict heuristic). Fages and Lorca [9] shownhow properties of the reduced graphs associated to an Asymmetric TSPs can be used to improve theMinimum Spanning Tree relaxation. The nodes of the reduced graphs are the Strongly Connected Com-ponents of the original graph.Isoart and R´egin [18] design a propagator based on the search of k -cutsets. The combination of thisconstraint with the WCC constraint has resulted in a significant reduction in the computation time. Several algorithms have already been developed, some of them have recently been published in their firstversion [5] while others are still being studied.
A well-known finding in the literature (e.g., [2]) is that the optimal solution of Euclidean TSP does nothave crossing edges (see Figure 1). P i bb bb P j P l P k Figure 1: Crossings elimination leads to a shorter route.
Property 1.
There is no crossing in the optimal solution for a Euclidean TSP.
We can take advantage of Property 1 to reduce the size of the search tree by eliminating branchespresenting crosses. We propose the nocrossing constraint that eliminates assignments leading to non-optimal solutions. In the successor representation, it is defined as follows.
Definition 1.
The nocrossing ( i , Next i , j , Next j ) constraint assures that segments iNext i and jNext j donot cross each other. The nocrossing constraint is a binary constraint since i and j are ground values at the time whenit is imposed. Suppose we have n nodes, to avoid crossings n ( n − ) / nocrossing constraint can be implemented thorougha pair of propagators: one propagates changes in the domain of the variable Next i on the domain of thevariable Next j , while the other propagator propagates changes on the other way. . Bertagnon (a) b b P i P j P y b b b P z bb b P t b (b) b P i P j P k b b α t P t α b b β k β t βα k b Figure 2: An arrow from P x to P y means that y ∈ Dom ( Next x ) . Dashed lines are plotted to show theangles.The nocrossing constraint could be implemented in a naive manner, for example using the tableconstraint [28] or the propia library [21]. A table constraint consists of a table (usually a list of tuples)of values that the involved variables must, or must not, assume. However this implementation wouldbe inefficient, because the constraint wakes up most of the time without being able to carry out anypropagation. Moreover, with the table constraint one should initially compute large tables, containing,for all pairs of edges in the graph, if they cross or not. Propagating such constraint would have the usualcost of arc-consistency propagation for a single constraint of O ( d ) (if d is the size of the domains) ineach activation of the constraint.From the definition of arc-consistency and Definition 1, a value v can be removed from Dom ( Next j ) only if the segment P j P v intersects all possible segments originating from P i (e.g. segment P j P t in Fig-ure 2a).We define a possible segment from P i a segment P i P j such that j ∈ Dom ( Next i ) . We denote with ←→ P i P j the (infinite straight) line passing through points P i and P j , and with ∠ P i P j P k the counterclockwise angleformed by the segments P i P j and P j P k with vertex in P j from P i to P k .We have identified the following necessary and sufficient conditions for pruning and we have ex-ploited them within our propagation algorithm. Theorem 1 (Necessary condition) . Let P j P t a possible segment from P j . If P j P t crosses all possiblesegments from P i then all segments originating from P i must lie on the same half-plane with respect tothe line ←→ P i P j . The propagator is suspended waiting that all elements in the domain of
Next i lie on the same half-plane. We select one element in each half-plane and the propagator suspends waiting that one of the twoelements is removed from Dom ( Next i ) . Theorem 2 (Necessary condition) . Let P j P t a possible segment from P j . If P j P t crosses all possiblesegments from P i then α t ≤ α , where α = min { α q | q ∈ Dom ( Next i ) } and α k = ∠ P i P j P k (see Figure 2b). Theorem 3 (Sufficient condition) . Suppose there exists a possible segment P j P t from P j such that α t ≤ α .If P j P t crosses all possible segments from P i then β t > β , where β = max { β q | q ∈ Dom ( Next i ) } and β k = ∠ P k P i P j (see Figure 2b). Thanks to these theorems, the nocrossing propagator can be implemented with O ( d ) complexity(if d is the size of the domains) per each activation (to be compared to the O ( d ) of a naive propagator).A study we are conducting to evaluate the actual performance of the nocrossing constraint is shownin Figure 3.90 Constraint Programming Algorithms for Route Planning Exploiting Geometrical Information (a) (b)(c)
Figure 3: A graphical representation of the nocrossing constraint while solving an instance with 20nodes. The darker the color, the higher is the value for the following indicators: (a) number of valuedeletion; (b) number of failures; (c) instances of nocrossing that have not performed pruning (binaryvalue: true, false).
Further pruning can be obtained by means of the convex hull of the set of points. We recall the definitionof convex hull.
Definition 2.
Let S be a set of points, the convex hull of S is defined as the smallest convex set containingS. The convex hull is therefore the smallest convex polygon that includes all the points of the set S.
The following property resulting from Property 1 can also be exploited to reduce the space of possiblesolutions.
Property 2.
Let k of the n points in the Euclidean TSP be vertices on the boundary of the convex hull.Then the order in which these k points appear in the optimum traveling salesman tour must be the sameas the order in which these same points appear on the boundary of the convex hull.
From Property 2 follows that the optimal solution of the TSP is is a simple polygon, and it dividesthe plane into exactly two areas: an internal and an external area. Please observe that the points on theborder of the convex hull do not necessarily appear consecutively in the solution, an example is reportedin Figure 4a.Let V = { , , ..., n } be the set of vertices, where n is the number of vertices of the graph, and let H = { ( h , h , ..., h k ) | h i ∈ V , i = , .., k } be the list of vertices that lies on the boundary of the convexhull ordered clockwise. The following is a summary of three different ways we proposed to exploit theinformation about the convex hull for constraint propagation.The simplest way to satisfy the Property 2 is to apply the following relation: ∀ i ∈ H , Dom ( Next i ) ∩ { h j | j = , ... k , j (cid:54) = ( i + ) } = /0 (1) . Bertagnon (a) b bb b b bbbb b b b H i H i +1 b b b bbbb (b) Figure 4: (a) Visiting vertices of the perimeter of the convex hull not in order generates a cross in thesolution of the TSP, therefore that solution cannot be optimal. (b) Imagine to cut the optimal TSP withtwo vertical lines, the convex hull reasoning can be extended to the borders (i.e., the parts of the circuitinside the stripe).Equation 1 states that it is possible to eliminate from the domain of each point in H all the other pointson the boundary of the convex hull except the next in the sequence (see Figure 5a).Further propagation can be carried out when the domain associated with a point on the boundary ofthe convex hull becomes ground. Let H i be the index of the point on the boundary of the convex hullwhose domain has become ground and P its value, i.e., in the current assignment there is the H i P segment.If we choose to go through the points on the boundary of the convex hull in a clockwise direction, inorder to satisfy Property 2, no points situated on the left of the H i P segment can have H i as its successor(see Figure 5b)The third way is to impose that each path originating from a convex hull vertex cannot reach any con-vex hull vertex except for the one immediately following it. Implementation is inspired by the circuit constraint [6], but performs more powerful pruning (see Figure 5c). It is clear that this third propagationalso implies the first one.The applicability of the three convex hull propagators presented can also be extended to points thatlie in the interior of the hull. Once a partial path has been defined, consider the polygon formed by suchpath plus a segment connecting its extremes. We can apply the propagators to the convex hull of thepoints inside that polygon (see Figure 4b).We propose the clockwise constraint that implements all the propagation described in this section. In order to assess the effectiveness of the proposed algorithms, we devised a series of experiments basedon randomly-generated TSPs and taken from structured instances (e.g. TSPLIB [26]).We implemented all algorithms using the ECL i PS e CLP language [27]. We started comparing ouralgorithms with a simple model for the successor representation (that includes alldifferent and circuit constraints), such a constraint model is named
CLP(FD) in the following. Then in order toshow that the pruning we provide is not subsumed by that of state of the art techniques, we implementedin ECL i PS e , in the successor representation, also the Held and Karp bound with pruning based on re-duced and marginal costs, as proposed by Benchimol et al. [4] (shown with BvHRRR in the following).The constraint model, named
Geometric , includes the nocrossing constraint on all pairs of vertices,together with the clockwise constraint that implements the propagation described in Section 3.2. The92
Constraint Programming Algorithms for Route Planning Exploiting Geometrical Information (a) b bbb b bb bbb b b b H i H i +1 (b) b bb bb bbb b b bb H i bbb b (c) b bbb b bb bbb b b H i +1 b H i b b bbb Figure 5: Depiction of three different ways to exploit the information about the convex hull for constraintpropagation as implemented in the clockwise constraint. The boundary of the convex hull is representedwith dotted lines. (a) The successor of a convex hull vertex cannot be another vertices on the boundary ofthe convex hull except for the one that immediately follows it. (b) In order to visit nodes in a clockwiseorder, the angle between the incoming edge and the outgoing edge of a convex hull vertex cannot bepositive (it must be between − π and 0). (c) On each paths originating from a convex hull vertex H i thefirst convex hull vertex different from H i is the one immediately following it, that is H i + . Geometric model also includes bounds with the Lin-Kernighan-Helsgaun [17]) as included in
BvHRRR .In Figure 6 we present cactus plots that compare the impact of our filtering algorithms with theconstraints already predefined in
ECL i PS e system. In the x -axis we report the number of optimally solvedinstances, and in the y -axis the solving time in seconds. Fixed a certain amount of time, Figure 6 clearlyillustrates that our filtering algorithms, especially when used simultaneously, significantly increase thenumber of instances solved.In Figure 7 we present cactus plot that compare the impact of our filtering algorithm with the pruningproposed by Benchimol et al. [4]. The addition of the filtering on geometric properties improves theruntime.Admittedly, the instances we were able to solve are not as large as those addressed by state of theart techniques in CP [4, 10, 9]. This could be due to several factors. Our implementation is based ondeclarative languages that have the advantage of separating problem definition (as much as possible) fromimplementation details. On the other hand, their performance can be significantly slower than imperativelanguages, not only due to interpretation vs compilation schemes, but also to the availability of efficientdata structures and search techniques.Although the results achieved so far are a solid starting point, we are still working on improving theperformance and making our algorithms scalable to solve larger instances. In this paper, we proposed to exploit geometric information while solving route planning problems inorder to have additional pruning with respect to the techniques already available in CP.The pruning of the WCC, proposed by Benchimol et al. [4], is orthogonal with respect to that ofthe nocrossing and clockwise constraints. The quality of the propagation carried out by the WCC isproportional to the quality of the current upper bound on the cost of the solution of the TSP, while ourpropagator can delete values from the domains even if no bound is known yet.Despite the preliminary results that we have achieved and presented in this paper are good, ourapproaches are still not competitive with Concorde especially for large instances. . Bertagnon (a)
20 40 6005001,000 ti m e [ s ] (b)
10 20 30 40 5005001 ,
000 ti m e [ s ] CLP(FD)CLP(FD) + nocrossing
CLP(FD) + nocrossing + clockwise Figure 6: Cactus plot of filtering algorithms which we run over 68 randomly-generated Euclidean TSPinstances with 20 nodes (a) and 24 nodes (b). Time limit was set to 1200 seconds. (a)
20 30 40 5010 l og ti m e [ s ] (b)
600 700 800 9006001 , ,
800 ti m e [ s ] BvHRRRGeom.+BvHRRR
Figure 7: Experimental results on randomly-generated Euclidean TSP instances from 20 to 50 nodes insteps of 2. For each size we generated 60 instances (30 uniform and 30 clustered). Time limit was setto 1800 seconds. (a) Average solving time of filtering algorithms varying the size of the instances. Eachpoint is the average solving time of 60 instances. (b) Cactus plot showing the number of solved instancesvarying the solving time.We used the successor representation, while the set variable or the graph representations should beexperimented extensively, possibly mixing different representations with tunneling constraints.As future work we also plan to apply extensions of the proposed techniques in the Euclidean VRPand possibly to other similar problems. In a Vehicle Routing Problem (VRP) there is a fleet of vehiclesthat must reach all the nodes of a graph; in each node the vehicle must load (or unload) goods. Eachvehicle has a capacity that must not be exceeded, so it is not possible to use a single vehicle (with onlyone vehicle the VRP boils down to the TSP). It can be seen that in an optimal solution of Euclidean VRPthere are no intersections in the path of each vehicle, even though there may be intersections between thepaths of different vehicles.We are also planning to extend some of the techniques presented here in CLP to Answer Set Pro-gramming (ASP).94
Constraint Programming Algorithms for Route Planning Exploiting Geometrical Information
Acknowledgments
The author wish to thank Prof. Marco Gavanelli for supervising his PhD research activities and JoachimSchimpf for his help in the implementation of some of the constraints. This work was partially supportedby GNCS-INdAM.
References [1] David Applegate, Robert E. Bixby, Vasek Chv´atal & William J. Cook (2001):
TSP Cuts Which Do NotConform to the Template Paradigm . In Michael J¨unger & Denis Naddef, editors:
Computational Com-binatorial Optimization, Optimal or Provably Near-Optimal Solutions [based on a Spring School, SchloßDagstuhl, Germany, 15-19 May 2000] , Lecture Notes in Computer Science
Polynomial Time Approximation Schemes for Euclidean TSP and Other GeometricProblems . In: , IEEE Computer Society, pp. 2–11, doi:10.1109/SFCS.1996.548458.[3] N Beldiceanu & E Contejean (1994):
Introducing Global Constraints in CHIP . Math. Comput. Model.
Improved filtering for weighted circuit constraints . Constraints An Int. J.
Improved Filtering for the Euclidean Traveling Salesper-son Problem in CLP(FD) . In:
The Thirty-Fourth AAAI Conference on Artificial Intelligence, AAAI 2020,The Thirty-Second Innovative Applications of Artificial Intelligence Conference, IAAI 2020, The TenthAAAI Symposium on Educational Advances in Artificial Intelligence, EAAI 2020, New York, NY, USA,February 7-12, 2020 , AAAI Press, pp. 1412–1419, doi:10.1609/aaai.v34i02.5498 0.[6] Yves Caseau & Franc¸ois Laburthe (1997):
Solving Small TSPs with Constraints . In Lee Naish, editor:
LogicProgramming, Proceedings of the Fourteenth International Conference on Logic Programming, Leuven, Bel-gium, July 8-11, 1997 , MIT Press, pp. 316–330, doi:10.7551/mitpress/4299.003.0028.[7] Michel Deudon, Pierre Cournut, Alexandre Lacoste, Yossiri Adulyasak & Louis-Martin Rousseau (2018):
Learning Heuristics for the TSP by Policy Gradient . In Willem Jan van Hoeve, editor:
Integration ofConstraint Programming, Artificial Intelligence, and Operations Research - 15th International Conference,CPAIOR 2018, Delft, The Netherlands, June 26-29, 2018, Proceedings , Lecture Notes in Computer Science
CP(Graph): Introducing a Graph ComputationDomain in Constraint Programming . In Peter van Beek, editor:
Principles and Practice of Constraint Pro-gramming - CP 2005, 11th International Conference, CP 2005, Sitges, Spain, October 1-5, 2005, Proceedings , Lecture Notes in Computer Science
Improving the Asymmetric TSP by Considering Graph Struc-ture . CoRR abs/1206.3437.[10] Jean-Guillaume Fages, Xavier Lorca & Louis-Martin Rousseau (2016):
The salesman and the tree: theimportance of search in CP . Constraints
An additive bounding procedure for the asymmetric travelling sales-man problem . Math. Program.
53, pp. 173–197, doi:10.1007/BF01585701.[12] Filippo Focacci, Andrea Lodi & Michela Milano (2002):
Embedding Relaxations in Global Constraints forSolving TSP and TSPTW . Ann. Math. Artif. Intell. . Bertagnon [13] Filippo Focacci, Andrea Lodi & Michela Milano (2002):
A Hybrid Exact Algorithm for the TSPTW . IN-FORMS Journal on Computing
Explaining circuit propagation . Constraints
Some NP-complete Geometric Problems . In:
Proceed-ings of the Eighth Annual ACM Symposium on Theory of Computing , STOC ’76, ACM, New York, NY,USA, pp. 10–22, doi:10.1145/800113.803626.[16] Michael Held & Richard M. Karp (1970):
The Traveling-Salesman Problem and Minimum Spanning Trees . Operations Research
An effective implementation of the Lin-Kernighan traveling salesman heuristic . Eu-ropean Journal of Operational Research
Integration of Structural Constraints into TSP Models . InThomas Schiex & Simon de Givry, editors:
Principles and Practice of Constraint Programming - 25th Inter-national Conference, CP 2019, Stamford, CT, USA, September 30 - October 4, 2019, Proceedings , LectureNotes in Computer Science
Reducibility Among Combinatorial Problems . In Raymond E. Miller & James W.Thatcher, editors:
Proceedings of a symposium on the Complexity of Computer Computations, held March20-22, 1972, at the IBM Thomas J. Watson Research Center, Yorktown Heights, New York, USA , The IBMResearch Symposia Series, Plenum Press, New York, pp. 85–103, doi:10.1007/978-1-4684-2001-2 9.[20] Latife Genc¸ Kaya & John N. Hooker (2006):
A Filter for the Circuit Constraint . In Fr´ed´eric Benhamou, edi-tor:
Principles and Practice of Constraint Programming - CP 2006, 12th International Conference, CP 2006,Nantes, France, September 25-29, 2006, Proceedings , Lecture Notes in Computer Science
Generalized Constraint Propagation over the CLP Scheme . J.Log. Program.
An Effective Heuristic Algorithm for the Traveling-Salesman Problem . Operations Research
Guillotine Subdivisions Approximate Polygonal Subdivisions: A SimplePolynomial-Time Approximation Scheme for Geometric TSP, k-MST, and Related Problems . SIAM J. Com-put.
An Exact Constraint LogicProgramming Algorithm for the Traveling Salesman Problem with Time Windows . Transportation Science
A Filtering Algorithm for Constraints of Difference in CSPs . In Barbara Hayes-Roth & Richard E. Korf, editors:
Proceedings of the 12th National Conference on Artificial Intelligence,Seattle, WA, USA, July 31 - August 4, 1994, Volume 1. , AAAI Press / The MIT Press, pp. 362–367.[26] Gerhard Reinelt (1991):
TSPLIB - A Traveling Salesman Problem Library . INFORMS Journal on Computing
ECLiPSe - From LP to CLP . Theory Pract. Log. Program.
Encoding Table Constraints in CLP(FD) Based on Pair-Wise AC . In Patricia M. Hill& David Scott Warren, editors: