Logistics shares for the collection of recyclables
Instead of intro
When the processes of waste collection and recycling will be fully developed in Russia, it is not easy to say, but I want to avoid participating in landfill replenishment now. Therefore, in many large cities, one way or another, there are volunteer movements that are engaged, in particular, in separate collection.
In Novosibirsk, such an activity is formed around the Green Squirrel action, in which once a month, ecologically concerned citizens bring accumulated recycled household waste to predetermined places at a certain time. By the same time, a rented truck arrives there, which transports the collected and sorted salvage to the site, from where it is redistributed between various processing enterprises. The action has existed since 2014, and since that time the number of recycling points has increased significantly, as well as its volumes. For routing the trucks, the gaze alone was lacking, and we began to develop optimization models to minimize transportation costs. This article is the first of these models.
In Section 1, I will describe in detail and with illustrations the scheme for organizing the action. Further, in section 2, the problem of minimizing transportation costs will be formalized as a routing problem for heterogeneous vehicles with time windows (heterogenious fleet vehicle routing problem with time windows). Section 3 is devoted to solving this problem using a freely distributed package for solving mixed-integer linear problems of mathematical programming GLPK.
1. Action "Green Squirrel"
Beginning in 2014, the Live Earth initiative group has been conducting a monthly campaign on separate collection of recycled Green Squirrel in Novosibirsk. At the time of writing the article for recycling with a number of reservations accepted plastic waste labeled PET, PE, PP, PS, glass, aluminum, iron, household appliances, waste paper and more. More than 50 volunteers participate in the preparation and holding of the action. The promotion is not commercial, participation in it is free and does not imply a monetary reward. ')
Points
The action is held in 17 points of the city, spaced from each other at distances covered by the car during the time from 15 to 90 minutes. In the photo one of these points: on the left along the wall there are bags for collecting various plastic fractions, on the right is a truck into which everything is loaded later, and in the center is a volunteer with ears.
The curators, who have time limits in which they are ready to perform their duties, organize all the activity at the point. When planning the action, the curators report the time interval within which the action must take place at their point.
There is also data on average volumes of recycled materials collected at each of the points.
Routes
Points are organized into routes, sequentially driven by truck. Truck movements are monitored by route curators who monitor the operational situation and make decisions on handling special events.
Trucks
They are rented out on a general basis as part of proposals for the hourly rental of freight transport. It is not possible to compact plastic in place, therefore the main parameter characterizing the truck is the volume of the body. Load capacity in our case is not a limiting factor.
The main expenses of the action are connected precisely with the payment of the rental of trucks, so its reduction is crucial for the existence and development of our action, which acquires institutional significance in the sense of forming ideas about responsible consumption. Next will be described an approach to solving this issue, based on the use of discrete optimization methods, namely mathematical programming.
2. Formalization
When constructing a mathematical model, we will remain within the framework of linear mixed-integer programs, for understanding of which knowledge of class 7 algebra is sufficient.
The only difficulty can be associated with the use of abstract symbols and summation signs in formulas. I hope this does not scare readers who have infrequent meetings with mathematical texts.
The optimization model can be divided into four components:
the formation of groups of points that make up a separate route;
determination of the detour pattern of each group;
meeting the requirements for the time of arrival of the truck at each of the points;
determining the type of truck needed to service each of the routes.
Consider each of the parts, introducing as necessary the necessary notation.
Formation of groups of points
Let be V = \ {1, \ dots, n \} there is a set of indices of collection points for recyclables, and the site where the collected recyclables are then transported - we will call it a depot - has an index of 0. We set \ bar {V} = V \ cup \ {0 \}
Each group of points forms a separate route. Through denote a set of route numbers.
Let the value equals one if point included in the route with the number and zero otherwise. Then the requirement that the point must enter one of the routes can be written by equality
Depot must enter all routes:
Subtleties
Unfortunately, such a recording creates computational problems related to the symmetry of an admissible region. It can be eliminated by adding a number of restrictions that ensure the choice of a lexicographically minimal partition. More in Russian about this can be read, for example, here .
Determination of the detour pattern
Routes are an alternating sequence of points and crossings between them. Formally, they all start at one of the points of the set and end at the depot, but it will be easier to assume that all routes are cyclical. This assumption does not change the essence, but makes all the peaks the same: in this case there are no end peaks, they are all transit peaks.
For points and route let's get the variable equal to one if the route c number the truck makes the move from the point exactly and zero otherwise.
Then we demand, firstly, that the truck moving on the route visited point if, after dividing it into groups, it fell into the group with the number :
Secondly, the truck after arriving at the point must go with her.
You may notice that these limits allow values set routes, which are a set of non-intersecting loops. Routes of this type, of course, do not make sense, and you want to add a number of restrictions to avoid this.
About elimination of subcycles
One way would be to introduce auxiliary non-negative values. Recorded using these values, the set of relations eliminates combinations of values. that specify routes that are not connected loop.
These ratios set the flow from the depot to the rest of the route points. At each intermediate point, a unit of flow is absorbed, so in order for a network to have a power flow equal to the number of points minus one, it is necessary that the route be connected.
Satisfying requirements at the time of arrival of the truck at each of the points
In other words, it is necessary to visit points only inside the time windows indicated by the curators. Through and denote, respectively, the beginning and end of the time interval in which the curator of the point may attend her.
To track the implementation of these restrictions, we will need information about the time spent by the truck during stops and crossings on the route. Through denote the duration of loading at the point and through - time of moving from point exactly Make a reservation that for all , and generally can be performed for any
We introduce variable non-negative values and equal to arrival and waiting times when driving on the route , respectively. For the entered values, the following relationships should be fulfilled.
Waiting time can not be less than the time required for loading
and is zero if the point does not belong to the route
Time of arrival at the point calculated through the corresponding times for the preceding point There is a fairly large constant is used to eliminate unnecessary dependencies when moving between and not done
Arrival and departure of the truck must be within the designated interval curator.
Determining the type of truck needed to service each of the routes Denote the many types of trucks that are available for rent through Truck type characterized by body volume and the cost of hourly rent Minimum truck rental type denote by Recycled volume collected at point denote by
We introduce variables equal to one if truck type assigned to service route with number and zero otherwise.
Integer variables set the time of renting a truck type serving route number For each route, , you must assign the type of truck:
In accordance with the splitting of points between routes, some routes may be trivial, that is, contain only depot. If route nontrivial, the truck assigned to it is rented for at least hours
At the same time, the duration of the lease should also exceed the total duration of stops and crossings in the route.
Add constraints providing the property: if a truck is of type not assigned to route , its rental time is zero.
All recyclables collected at the points of the route should fit in the back of the truck.
Finally, our goal is to minimize the cost of renting a truck, which, using the entered notation, is written as
Search for a solution
It is easy to make sure that all the expressions involved in the optimization model are linear functions of variables, therefore, to find accurate and approximate solutions, you can use standard packages for solving problems of mixed-integer programming such as Gurobi , CPLEX , Xpress , ORtools , SCIP , BLIS , etc. We write the model of minimizing transportation costs in the GMPL language. This will allow us to use the freely distributed GLPK package for our purposes. For writing code and debugging the model, it will be convenient to download the GUSEK development environment , which already contains GLPK in its composition.
GUSEK looks like this:
On the left, we see a description of the model, and on the right, a window displaying information about the progress of the calculations that the solver will deliver after launch.
Full description of the model
param numOfPoints > 0, integer; # param numOfTypes > 0, integer; # param numOfRoutes = numOfPoints;# set V := 1 .. numOfPoints; # set Vbar := V union {0}; # () set T := 1 .. numOfTypes; # set R := 1 .. numOfPoints; # ############### param WDL >= 0, default 8; # param B{i in Vbar} >= 0; # param E{i in Vbar} >= 0; # param L{i in Vbar} >= 0; # param D{i in Vbar, j in Vbar} >= 0, <= WDL; # param G{i in V}, >= 0; # , 3 ########## param C{t in T}, >= 0; # param P{t in T}, >= 0; # param U0{t in T}, >= 0; # , /********************************************** * **********************************************/ var z{Vbar, R} binary; # , , st pointToGroup 'point to group' {i in V}: sum{r in R} z[i, r] == 1; st depotToGroup 'depot to group' {r in R}: z[0, r] == 1; st lexMinGroups 'lexicographycally minimal division' {i in V, r in R: r <= i}: 1 - z[i, r] <= sum{j in V: j <= i - 1}(1 - sum{k in R: k <= r - 1} z[j, k]) + sum{k in R: k <= r - 1}z[i, k] ; /********************************************** * **********************************************/ var x{Vbar, Vbar, R} binary; # , c r i j, . st visitPoint 'visit point' {i in Vbar, r in R}: sum{j in Vbar} x[i, j, r] = z[i, r]; st keepMoving 'keep moving' {i in Vbar, r in R}: sum{j in Vbar} x[j, i, r] = sum {j in Vbar} x[i, j, r]; var f{Vbar, Vbar, R} >= 0; #, . st flowFromDepot 'flow from depot' {r in R}: sum{i in V} f[0, i, r] == sum{i in V} z[i, r]; st flowAlongActiveArcs 'flow along active arcs' {i in Vbar, j in Vbar, r in R}: f[i, j, r] <= numOfPoints * x[i, j, r]; st flowConservation 'flow conservation' {i in V, r in R}: sum{j in Vbar} f[j, i, r] == sum{j in Vbar} f[i, j, r] + z[i, r]; var a{i in V} >= 0; # var w{i in Vbar, r in R} >= 0; # st wait 'wait'{i in Vbar, r in R}: w[i, r] >= L[i] * z[i, r]; st dontWait 'dont wait'{i in Vbar, r in R}: w[i, r] <= (E[i] - B[i]) * z[i, r]; st arrivalTime 'arrival time' {i in V, j in V}: a[i] + sum{r in R}w[i, r] + D[i,j] <= a[j] + 3 * WDL * (1 - sum{r in R} x[i, j, r]); st arriveAfter 'arrive after' {i in V}: a[i] >= B[i]; st departBefore 'depart before' {i in V}: a[i] + sum{r in R}w[i, r] <= E[i]; /********************************************** * , **********************************************/ var y{t in T, r in R}, binary; # , t r, . var u{t in T, r in R}, integer, >= 0; # t, rst assignVehicle 'assign vehicle' {r in R}: sum{t in T} y[t,r] == 1; st rentTime 'rent time' {r in R, t in T}: u[t, r] >= sum{i in V, j in Vbar}D[i, j] * x[i, j, r] + sum{i in Vbar}w[i, r] - WDL * (1 - y[t, r]); st minRentTime 'minimal rent time' {r in R, t in T}: u[t, r] >= U0[t] * (y[t, r] - sum{i in V}z[i, r]); st noRent 'no rent' {t in T, r in R}: u[t, r] <= WDL * y[t, r]; st fitCapacity 'fit capacity' {r in R}: sum{i in V} G[i] * z[i, r] <= sum{t in T} C[t] * y[t, r]; minimize rentCost: sum{t in T, r in R} P[t] * u[t, r]; solve; /********************************************** * **********************************************/ printf{i in V, r in R} (if 0.1 < z[i,r] then "point %s to group %s\n" else ""), i, r, z[i,r]; printf{r in R, i in Vbar, j in Vbar} (if 0.1 < x[i, j, r] then "route %s: %s -> %s\n" else ""), r, i, j; printf{i in V} "point %s arrive between %s and %s (actual = %s)\n", i, B[i], E[i], a[i]; end;
For a quick start, I also add data prepared for use in the model, taken from the head:
After copying the model code into a file with the name, for example, model.mod, and the input data is in the data.dat file, everything is ready for launch. Set a limit on the calculation time of 100 seconds (this is done using the βtmlim key [time in seconds]), passing the path to the file with input data (using the βd key [file path]),
and hit F5. If successful, messages will appear in the window on the right, and after a hundred seconds we will have the best solution in our hands, which GLPK managed to find in the allotted time.
In the blue text, we are interested in the value after the caption "mip =". As you can see, it decreases from time to time. In the process, there are all new solutions, the value of transportation costs for the best of which is displayed in this column (so far there are 14,700). The next number is a lower bound for the best existing one, i.e. the optimal solution. Initially, the assessment is significantly underestimated, but over time is refined, that is, increases. The values ββon the left and on the right come closer, and the relative gap between them at the time of the screenshot is 54.1%. As soon as this number becomes zero, the algorithm will prove that the best solution found is the best possible. To wait for this event in practice is not always justified, and not only because it takes a long time, but it is important to make a reservation that, as a rule, a good solution is found relatively quickly, and the main time costs are related to the refinement of the estimate required for proof of non-improvement.
Instead of conclusion
The routing tasks are extremely difficult computationally, and with the increase in the number of points that need to be visited, the time required for the solver to find a solution and prove its optimality grows rapidly. However, for fairly small examples, the solver can build a good set of routes in a reasonable time and can be used to support decision making. An analysis of the proposed routing options has helped us discover significant opportunities to reduce costs, and this is crucial for the existence and development of the promotion.
Our further efforts were directed towards working with uncertainty in the volumes of recycled materials collected at the points. We are developing a range of stochastic programming models for making strategic and operational decisions in truck routing. If the topic turns out to be relevant and arouses interest, I will write about it too, because soon we all will have to immerse ourselves in environmental issues much more thoroughly, in which I wish us success.