The software application for cargo transportation routes optimization

This article discusses the possibility of reducing logistics costs for transportation using the genetic algorithm for solving the Traveling Salesman problem. As a solution, it is proposed to develop an algorithm of actions for optimizing cargo transportation routes and to work out some points of the algorithm that will bring the result to the desired form. Based on this, the steps that are included in this algorithm, which was developed using an application using the Electron framework (JavaScript programming language), are analyzed. Based on the proposed algorithm, a practical situation is resolved and an optimal route is drawn up for orders of the courier organization. Such an application will improve the technical and operational performance of the enterprise, strengthen coordination of work and shippers, reduce transportation costs, use road transport more efficiently.


Introduction
Nowadays, one of the social needs is to obtain (purchase) objects of any categories -from basic necessities to luxury and social status items. The development of communication technologies has greatly facilitated the acquisition of various kinds of goods and services. Now everyone can easily order food, clothes, electronics, etc., "in one click", using the capabilities of the "World Wide Web" [1][2][3][4].
However, everything is not so simple for the cargo transportation and delivery industry. With the increase in the number of orders, the complexity of the task of optimizing the goods delivery to addresses also increases [5][6][7][8].
If we consider only aspects of the shortest route, covering all points on the route, then this problem reduces to the well-known traveling salesman problem in general form. Unfortunately, there are a number of factors that make it difficult to optimize the freight process [9][10][11]. Among them are: • Traffic situation.
• Time for lunch, opening, closing of establishments (convenient time for receiving parcels, if we are talking about private individuals). • Car loading capacity.
• Type of car (for loaded wagons it is forbidden to drive along some roads within the city limits). In general, the task of optimizing cargo transportations has an important economic effect on enterprises providing postal and courier delivery, as well as the delivery of heavy goods. Following the optimal route will save both time and fuel, which over time will bring profit to the enterprise.

Mathematical modeling of the problem
There are several solution algorithms for the general problem of the "Salesman". One of the most common solutions to the problem is a complete enumeration of all possible paths and the choice of the shortest path over distances. Its complexity is characterized by the formula: where n -the number of route points. This option is not suitable for freight conditions, as the route usually consists of 40-45 points per day. Some organizations can build routes in advance for several days. Thus, the number of points increases several times. For such complexity of the algorithm, this task becomes impossible in the required time frame.
Another solution method is the genetic algorithm. The genetic algorithm is based on the random search method. The main disadvantage of random search is that it can be assumed only approximately how long it will take to solve the problem. To avoid this, methods that are open to the study of the evolution and origin of species are used. As you know, the most fit individuals survive in the process of evolution. This leads to the fact that the fitness of the population increases, allowing it to better survive in changing conditions. Individuals are routes, and their genes are paths from point to point (component parts of routes). The iteration of the algorithm consists of 3 stages: selection, crossing and mutation. The best individuals survive the selection, then from their genes, by mixing the genes of the individuals with each other, a new generation of individuals is formed. After crossing the genes of a new generation of individuals, random mutations are applied (changing the parameters of the gene). Thus, the algorithm moves to the best result.
The complexity of the genetic algorithm has an approximate estimate, calculated by the formula: where nthe amount of the route points; kset number of iterations to a stop.

Software application development
Electron was chosen as the main framework for application development. It uses JavaScript to develop internal program logic and HTML to implement a visual interface. This was done on the basis that this framework has proven itself in the development of high-performance applications for personal computers based on the Windows operating system. It also has the required number of libraries for implementing specific functions: binding Yandex.Maps, implementing interaction with a database based on SQLite DBMS, as well as a mechanism for packing a project into a portable version of the application. When implementing the application, the framework was divided into 3 modules: map module; module for interacting with the database; module for the implementation of the genetic algorithm with an additional calculation of the optimal route parameters.
The map module includes methods for accessing the Yandex.Maps API, which, in turn, provides the necessary functionality for working with routes.
The use of maps from Yandex makes it possible to exclude the factor of the traffic situation in the task of optimizing cargo transportation routes, as Routing is performed as quickly and conveniently as possible for the user. Functional display of traffic jams, marks with construction work is provided. As an alternative to the main route, additional ones may be offered that will help save time on the way. When laying routes, the number of traffic lights on the road, as well as turns, is taken into account.
The database interaction module includes methods for connecting, saving data, creating, deleting and changing records in a local database managed by SQLite DBMS. There are 4 tables in the database: "Routes" -a table that stores information about routes; "Points" -the table where the route points are located. It has a foreign key indicating that the point belongs to a specific route; "Note_points" -a table Placing the tables exactly in this form allows them to return to their normal form, corresponding to the properties of relations in the relational data model that characterizes the tables in terms of redundancy.
The third module -the implementation module of the genetic algorithm with additional miscalculation of the parameters of the optimal route -is a complete implementation of the genetic algorithm with subsequent transfer of control to the map module to place many points in the optimal sequence. Each stage of the algorithm is presented as a separate method. The set number of iterations of the algorithm was chosen based on empirical studies, and is equal to 800 iterations. After calculating the shortest path, additional characteristics of the route are also calculated -the fuel consumption of each available transport unit on the full path, based on the specific fuel consumption per 100 kilometers, and fuel costs, according to the latest data.
The algorithm of the program. Consider the algorithm of the program, which allows to optimize the route of cargo transportation, which is presented in figure 1. Next, let us consider the tabs of the program, their functions and an example of the program. When you open this program, the main menu opens, in which there are buttons "menu", "clear the current route", "build the shortest path", "save the route", and also the map is located. When you click on the "clear route" button, the program will delete the data entered by the user for further work. When you click on the button "build the shortest path", the route will be optimized taking into account the minimum costs. You can save the desired route using the "Save Route" button.
When you click on the "menu" button, a list opens, in which there are sub-items: "Map", "Routes", "Points", "Advanced", "Vehicles.
In the "Routes" sub-item, the user opens a list of saved routes.
In the "Points" sub-item, the user indicates the points of stops by which the optimal route will be calculated.
In the sub-item "Vehicles" the user can choose a convenient means of transportation.

Experimental study
After the implementation phase of the application, it was necessary to test it to identify errors in finding the shortest path. For this, data on orders of a real courier service for 30 days were taken as a basis. The data was plotted on a map, and an algorithm for finding the optimal route was launched for each route. The result of the algorithm for one of the routes is shown in figures 2 and 3. Data on fuel consumption and price before and after applying the algorithm are presented in table 1.    Studies have also been conducted on the dependence of the accuracy of the result of constructing the optimal route on the number of genetic algorithm iterations ( Figure 5).  Figure 5. Dependence of the accuracy of the constructing the optimal route on the number of iterations of the genetic algorithm.
An analysis of the results showed that the most accurate number of iterations is the number 800. For a given number of iterations, the accuracy of the algorithm becomes approximately 98%, which is quite sufficient for the task, and the performance is higher than that of 1000 iterations with an accuracy of 99%.

Conclusion
The effectiveness of the application under consideration was proved using the Electron framework (JavaScript programming language) based on the genetic algorithm. To do this, a study of the results of his work was conducted on the example of a real summary of orders of a courier organization. Yandex.Maps API was used in the application, the application's performance is observed even in adverse traffic conditions, due to the efficient operation of the route-building algorithm according to traffic density.