Vehicle Routing Problem Solving System as a CRO-GRID Application Hrvoje Gold, D.Sc, Tonči Carić, D.Sc, Ante Galić, B.Sc, Ivana Ćavar, B.Sc. Faculty of Transport and Traffic Engineering University of Zagreb Vukelićeva 4, Zagreb, HR-10000, Croatia Phone: +385-1-2380-222 Fax: +385-1-2314-415 E-mail: {hrvoje.gold | tonci.caric | ante.galic | ivana.cavar}@fpz.hr Abstract - Transport logistics and fleet management problems often fall into one class of the optimization problems. Finding an optimal set of routes for group of vehicles in the transport network under defined constraints is known as the Vehicle Routing Problem (VRP). VRP represents the NP hard problem. Solving of the VRP problem can be shortened by parallelization of the time critical steps of the sequential algorithm, decomposition of the problem and distribution of its search space among the processors or by concurrent search with different amounts of synchronism and cooperation among sub-problems. The paper presents the description of the developed VRP solving system Venera/Mars and the discussion of results obtained by the implementation of the heuristic algorithms for solving the practical VRP problems in city logistics. of corresponding vehicle. The requests from all the customers should be fulfilled and all constraints satisfied. In practice, the basic vehicle routing problem is extended with constraints, for instance, on the allowed capacity of the vehicle, length of route, arrival, departure and service time, time of collection and delivery of goods. The extended classes of VRP are Capacitated VRP (CVRP), Distance Constrained VRP (DVRP), Distance Constrained Capacitated VRP (DCVRP), VRP with Time Windows (VRPTW), Backhauls VRP (VRPB), Pickup and Delivery VRP (VRPPD), and Simultaneous Pickup and Delivery VRP (VRPSPD), Fig. 1. The main goal in all VRP problems is to obtain the minimal transportation cost. Vehicle Routing Problem (VRP) I. INTRODUCTION Capacitated (CVRP) One of the main aims of the 'CRO-GRID Applications' project supported by the Ministry of Science, Education and Sport of the Republic of Croatia [1] is to qualify the academic community for the development of distributed applications. The application of ‘Optimization of Transport Management’ is oriented towards the improvement of organizing the transport of people and goods by solving the practical vehicle routing problems using distributed / parallel implementations of exact and (meta)heuristic algorithms on cluster/grid infrastructure. The vehicle routing problems represent NP problems and the optimal solution cannot be reached in polynomial time. Therefore, for the correct solution it is appropriate to develop distributed implementations of exact algorithms which can be solved on a computer cluster. In case of solving practical vehicle routing problems that include a number of special additional constraints, the approximate solving methods should be used. The heuristic and metaheuristic algorithms provide approximate solutions acceptable in practical application. By application of distributed/parallel implementations it is possible to achieve the accelerations of the performance of heuristic and meta-heuristic algorithms. II. VRP PROBLEM Determining the optimal route that is used by a group of vehicles in the course of serving a group of customers, represents the vehicle routing problem [2]. Vehicles start from the depot and to reach the customers they operate on the transport network. The solution of the problem is the set of routes. Each route has its first and last stop in a depot Distance Constrained (DVRP) Time Windows (VRPTW) Backhauls (VRPB) Pickup and Delivery (VRPPD) Simultaneous Pickup & Delivery (VRPSPD) Fig. 1. Classification of vehicle routing problems In the case when only one vehicle is serving the customers and there are no additional constraints, the vehicle routing problem is reduced to the travelling salesman problem (TSP). Both problems are NP problems. In the general case the exact solution cannot be found in the polynomial time. For instance, to solve the TSP problem with 10, 15, 18 and 20 customers, a single contemporary computer with processing power of 109 operations/sec, needs less than 1 second, 21 seconds, 74 days, 77 years respectively. To solve the VRP problem the exact, heuristic and metaheuristic algorithms are in use. The exact algorithms, based on linear programming techniques are limited to solving simple practical problems. In special cases when the set of possible solutions can be reduced the branch, cut and price, column generation and Lagrange relaxation algorithms are often used. With heuristic algorithms, e.g. Clark and Wright, Sweep, the acceptable solutions can be achieved relatively fast. The algorithms of improving the heuristic solutions, e.g., 2opt, try to further optimize an already existing solution by route modifications. The meta-heuristic methods, e.g. simulated annealing, genetic algorithms, tabu search, ant colonies, simulate natural processes and they have proven as very successful optimization methods. In order to solve the practical VRP problems the procedures are used which select the starting routes by construction techniques, and then improve the solutions by linking up of the heuristic and meta-heuristic methods. The optimized routes have a significant impact on the transport organization by reducing the costs and travelling duration. Practical experiences from literature show that by improving the transport organization by optimizing the routes a reduction of transportation costs of even up to 20% may be achieved. The main users are the carriers who perform the delivery and collection e.g. the transport companies, municipal services, post, courier services. III. VRP SOLVING ENVIRONMENT In order to realize the established goal the VRP solving environment that consists of a database with models of test and real-world VRP problems, database of exact and heuristic VRP algorithms as well as VRP solving system has been determined, Fig. 2. Distributed/parallel versions of VRP algorithms are executed on cluster/grid network. IV. VRP SOLVING SYSTEM VENERA In order to set and visualize the results of the vehicle routing problem, the interactive graphical user interface Venera [3] has been developed, tested, and used for the solution of practical problems. In the current version, Venera has the task of insuring the necessary tools for solving the capacitated vehicle routing problem, solving of the vehicle routing problem with time windows, research, experimenting, and testing of heuristic methods and algorithms. For the implementation of heuristic algorithms the traffic technologist-oriented programming language Mars was developed and tested on the solving of VRP problems from the literature and from practice. Mars interpreter is integrated in the interactive graphical programming environment Venera. Venera and Mars have been developed in the object programming language Java. The main window of Venera, Fig. 3, is divided into three parts, one for the table presenting customer data (1), part for table containing data on the vehicle (2), and a part for graphical presentation of the problem (3). Programming window (4) consists of an editor of the source code and a window for displaying system information and messages while the program is running. DATABASE OF TEST AND PRACTICAL VRP PROBLEMS DATABASE OF EXACT AND HEURISTIC VRP ALGORITHMS 1 TRANSPORTATION GIS VRP SOLVING SYSTEM CLUSTER/GRID Fig. 2. Vehicle routing problem solving environment Since each VRP problem is specific and depends on the stated service and transport conditions, the database of test and practical VRP problems assists the user in classification of his problem. The database of exact and meta(heuristic) VRP algorithms is the collection of VRP solvers implemented in sequential or distributed/parallel form. For solving the practical VRP problems the environment is augmented by geographic information system of transport network with traffic attributes. 3 2 4 Fig. 3. Graphical user interface of VRP solving system The table with the customer data shows the index, the location by means of x and y coordinates, request for delivery, the earliest time of the start of serving, the latest time of the end of serving and the expected time of serving duration. The table containing data on the vehicles shows the index, colour of the vehicle (route), occupancy, remaining capacity, length of the travelled path and the route recording. Apart from the setting of the problem, the graphical interface allows editing of the customer data and manual design of the vehicle route. If necessary, the form and appearance of display can be adapted by tools supplied inside the interface. As a means of staying close to the real problems, the possibility is provided of using the traffic matrix of distances between the customers (examples from literature assume Euclidian distances between two points in a twodimensional space). It is also possible to load problems written in the format of standard Solomon's test of VRP tasks. There is a possibility to test and compare the results obtained by one's own algorithms with the already known solutions and results from the literature. V. PROGRAMMING LANGUAGE MARS Apart from the basic numerical and character data types and language constructions, the programming language Mars also contains data types related to the data that are used in setting and solving VRP problems, as well as special statements and functions for local searches and minimization (maximization) of the objective function [4]. In this way the heuristic algorithm programming is significantly simplified and the code is clear and short. The basic transport data types in the language Mars are CUSTOMER, VEHICLE and ARC. The structure of type CUSTOMER consists of the following data: customer index, customer location coordinates, delivery/collection demand, earliest allowed time of beginning the serving, the latest allowed time of ending the serving, duration of serving and number of visits to the customer. The transport type VEHICLE contains data on the vehicle index, total and remaining vehicle capacity, total travelled path and customer location at which the vehicle is positioned. The type ARC consists of: arc length, index of the starting and destination customer and vehicle index which is the arc owner. The values of these variables are usually set before running the program in the very working environment by means of the graphical interface or by loading the concrete VRP problem from the database. For the needs of the program it is possible to increase the number of transport variables and to declare them subsequently. Thus declared variables represent auxiliary variables, rather than the content of the VRP problem that is being solved. These subsequently declared transport variables are accessed by means of the name stated in the declaration, and their values are assigned to them only during the running of the program. In case one wants to run a block of statements, e.g. within the statement SELECT or FOR loop, one can avoid declaration of the auxiliary variables, since these two programming structures, if necessary, carry out independently the initialization and declaration of the variables. Such approach allows fast interaction between the users and the system as well as obtaining of the answer to simple queries without having to declare the variables. The type of variables CUSTOMER and VEHICLE indicate numerical data which are closely related to the definition of VRP, CVRP, DVRP and VRPTW problems. The grammar of the language is formalized in EBNF (Enhanced Backus Naur Form) notation. Fig. 4 shows the statement for building of a route between two customers ADDARC and statement to delete the arc DELARC described by syntactic diagrams. ADDARC vehicle DELARC , customer , customer arc Fig. 4. Syntax of statement ADDARC and DELARC in language MARS The basic language constructions, e.g. IF, DO, WHILE, FOR, denote meanings that are similar to those of the majority of programming languages. The statements and functions such as MOVE, ADDARC, DELARC, ADDVEHICLE, DELVEHICLE, DISTANCE, ALLVISITED, SOLVED etc. serve for the communication with the VRP problem objects. A special place belongs to the declarative statement SELECT which acts as query, and not as an element of the sequential structure of algorithm step description. The form of the query statement is of similar syntax as the statement of the same name for selection in SQL (Structured Query Language) – a language for making queries to the database management system. The task of the selection statement is to search all the customers, vehicles or arcs that satisfy the stated logical expressions. For all the selected variables, additional search may be requested in order to minimize or maximize the stated objective functions. Such structure of search conditions is extremely useful in the development and coding of the heuristic algorithms. The statement SELECT automates the search within a part of the neighbourhood which is described in the WHERE part of the statement SELECT. By using the options MINIMISE and MAXIMISE precisely the variable is selected which is contained in the selected part of the neighbourhood, and at the same time provides the desired minimal or maximal result of the objective function. An example of a simple query that will select the nearest customer c to vehicle v is presented in Fig. 5. SELECT CUSTOMER c, VEHICLE v WHERE c.INDEX != v.POSITION.INDEX MINIMISE DISTANCE(c, v.POSITION) ENDSELECT Fig. 5. Query structure in language MARS VI. HEURISTIC VRP ALGORITHMS Constructive heuristic methods such as the Nearest Neighbour Heuristic (NNH), the Nearest Addition Heuristic (NAH), the Sweep method, Sweep-NAH method, the Sweep-Farthest Addition Heuristic (FAH) and the Clark and Wright method, along with the 2OPT or local search e.g. Global Best (GB), First Best (FB) on large neighbourhood generated by interchange mechanism [5] written in Mars, using standard test data from the literature set and visualized in the Venera, have shown the results close to the optimal results from the literature. Thus, as an example of the standard test problem E05105e with 50 customers and 5 vehicles, using the two-phase Sweep-NAH algorithm, the deviation achieved in the Venera environment compared to the best result described in literature amounts to 1.7%, and the result is presented in Fig. 6. The points are customers index and arrows show calculated directions of vehicles for each route displayed on the Venera graphical user interface. To each route is assigned a different colour. ADDVEHICLE capacity ENDFOR ENDPROCEDURE PROCEDURE DeleteUnusedVehicles FOR i=VEHICLECOUNT-1 TO 0 STEP -1 IF VEHICLE(i).CAPACITY = VEHICLE(i).CAPACITYLEFT DELVEHICLE VEHICLE(i) ENDIF ENDFOR ENDPROCEDURE PROCEDURE DeleteAllVehicles FOR i=VEHICLECOUNT-1 TO 0 STEP -1 DELVEHICLE VEHICLE(i) ENDFOR ENDPROCEDURE Fig. 7. Clark and Wright algorithm in language Mars Fig. 6. The solution of standard test example E051-05e For the example E076-10e with 75 customers and 10 vehicles applying the Clark and Wright algorithm the deviation amounts to 6% compared to the best published solution. The example of the Clark and Wright algorithm realization in Mars is presented in Fig. 7. '----------------------------------------------' ' CLARK AND WRIGHT ALGORITHM ' '----------------------------------------------' CLEAR AddVehicles CUSTOMERCOUNT, 160 CUSTOMER depot = CUSTOMER(0) NUMBER end, end0=0 FOR i = 1 TO CUSTOMERCOUNT-1 ADDARC VEHICLE (i-1), depot, CUSTOMER (i) ADDARC VEHICLE (i-1), CUSTOMER (i), depot ENDFOR DO SELECT ARC arc1, ARC arc2 WHERE EQUAL CUSTOMER (arc1.TO, depot) EQUAL CUSTOMER (arc2.FROM, depot) NOT EQUAL VEHICLE(arc1.VEHICLE, arc2.VEHICLE) arc2.VEHICLE.CAPACITY arc2.VEHICLE.CAPACITYLEFT < arc1.VEHICLE.CAPACITYLEFT MAXIMISE arc1.LENGTH + arc2.LENGTH DISTANCE(arc1.FROM, arc2.TO) ENDSELECT IF FOUND (arc1) MESSAGE "MAX saving -> " + arc1.FROM.INDEX + " on " + arc2.TO.INDEX end = 0 DO SELECT ARC arc3 WHERE NOT EQUAL ARC (arc3, arc2) EQUAL VEHICLE (arc3.VEHICLE, arc2.VEHICLE) ENDSELECT IF FOUND (arc3) ADDARC arc1.vehicle, arc3.FROM, arc3.TO DELARC arc3 ELSE end = -1 ADDARC arc1.VEHICLE, arc1.FROM, arc2.TO DELARC arc1 DELARC arc2 ENDIF LOOPIF end = 0 ELSE end0=-2 ENDIF LOOPIF end0 = 0 DeleteUnusedVehicles PROCEDURE AddVehicles(NUMBER number, NUMBER capacity) DeleteAllVehicles FOR i=0 TO number-1 In the first part of the program the FOR structure creates as many routes as there are customers, and each route consists only of the depot and one customer. After the initialization the first SELECT statement selects those routes that need sufficient capacity of one of the vehicles in order to combine the routes and at the same time to maximally save the length of the total travelled distance by the vehicle. The next SELECT statement combines two routes and reduces the number of the necessary vehicles by one. Selection and combining of routes continues until is possible to gain a savings. VII. TRANSPORT GIS The solving of the vehicle routing problem is a demanding mathematical problem, but mathematical methods and models alone are not sufficient for its practical solution. It is necessary to combine the VRP model with the real environment of a transport company whose transport organization needs to be improved, e.g. by suggesting changes of transport routes. As a system for managing spatial data, the Geographic Information System (GIS) appears as one of the obligatory interfaces between the methods developed on the VRP mathematical model, underlying real transport network and the actual working environment of the transport company with all its specific operations. The GIS system, composed of a set of programming tools that are used for the input, storage, manipulation, analysis and presentation of spatial data, links all the spatial data within the applied coordinate system, e.g. geographic latitude and longitude. In order to input and prepare the real data on the locations of customers as well as to visualize the existing and the resulting routes on a digital map, special GIS application Miranda has been developed. The current transportation layer of the network of urban traffic routes is expanded by a layer of actual constraints acting on the allowed traffic flow, Fig. 8. Also, since by setting the actual VRP problems the addresses of collection or delivery locations are most usually known, rather than their geographical coordinates (latitude/longitude), the address module of the geo-information system has been used. The address module performs the transformation of addresses into adequate digital map coordinates. For the needs of transforming the actual traffic route network into adequate graph used for the solving of the VRP problem, the layers of the digital map are supplemented by a layer of the shortest paths between the given locations. The shortest path calculation is performed by modified Dijkstra algorithm. While calculating the shortest path, the application takes into consideration the direction of the streets and the allowed turnings at intersections and generates an asymmetric matrix of the shortest distances between all the given locations. This allows the solution of practical VRP problems. Since the real transport network represents an incomplete graph, a fully connected directed graph was constructed and used in the calculation of the shortest path, as the first approximation of the real transport network. Non existing connections like prohibited directions, e.g. one-way street, are added in the form of bidirectional arcs but one direction is always avoided in route due to assigned weight (large number) which are penalised by objective function. ∞ 1 ∞ ∞ ∞ 3 2 ∞ ∞ 4 5 ∞ Fig. 8. Transport network layer, traffic data layer and virtualy connected directed graph Since the accuracy of the solution of the practical VRP problem is directly related to the accuracy of the traffic data on the digital map, it is necessary that the traffic layer data are precise and valid. Updating of the data is an ongoing process, and the accuracy of the data in the spatial and attribute base of the digital map, along with the collected data from the field, can be supplemented by the simulation and visualization of the existing and calculated routes obtained during the solving of the VRP problem. The digital map with the transport network and traffic layer was provided for the needs of the project by the company Mireo d.o.o. VIII. THE SOLUTION OF A PRACTICAL PROBLEM For the needs of solving the practical VRP problems, cooperation was established with the municipal waste collection company Čistoća d.o.o. from Zagreb, and the garbage collecting routes were optimized for the district of Novi Zagreb. Based on the work orders and by processing the data from the statistical reports, the data on the available vehicles and their capacities, delivery places and the existing methods of vehicle routing while garbage collecting were gathered. 169 places of garbage collection in the region of Novi Zagreb were included. The garbage collection in the cities is a municipal service activity, which from the aspect of selecting the optimal routes, can be very well described as an Asymmetric Capacitated Vehicle Routing Problem (ACVRP). In ACVRP problem all the customers and their orders are known in advance, the vehicles are identical, and the common starting point is at the central depot. The only constraint that exists is the capacity of individual vehicles. The objective function expresses the request for minimizing the overall cost (e.g. weight function of the number of vehicles and their total length or time) in serving all the customers. The transport management may be improved by changing the route plans alongside keeping the existing place of collection. In case there is intention and sufficient financial means for changing the collection places, new collection places could be proposed regarding the changes of the density of population and the newly formed distribution of the collection places. The solving procedure of the practical VRP problem by using the Venera/Mars system combines the processes of data collection, data processing by means of GIS tools, analyses of the current routes, interactive generation of the new route plans by using heuristic methods and presentation of results. Thus, in the procedure of solving the set problem, first a simulation of the existing routes was performed. By entering the data from the work orders into Miranda, by calculating the distances matrix, by transferring the collected and calculated data into the working environment of the Venera, and by running the simulation program of driving according to the route plan from the work orders entered in the programming language Mars, the data for the existing routes were obtained. For the calculation of the new route plans, several constructive heuristic algorithms and their chains were implemented in Mars, and performed in Venera, in order to find the initial solution (NNH, NAH, Sweep, FAH, Clark and Wright) and made improvements with additional local search (2OPT, , GB, FB) constrained with selected number of iterations (1E5, 1E6). All the obtained results indicated that in order to realize the required routes one vehicle less would be sufficient compared to the initially used number of vehicles. In case of applying the algorithms NAH and GB-1E5 with the reduction in the number of vehicles, also the totally travelled path necessary to visit the collecting points is reduced by 29% compared to the totally travelled path according to the current work orders. While entering the data and using the available digital map, several errors have been noted. Difficult to see by the naked eye, there are errors in the map construction which caused traffic inaccessibility of some minor areas on the map. The inaccessibility was reflected in the impossibility to calculate the shortest path to certain locations. The error was identified and eliminated while analyzing the asymmetric matrix of distances and try to explain the poor results in the operation of certain algorithms. The complexity of modelling and solving the practical VRP problems regarding a number of special requirements that are brought by the actual problems, as well as the need for ever shorter solving times, imposes additional requirements on the approximate solving methods as well. Therefore, the distributed and parallel processing on the computer cluster/grid [6] in the form of parallelization of the time critical steps of the sequential part of the heuristic algorithm, decomposition of the problem and distribution of the search space between the processor or concurrent search with different forms of synchronization and cooperation between sub-problems, represents an adequate framework in the optimization of the transport management. and the totally travelled path were achieved, compared to the initially found values. With the aim of allowing the development of distributed applications for solving of the VRP problems, the Venera system is expanded by new graphical interface that will allow setting of the problem and visualizing of the solution on the local computer, whereas the solving itself will be carried out on the computer cluster network. The development of new data types, e.g. multiple depots, garages, as well as new Mars instructions for distributed programming are underway. IX. CONCLUSION REFERENCES For the solution of the problems of distribution or collection of goods, the descriptions of technological processes need to be brought nearer to the description of the mathematical model. Apart from the case of fewer number of vehicles, the mathematical combinatory optimization problem, can not be generally and exactly solved within an acceptable period of time. Practical solutions are obtained by approximation methods that are usually of heuristic nature. The combination of the geographic information system, mathematical methods and databases, improves significantly the utility value of the existing optimization methods, i.e. algorithms, since the verification of the new and the simulation of the existing route plans can be performed fast. For the needs of solving the practical VRP problems, an interactive system for VRP problem solving was developed, composed of the graphical user interface and a language interpreter to perform heuristic algorithms recorded in the traffic technologist-oriented programming language Mars. The operation of the system was successfully tested by solving a number of standard VRP examples from the literature, with the best obtained result indicating slight deviation from the optimal result from the literature. In solving the ACVRP problem of optimizing the waste collecting routes of the municipal waste collection company, the real data about the vehicle fleet were used, and with the help of a digital map the data on the collection places and the direction of streets. By applying the heuristic algorithms, the savings in the number of vehicles [1] 'CRO-GRID Applications' – Optimisation of Transport Management', Complex Technological Research and Development Project STIRP-42/2002, Ministry of Science, Education and Sport, Republic of Croatia [2] P. Toth, D. Vigo, The Vehicle Routing Problem, SIAM, Philadelphia, 2002. [3] T. Carić, H. Gold, A. Galić, “Interactive Programming Environment For Solving Vehicle Routing Problem”, Paper No. 2814, Proceedings 4th European Congress on Intelligent Transport Systems, 24-26 May 2004, Budapest, CD-ROM [4] T. Carić, H. Gold, A. Galić, “Heuristic Solver System for a Practical Vehicle Routing Problem”, Proceedings of the 11th World International Congress on Intelligent Transport Systems, Paper No. 2070, Nagoya, Japan, Oct. 18-22, 2004, CD-ROM [5] I. H. Osman, N. Christofides, "Simulated Annealing and Descent Algorithms for Capacitated Clustering Problem", Research Report, Imperial College, University of London, 1989 [6] I. Ćavar, A. Galić, J. Fosin, T. Carić, H. Gold, “Development of Distributed System for Practical Vehicle Routing Problems”, Proceedings of XXX International Conference on Software, Telecommunications and Computer Networks, Poster, October 10-13, 2004, Split, Dubrovnik, Venice, p. 99 [7] http://venera.fpz.hr