 Hi, everyone. My name is Rahul and I'm a data scientist at locust.sh. We are an optimization company majorly focused at optimizing decisions and logistics. Today, I'm going to speak about optimizations for sales fleets and, basically, from a perspective of FMCG companies. This is optimizing the movement of salesmen or sales people and the next part of delivering the goods, the last mile routing part. So the outline of the talk is, basically, I'll explain what is a salespeed. Why do you actually need a salespeed? Dig a little deeper into what are the challenges? Dig a little deeper into the stakeholders for the same. The salesman, the shopkeepers, the sales managers formulate the problem. And then talk about our solutions and then some ground challenges that we face while deploying these solutions. And both from a quantitative perspective, from a math model perspective, and also from real-world soft constraints, what are the ground troubles of deploying such a solution? So the first thing is, what is a salespeed? So let's look at a typical FMCG company. The FMCG company would have like 8,000 to 10,000 stores from Kirana stores to wholesale stores in a particular city. Now what they want to do is that they have a fleet of salesmen, like 20, 30 salesmen. And these salesmen need to go visit each of these stores and collect orders. Once the orders are collected, the company would send out delivery vehicles, dispatching the orders. So, basically, it's a two-step process of, once that you need to figure out which salesmen should go to which store selling what product, take what route selling that product. And once that is done, you want to send out delivery vehicles dispatching those orders. The objective of this entire process is to get as much revenue as you can. So send the right person to the right store selling the right product, and also reduce costs. So you also want to minimize costs like transportation costs and also maximize the amount of time the salesman spends in the store as compared to on the road. A question that I get often is, why do you need a sales suite? Like, we are in a, we are in the digital era. We are in the time of Flipkart and Amazon where people order products on a web application. And once the orders are there, you can always dispatch the orders. So this is actually a bit inefficient that you're sending a person on the road to collect, to physically interact with another person to get an order. From a FMCG perspective, that image over there is a typical shelf that you would see at a store. And it has products from all brands and companies. So shelf space is very, very important. Given that it is a push sales model. So people are really working, salesmen are actually going on ground pushing products. And if you are not selling your product, someone else is. And a quote that I got from one of our partners was that increasing sales by 0.5% is a little bit more important than reducing costs by 2%. That being said, it's not true that reducing cost is not important. It is very important. But the reach is everything. You need to reach the customer and you need to push your product on the shelf. That's why salesfeeds and sending salesmen or salespeople on ground is very important. So I'll dig a little deeper into each of our stakeholders. One of the insights that from the entire exercise of building the solution and deploying it in India and Southeast Asia is that other than from a math perspective, looking at it as a math problem, you need to appreciate the human element. These are real people who we are optimizing solutions for and they have some real contributions in terms of, in terms of their experiences that you need to capture in the math model. It cannot be purely done sitting in a lab. So we did a number of user interviews interacted with these stakeholders. The most important stakeholder in this is the salesperson. And you get a very interesting insight from the person that the classical optimization literature would tell you that to solve, to get the perfect route, you minimize the distance. And that's how you're going to reach the maximum amount of stores in the minimum amount of time. But a person's told me that you need to be at the right store at the right time. So over because he or she has worked for the past 20 or 30 years in the industry, they know that if they visit a wholesale store at a particular time during the day, they're going to get more money as compared to if they would have visited that store during the closing hours or early in the morning. So these are regional heuristics that these people have figured out based on their experience. And we were really interested in modeling these, like we have a lot of historical data. We want to figure out, we want to try to add these objective terms in our optimization algorithms to understand and then optimize for these objectives that can actually get you more money. So if you want to get more money, you want to be at the right store at the right time. So making a sale is more about being at the right place at the right time. That is one of the insights that I got from salespeople. The shop owner actually, shop owners in, this is a little bit more specific to Kirana stores. So this also reinforces the same fact. Basically, from a Kirana store's perspective, business for him or her is more about managing cash flows, although they buy from every other company, but they have limited and constrained resources. And again, if you are at the right time at the right, if you are at the right store at the right time of the day, which might depend on number of factors, like day of the week, month of, what is the month? Is there festivity? Are there festivities coming around? You can actually increase your revenue potential from a particular store. These numbers, something that we got from looking at a lot of historical data also, that revenue potential of stores is not static across the day, and it can be very dynamic. So you want to reach at the right store at the right time. The third stakeholder is the sales manager. So the sales manager is the person who has to make these plans. You would have 5,000 outlets and all these salesmen, and now he needs to plan for the next month, create these permanent journey plans, as they say it. So that person says that this is not a perfect science that you can actually have an optimization algorithm which will give us, even if you don't use optimization, if you use historical heuristics and intuition and make the beats, it is still not going to be a perfect science. And the other problem is that even if you build such a thing, it has to, it needs to be very repeatable because although it says permanent journey planning, every month they get 500 to 1,000 new stores. Now it needs to be re-optimized. You need to create new routes. So permanent journey planning by itself is very dynamic. And their point is that deploying or developing these plans would require more than just optimizing on regular objectives. You need to look at software constraints, figure out how would you model these things in your equations. So from a bird eye perspective, I'll give a problem statement. What is the problem statement? So you have a set of outlets that need to be visited. These outlets would have different requirements from foods and beverages, to personal products, to detergents. There are different people selling these products. Those are the salesmen. And there is a finite point duration for which, during which these outlets need to be visited. So you need to take these outlets, create tools for salesmen, that is the routing part. Then assign these routes to different salesmen. You assign them. Then you take these routes and put them on different days. That's the scheduling part. So it is a very convoluted optimization problem which does three interleaved optimization simultaneously. Routing, salesman assignment, and also scheduling. So from a computation perspective, it is NP-hard. I'll get a little deeper into it in a while. I'll just get into each of these boxes. So a sales suite. A sales suite I already explained, it's a salesman tour. It is a sequence of orders that need to be visited. So one common objective of defining a good sales suite is the salesman spends more time in the store than on the road. So that is typical distance minimization or time minimization that you need to achieve. Two interesting objectives that we added to our equations were salesman fatigue, that if the salesman is more tired, then he or she would, then you basically want the salesman to visit the higher revenue stores when he's fresher during the day. And lower revenue stores may be a little later. And the other was, so you minimize the salesman fatigue and also maximize the revenue potential. So this is an interesting objective because your sequence of just minimizing distance might not give you maximum revenue possible. So you need to assign the right outlet to the right salesman. That is one thing. The other thing is they need to be visited at the right time. So it is a traveling salesman problem with time windows as constraints also. A few graphs from, this is abstracted data from some of our clients. Different sales, so for the same, this graph basically shows that if you look at a particular outlet and historically different salesman have gone there with selling different products. So that is S1, S2, S3. Different salesmen have different skills of selling to the same store. So a salesman who probably be selling products like detergents for the past 10, 15 years would be selling detergents a little bit better than other products, which is very intuitive. But it was just nice to see that intuition is being backed by data. And also it again reinforces the importance of sales speed that people actually are actually adding real value in going and selling. You can actually get more money if the right person is going and selling. So we looked at a number of other parameters from the salesman's perspective, like his or her experience. What are the outlet familiarity, product familiarity, regional familiarity and a number of other miscellaneous features to create this matrix of if a particular salesman is going to a particular store, what is its revenue potential? So it's a salesman cross outlet matrix in a way which is basically derived from historical data. This is a graph on the revenue potential of a store. Just two kinds of stores that we are looking at. One is a Kirana store, the blue, it's not clear. The red line is a Kirana store. The blue line is a wholesale store. So as intuitive, the wholesale store is actually going to fetch you a lot more money as compared to a Kirana store. But there's a limited window where you want to go visit the store when he or she is not busy doing business with their customers. So the idea is that for buckets of these stores, for all the stores, we will create these buckets of different revenue potentials. And you want to basically, the tool should be created in such a way that the highest revenue that you can get from difference. So you maximize revenue in such a way that you visit the bluer curves during the peaks and then map out the redder curves. So if you look at this slide once again, the who to when to what to where mapping. Now we have outlets with all of these curves which define their revenue potential. Salesman with a salesman cross outlet matrix which defines this salesman's ability to do these particular outlets selling those products. And you have days. And now we want to simultaneously create tours, assign them to salesman and assign them to days. And there are a number of other constraints that are real world constraints, which can be these particular stores have to be visited by these particular salesmen only. They have to be done on these particular days only. So two kinds of products cannot go together. So those are very client specific. Some of the real world problems that I would show. So actually we saw that salesman usually spend like 20% of their time on road, which can be improved a lot by better routing. This can be seen in this particular image. It's a in one locality, three people are going and selling the same product. So that is just if you do not have hard time windows, that is a reflection of that routing is not really good. That's different people are going and selling in the same area. So if you improve your routing, that can be directly improved. This is a very interesting insight that we got from some of our clients that now one store we have a, there's a common constraint that different products cannot be, cannot go together when you're going and selling like food cannot go with detergents. Okay. Now then it should end. So these are different tours for different products. So it's heuristically believed that if you go visit a store in the morning, you should not go visit him once again to sell another product because that person's revenue potential has reduced. Now he just made a sale. He or she or just made a sale and you're just trying to make another sale. So you want to space these visits out. You don't want multiple visits on a particular day. So this brings to the importance of optimizing this, optimizing the problems simultaneously that you're creating the routes and then you're scheduling them. So scheduling should be done in such a way that you do not increase the same day visits a lot. Now I get a little bit more quantitative to, for people who are in the routing community and everyone else was also interested in the same thing. What is the problem classification from optimization perspective? So it's a capacitated vehicle routing problem which is periodic in nature because the entire, the tours need to repeat. So the tours need to be optimized across time. There are multiple trips. So one salesman can do multiple trips. It's multi-day. So that's a scheduling element that the tours created need to be put on different day buckets also. Clustering is a very, very interesting constraint which messes up a lot of optimization. So when you are putting these tools on different days, you want those salesman tours to be close by. You want them to be close by because two days later or three days later you need to make deliveries to those outlets. And if they are spread out across the city, your delivery cost is going to go prohibitively high. So you want to create tours looking, planning ahead for the deliveries that would be made in the future. So you want clustering multi-product and heterogeneous fleets. You have the salesman can choose to walk or to drive or to take a different vehicle with a different speed. Complexity of the problem with just 60 outlets in the problem, the number of solutions that are possible go above the atoms in the known universe. And the number of the batches that we would be looking at would have seven to 10,000 outlets. So it really requires a smart optimization algorithm to actually give a solution in reasonable amount of time. I'll point this out later also that time is a resource that is really important in real-world optimization. Even we actually kept this as a KPI that we want to have a solution in 10 to 15 minutes because all of the data that goes into the optimization it's a very complex optimization problem at the end. The optimizer gave an answer after three hours. People are not happy with it. You want to change the weights. There are so many objective terms. It needs to be quick and you need to run multiple runs. You need to run multiple simulations. So optimization needs to be very, very fast. So for a batch of seven to 10,000, you need to have solution time as a very important KPI. So what was the solution approach looking at all of these factors of importance of need for speed, the problem being really hard and past and still generate very good solutions. So as it comes out, solving it simultaneously, routing with scheduling is very, very hard. Probably cannot be done with the current infrastructure available. We broke down the problem. The two approaches I'm going to talk about is one of the approach only here. This breaks down the problem in routing, aggregating tours and then scheduling. So since we are breaking down the problem in two parts, there are some approximations involved, but we added objective terms for the second part in the first part itself so that we get reasonable tours for a second step which optimizes and finds feasible answers for scheduling. So how we do it is that we have a routing engine with specialized heuristics that generates a bunch of tours, bunch of feasible tours. We have a scheduling engine which is a mixed integer program, which looks at all of these tours, where the bunch of other constraints and objectives and then puts them on schedules, put the tours to different days. The downside of this approach is, yes, it is not simultaneous. So there are approximations involved, but the upside is that you can get solutions in 10 to 15 minutes, and which is actually very helpful, even in a plan like permanent journey plan, which is actually very helpful because you have to run like 40, 50 simulations or batch to display value and visibility. Because again, this is, we are dealing with real people over here, optimizing, assigning stores to salesmen to visit. So there are a lot of other real world constraints which even though you attempt to model them, you would not be able to model qualitative factors like, a salesman, like it's just a business heuristic that these people have to go visit the wholesale store at 5 p.m. It is a fixed constraint. So it is a lot of trial and error still, but the idea is always to have a scalable fast solution to generate excellent solutions. The map visualization of several solutions, the picture I showed you before for overlap, the routing overlap for a particular product has almost been eliminated now, just because a math program would, can deal with constraints and it can be hard. You can always, an optimizer can guarantee you something like this. So we were able to generate almost zero overlap for routing. Even the double, the zero double visits at a store were eliminated. So this was a major, major, major improvement because for a manual scheduling approach, it is very hard for routing and assigning it on different days to ensure that there are no zero visits because there are limited number of days, limited number of salesmen and a lot of stores to visit. So one of the biggest improvements was that the revenue potential went really up because of minimizing zero double visits, just by minimizing zero double visits at a particular store. Some of the average improvements, this is across clients, distance was reduced by 40 to 50%. Transaction time was reduced, serviceability number of outlets for beats became realistic. Common thing that I saw in some of the clients that sometimes a salesman would be assigned 40 or 50 outlets and a realistic number of outlets, a salesman usually does is 20 or 30. So that is often a problem. Like they were assigned these outlets because of some business heuristic, but when it cannot be deployed on ground. So actually this particular, the optimization actually helped generate tours which were realistic to deploy on ground also. Given these constraints of number of outlets, it's a cut of it, but it says challenges involved. So challenges involved, the first challenge, I think which a lot of you would relate to also is on ground deployment and acceptance. Even though we tried a lot to model a lot of these complex real world objectives, on ground deployment is still hard because it is just a change. There is a big change involved on how people function and you can't just go the next day and tell them this is a new beat plan. You have been servicing these outlets on the past five years. Now you need to service these. It's a big change for any person. So how we mitigate that was that there are multiple iterations that we run to show that yeah, you change the weights. This is the as a scenario. You run multiple simulations with different weights, different combinations and show that there can actually be multiple gains if you follow the optimized answer. So multiple iterations of different scenarios. Then we added some special constraints like for people who are really, really, for sales managers who were adamant that this won't work on ground. We added, we gave a phased rollout. We froze some particular salesman tours, say froze like 50% of the tours and then optimized. Like that's a constrained optimization that 50% of this is okay. This all is frozen, which is your critical business item. Let's roll out the other part. Given this is frozen, then optimize the other part. Then that is optimized. Then we slowly relax the frozen constraints to get more and more on ground deployment. We made separate weight configurations for different geographies that one particular. So this is a multivariate objective optimization problem. So you can have, you can, depending on the weights, you can get a particular solution. You change the weights, you'll get the solution. So we bucketed it down to different templates that, okay, if you want clustering, this is your configuration with which you should run. If you want distance minimization, this is what with which you should run. No zero visits. There will always be a tradeoff between one solution to another. And one way of showing that the optimization is actually working, it was to plot the solutions, give them visibility in terms of, if you change the weights, the optimization is changing. This part is always their noisy data in poor address sets. Actually, I can show you. These are two, these are batches. They're supposed to be one city addresses only. So there were outliers both in inter, at an inter city level. For addresses, the image on the left is all the addresses are on in Mysore, but a small subset of the addresses are also in New Delhi, which is clearly those are wrong entries. Their intra city outliers also, usually sales speed data is highly clustered, like there would be 100 outlets in 300 meters. But whenever you see one outlet, like 100 kilometers away from the city or 50 kilometers away from the city, that's also an outlier. So address data, the noisy data, salesman historical data can also be noisy. Some technical challenges were scaling up the mixed integer program. For those of you who are in the optimization industry, mixed integer programs can be really unreliable. If you give it more scale, it's going to blow up. It's not going to give any feasible solution. And time was very important for us. So we spent a lot of time to actually make the program reliable in terms added constraints, added cuts to make it robust to giving solutions. Horizontal scalability of the product to different multiple use cases. So when we started with optimizing sales speeds, our constraint set was this. Soon we realized that as this was working, the constraint set almost became four times that people said, okay, this is working like, let's add this also. Okay, let's add time windows to this. So when initial design begins, always try to ensure that your product is going to be scalable and generic. It should not be that you make a very, very specialized product which nails traveling salesman problem for time windows. You can get excellent solutions but it cannot solve anything else. So being generic across different use cases is very important. Constraints change, use cases change, but the optimization should be still reliable and robust. And need for speed and optimization. That is very, very critical. Something that a lot of people from academia often ignore the importance of this. You can't run a plan for 24 or 48 hours and come the next day and look at the solution and say, okay, I will change this wait and then run again. People are waiting for you. Deliveries need to be made. Things need to be rolled out. Plans need to get really quick and you need to generate, you need to demonstrate value also. So they need to be fast and they need to be fast in terms of changing parameters to run multiple scenarios. The, it's cut of it. It says conclusions. One of the most important conclusion is appreciate the human element when you are writing optimization solutions for the real world. Try to understand like what do, why do people do and what do they do? So and try to get that learning using some machine learning model into or anything can be heuristics or machine learning model or business intelligence. Get them into the optimization because not only that will get it accepted on ground. The other thing is that a lot of times those people have a lot of important things to say. Like the maximization of revenue potential. Like getting this insight would have been hard for us just making that optimization program in the office. So these are the real objectives that you can actually add and enrich the literature also. Enrich the, because as people in the industry you have access to real world use cases. The other thing is that build fast like which everyone says that but build with customers, iterate more, give them a solution, get it back, tweak it a bit. So if you build with customers, I've seen that the learning and the speed of product development has been really, really fast. Visibility is very important. So we made a, so initially we were giving optimization solutions to our clients and it wasn't, they were not, they did not have a lot of clarity why this is happening and why this is good because this is a complex optimization problem. People won't be able to get a direct insight into, okay you assigned this person to do this order at 5 p.m. But why is that? I don't understand the reason for it. So in this particular case we generated different configurations as I said and a lot of people to have a flavor of different configurations and that generated intuition that, okay I see that if you are, if you want really, really clustered orders, if you want really, really clustered tools, you cannot, you will have multiple visits on a particular day. Like if you want deliveries three days later to just go to one locality for your salesman, different salesmen need to go visit that same locality only. Then so your double visits will go up but so there is a trade off always in multivariate optimization. So visibility helps you, helps people or the different stakeholders to appreciate that trade off. And speed matters. Fast, real good solutions are important. Thank you. Questions please. Very good, thank you. Quick question, are you using solvers or metaheuristics? So we use a combination. So a lot of this, a lot of the IP is in-house developed. So the routing part is uses a combination of metaheuristics and we use a commercial solver also for the integer programming, for the mixed integer part. We use, yeah, we use Siplex and Gorobi.