To make our supply chains smarter, we can optimize its structure or how we control the processes of a given supply chain structure. For extremely simple supply chains, both of these goals can be achieved analytically. We can often use tools like linear programming solvers to optimize these control problems.
Realistic supply chains are way too complex for that approach though. They are also stochastic, meaning that they come with some level of randomness. Which means that all the nice standard methods that assume deterministic behavior must go out the window.
If we can simulate a realistic supply chain with a good level of fidelity, however, we can suddenly achieve wonderful things.
We can experiment, risk free. What happens if we remove a certain supplier? Change the simulation and get your (approximate) answer. All it takes is computation – so we can experiment at a fraction of the cost that real-life experiments would entail. We can use simulation to optimize both structure and control.
We can inspect the simulation as it runs, or after it has run, to gain new insights into the dynamics of our supply chain – such as fluctuations in inventory levels.
We can even simulate how a supply chain would behave before it even exists. Pretty valuable stuff!
Simulation tools
Wikipedia lists a wide range of proprietary and open source simulation software.
Possibly the most well known of the proprietary ones in the field of supply chain management is Anylogic. I haven’t used it and I don’t know how expensive it is. But it does seem to have powerful features for supply chain modeling and it comes with an open API, likely allowing you to easily build software around the software.
Simul8, another well-known proprietary simulation package, does state pricing on its website – from $1,999 to $19,995 for a perpetual license. If you are able to strategically leverage a good simulation tool, you’ll likely see tremendous ROIs from this kind of investment. But for the getting-your-feet-wet phase, it’s a bit rich.
Other than cash pains, a major potential drawback of relying on proprietary simulators is outlined in this excellent review of the field, namely that the models can be stored in binary formats that are not easily shared. This can hamper research and lock one in to a specific vendor.
However, as the review mentioned above shows, the proprietary simulators can be much faster. So if you need fast simulation of complex supply chains, you may have to accept those chains – so to say.
SimPy
SimPy is an open source, discrete-event simulation package implemented in the Python programming language. I am aware of three other similar packages. There’s SimX, which doesn’t seem very mature, and Ciw, which seems geared towards simulating customer queues and seems less flexible in terms of rapid development. And finally Salabim, which seems to be hibernating. So I’ll be using SimPy for this introduction.
This is the best video tutorial on SimPy I have been able to find, in case you want to dig in yourself.
SimPy uses processes that are defined by so-called generator functions. Such processes and can be used to model active supply chain elements like customers, factories, vehicles or AI controllers. “Shared resources” can be used to model congestion points like warehouse loading docks, containers, railway stations, or roads.
A minimalistic supply chain
Here’s a supply chain that only barely deserves to be called one:
We’re running a warehouse that stocks a single product. At irregular intervals, an order is generated from the market. We’ll use an exponential distribution with a rate of 5:
So an order is sent from ‘demand’ to our warehouse, and demand then waits for a random period of time. As you can see, most order delays are short, but a few can be very long.
(Note that we’re working with a relative time concept here, but feel free to think of 1 unit of time as 1 day.)
Each order is for between 1 and 5 units. We use a uniform distribution for the order size, so all values between 1 and 5 (inclusive) are equally likely.
Our inventory management uses a simple reorder-point scheme: whenever inventory drops below our reorder point, we order the difference between the present inventory and a set target point. We’ll set the re-order point to 30 and the target to 100, which is also the starting inventory.
When we order from the supplier, our order is shipped immediately and takes exactly two days to arrive. No randomness there – I wish all suppliers were like that, right?
Our inventory management policy is to not order when an order is underway from the supplier. Once the order has arrived, we are free to order from the supplier again.
This example is almost identical to the one explained here, because I found it to be nice and simple starting point. I implemented it somewhat differently, however. For example, the warehouse was implemented as a Container sub-type that keeps track of inventory, revenue etc. internally. By the way – if you are interested in seeing the code, let me know.
Let’s fire up this bad boy
Now that we have our awesome simulator, let’s give it a spin. First, how does our inventory evolve over time?
In this single instance – one run – we see that we get pretty close to running out a couple of times, but we managed to deliver all the orders. We can see how erratic the demand is. Sometimes when we order, demand is very high over the next two days it takes for supplies to arrive, and we end up with a relatively low inventory point after restocking. At other times, demand is low, and we end up with much higher inventory. Demand forecasting, anyone?
What if we repeat the simulation 100 times and look at the distribution of the inventory at each time?
In all these 100 simulations, we end up waiting until we reach the reorder point – hence the relatively stable line on at the beginning. After that, cumulating demand varies a lot across the simulations, because the delay between orders has a ‘long tail’ from the exponential distribution. We can see that on average we are carrying some level of inventory above what is necessary to serve demand.
What about turnover ratio? That is easy to calculate – we just divide total turnover by average inventory. Using a price of 1 (insert your favorite currency here), we find the turnover rate of a particular simulation to be 5.8. Again, we can run the simulation multiple times to analyze the uncertainty of this turnover rate. When we do that, we get the following histogram of turnover rates:
Thus, if we were contemplating building this supply chain, we could expect a turnover ratio roughly between 5 and 9. Good to know before we start hiring those expensive contractors!
It’s about as simple as you can imagine, but there you have it – a supply chain simulation using SimPy.
Reality check
If you have been paying attention – and you have been paying attention, right? – you’ll notice the paradox between the argument that simulations are great for realistic analysis/optimization of supply chains, and the unrealistically simple example that has been demonstrated. Don’t worry – this simplicity was only to illustrate the principles. What lies between that and reality are a set of simplifying assumptions.
As you may have heard, the devil is in those assumptions. What are some of the biggest assumptions we have been making that would absolutely need to be relaxed if we want to move closer to anything resembling a realistic supply chain simulation?
Obviously, no real supply chain has such a simple structure. We may need to add manufacturing entities, multiple suppliers, multiple warehouses, multiple demand sources, multiple products/SKUs, and so on. With any decent simulation software, we can do just that.
Second, most processes in real life are stochastic. The time from when we order until the order arrives from the supplier can vary. Traffic means stochastic delays between ship time and our customer holding the product in his or her hands. As we have seen, adding and controlling randomness in SimPy is pretty straight forward. If we have observations of, say, demand variation, we can model that with appropriate probability distributions and use those in our simulations.
There are other assumptions, but in general we can relax or get rid of them by making our simulations more complex. There is nothing stopping us from getting closer to reality through simulation if we are willing to put in the effort and invest in the necessary computational power and software development, alternatively software packages.
Conclusion
The ability to simulate supply chains delivers serious analytical and decision-making power. It allows you to calculate likely outcomes of changes to structures and policies in a near risk-free manner. You need an acute sense of the assumptions you’ll be making along the way – but we need that anyway to do a good job as supply chain optimizers. If you don’t have the “simulation weapon” in your arsenal already, I recommend that you look into expanding said arsenal.
Do you have experience simulating supply chains? Did I leave out some important aspect of this subject? Let me know in the comments or send me an email!
If you want to start leveraging simulation or other AI techniques for your supply chains, get in touch with me. I would love to help you.
Really nice, I enjoyed reading this. Want to get well versed with SimPy before I can use it as a tool and I would like to see the code if possible.
Regards,
Rohan
Thanks Rohan,
I’m afraid I don’t have the code handy but there are some nice SimpPy tutorials on Youtube, for example.
Regards,
Daniel