supplyseer: Computational Supply Chain with Python

Supplyseer bridges the gap between theoretical supply chain analytics and practical implementation by providing a pythonic interface to advanced mathematical concepts. This talk will walk through the library's core components and demonstrate how they solve real-world supply chain challenges.

Outline:

  1. Introduction to Modern Supply Chain Analytics
  • The need for sophisticated analytics in today's complex supply chains
  • Why traditional methods fall short
  • The role of probabilistic modeling and topological analysis
  1. Core Mathematical Foundations
  • Time series embedding techniques using Takens' theorem
  • Stochastic process modeling for demand forecasting
  • Bayesian approaches to Economic Order Quantity (EOQ)
  • Point process modeling with Hawkes processes
  • Network analysis for supply chain risk assessment
  1. Library Architecture and Design Philosophy
  • Object-oriented design for supply chain analytics
  • Integration of multiple analytical approaches
  • Extensible architecture for custom analytics
  • Performance considerations and optimizations
  1. Key Features Deep Dive a) Demand Forecasting Module
    • Stochastic demand process simulation
    • Time-delay embedding for pattern recognition
    • Mixture density networks for uncertainty quantification

b) Risk Analysis Tools

  • Geopolitical risk assessment
  • Supply chain network visualization
  • Real-time monitoring and alerting
  • Trade restriction impact analysis

c) Inventory Optimization

  • Bayesian EOQ implementation
  • Multi-echelon inventory optimization
  • Stockout probability calculation
  • Vector field analysis for inventory dynamics
  1. Practical Applications
  • Route optimization with geopolitical risk consideration
  • You and your suppliers play cooperative games: game-theoretic Supply Chain
  • Supply Chain Digital Twins
  • Real-time risk monitoring and mitigation
  1. Integration with Data Science Ecosystem
  • Compatibility with pandas and polars
  • Integration with scikit-learn pipeline
  • Visualization with matplotlib and seaborn
  • Performance optimization with numpy
  1. Future Directions
  • Planned features and enhancements
  • Community contribution opportunities
  • Integration with other supply chain tools
  • Research directions in supply chain analytics
  1. Interactive Demonstrations
  • Live coding examples
  • Real-world data analysis
  • Visualization of supply chain dynamics
  • Risk assessment workflows

The talk will include code examples and practical demonstrations, showing how to:

  • Implement stochastic demand forecasting
  • Analyze supply chain risks using network analysis
  • Optimize inventory levels using Bayesian methods
  • Visualize supply chain dynamics using vector fields
  • Monitor and assess geopolitical risks

Target Audience: This talk is aimed at data scientists, supply chain analysts, and Python developers interested in applying advanced analytics to supply chain problems. Attendees should have intermediate Python knowledge and basic familiarity with data science libraries like pandas and numpy.

Prerequisites:

  • Python programming experience
  • Basic understanding of supply chain concepts
  • Familiarity with pandas and numpy
  • Basic knowledge of probability and statistics

Takeaways: Attendees will learn:

  • How to implement advanced supply chain analytics in Python
  • Practical applications of mathematical concepts in supply chain
  • Best practices for supply chain data analysis
  • Techniques for visualizing and monitoring supply chain dynamics
  • Methods for quantifying and managing supply chain risks

All code examples and demonstrations will be available in a GitHub repository, allowing attendees to experiment with the concepts presented and apply them to their own supply chain challenges.​​​​​​​​​​​​​​​​

This session took place in track Machine Learning & Deep Learning & Statistics and was classified suitable for intermediate domain / intermediate python by the speaker.

Transcript (auto)

Auto-generated from the recording utilizing Open-Source AI. Speaker labels (Speaker 1, Speaker 2) reflect diarization, not identity. Timestamps refer to the recording.

Speaker 1 [00:07]

all right thank you welcome to this tutorial for supplies here I will will make it interactive so I'll show you how to install it but let's do the classical you know ask a few questions but before that I mean let me introduce myself who am I I'm Yakko Rostami I am a machine learning engineer one of the words or if if not the world's largest fast fashion retailer. I don't mention them because I'm not here under representation. I'm here as an independent. My background is in statistics. I study statistics and probability theory in Uppsala University in Sweden. So I arrived yesterday from Stockholm to Germany. But the most important thing I would say for this is I've got about 12 years in supply chain and logistics. I have about six years operational, six years analytical. I used to work as a data scientist at one of the largest, if not the largest, German fast-moving consumer goods. Met some old colleagues earlier. I'm also a creator of Expectation. This is a hypothesis testing library that uses game theoretic approaches for statistics. If you want to try it out, there is a QR code, but it's not relevant for this tutorial. To my question, who here has a background in supply chain and logistics? Who, all right, all right, quite a few. Who is working actively within that field? All right. How many data scientists in that field? Or engineer, machine learning engineer, or analyst, doesn't matter. All right, all right, quite a few, quite a few. Who is a supply chain analyst with no technical background or a mathematical background? Good, that's not the intended audience, good, good. All right, first an introduction to modern supply chain analytics. Two things I want to point out is work in a complex world, extremely complex world. The complexities arise from economic effects, it arises from political effects, we see the most recent one is the tariffs from the Trump administration in the US. Before that, I don't know how many of you remember, but the semiconductor shortage. in Sweden there was a waiting line for about six to two years waiting for your EV car like impossible I'm gonna buy a Volkswagen and a Volvo I'm not buying a hypercar these things arise not because we want them to but there are like there's something else is happening right politically economically it It creates a complex world. What else arises in this phenomenon is uncertainty. So uncertainty in terms of, can I trust my lead time? Can I trust that the delivery will actually be on time? Can I trust that the customers will still want the same product? There are a few tools I've mentioned here. We will go through these ones. I mention them here as small bullet points, because I want you to have that in mind. topological data analysis You will ask questions probably Dynamical systems networks for uncertainty. We have probabilistic modeling simulation risk assessment why I mentioned these ones is are because of the module or the library itself has Probably some unique approaches to supply chain For instance one thing we will look through before before this is that I want you to visualize when you work with something in this tutorial is you're actually working on the global map right there is a shipment coming from China or the US or South America it has to pass through some canal Suez Canal or somewhere else and you need to know about if there will be delays. You need to know about the, I don't know, the demand that will occur with these delays in mind. You probably want to know that, okay, my shipment is stuck in the Suez Canal. What can I do, right? What are the news? You don't speak Hebrew, you don't speak Arabic, you want to do something, right? Now I'll open SupplySphere, if you go to... Oh, sorry. I don't know how many people see that link. Do you see that link by the way? Is it readable? Yeah? If you go to that link, github.com, supplysphere-ai slash supplies here you'll come to this page for installing the library pip install this version so I'm gonna wait for like one minute or if you have does anyone have questions by the way how to how to pip install no let's wait for like one minute. I cannot actually see my screen now. Let's do it like this. The link? Sorry. Anyone else that needs the link? No? All right. Let's wait for a few more seconds. By the way, does anyone have issues installing it? Nobody. It's a classical thing, right? You try to install something, it doesn't work. Just a reminder, also please install the requirements if you already have a virtual environment or a conda environment, otherwise just run pip install dash r requirements dot text. installs the requirements for you. I mean I can even, let's do it like this, let's do it like clear, desktop, pip install, I'm not even in that one, all right nothing is here I'll try to move over my terminal here. Get clone. I'm going to clone it instead. And then I'm going to run pip install requirements, pip, let's see this applies, alright, pip install.rrequirements.txt, I don't even have Python, all right, never mind, let me just, let me bring up my Visual Studio code instead. I'm going to immediately jump into, by the way, does everyone have it? Everyone? All right. I'm going to jump into this one immediately. I can't even see anything. We're going to start by, is it okay if I stand like this? We're going to start by simulating demand, any demand. We're going to start with the most basic thing. You're going to simulate demand based on absolutely no assumptions. You're just going to assume it has some key features and we're going to write them down. But can everybody open this demand notebook? It is found under Tutorials, in Supplies here, open it, or no, sorry, Tutorials, over there. Let me do it like this, Tutorials, Demand Simulation, open it. We open Demand Notebook, yes, bigger, thank you for pointing it out. All right, this is the folder structure. You should see these things. If you have not opened it, interrupt me, please, but I'm going to click it like this. going to simulate demand based on a stochastic process. We're going to apply it to how to simulate demand. It could be any product, I don't know, does anyone have something in mind? Something, I don't know, fruits, bananas, clothes, it could be, I don't know, pizza. And this is the equation governing our simulation process. It's called a geometric Brownian motion, it's taken from stochastic finance or what we call financial calculus, but we're going to apply it to demand. The first thing here we're going to look at is s is a function of time, so it's a demand at time t, that only means that we expect to sell 100 at this time. Mu is a drift rate, eta Eta is a decay rate so our process has to decay somehow either demand decays or it increases we're just gonna say okay decays. Sigma is the volatility so you don't have constant demand you're sometimes your demand or your sales actually let's skip demand for now let's think of sales your sales is not a constant you don't always sell 100 or 50 it's varying it's volatile. W out of is a function of T, Savino process, you think of this as a normal white noise, normal distribution, think of it like that. We don't need to go into the theory behind it. And the key features is for us are we're gonna assume not natural market decay, that people's interest for your or people's demand for your product decays over time, that the market is volatile, it's varying, right? We're gonna assume trend and drift component meaning there is either a positive trend or a negative trend and we're going to simulate multiple paths we're not saying there is only one path we're going to say there is not only one universe we believe in the multiverse so we're going to generate multiple universes and see the average path of all these statistical universes and that's going to give us a look at it so what we do is we import this module called StochasticDemandProcess and DemandSimConfig. Alright, it's done for me. Number two, we're going to configure our simulation parameters. Feel free to do whatever, to put in whatever arguments you want, think of something you can relate to. So the initial demand, that's the starting point, that's our baseline demand before any change will occur. We have a drift parameter mu, represents the trend component, 5% expected trend rate, and you You can also set it to negative. We have volatility, volatility parameter sigma represents the standard deviation, 10% volatility in demand changes and cannot be negative. We have a decay rate of demand over time, a 5% decay rate for 0.05, you can think of it as a seasonal or a declining product, and the time horizon. So skipping the theory, I'm just going to say we're working in continuous time. So we can just say you're going to simulate all the possible paths that your product or the demand could take during a year. So time horizon one year, and how many simulations you want to generate. I'm going to keep it like this. Number of steps, number of time steps to divide the simulation into. So that means we take time horizon, one divided by 365 minus one. That's our horizon. Let's run that one. We got that. Three, we're going to run the base simulation. We're going to instantiate the process, and we're going to run the basic simulation. You need to instantiate this based on your config above. And then we'll run it quick. good. So this is our final distribution. But numbers or visuals say much more than numbers. We can also check the shape by the way, it should match the input of your simulations and the number of days in your time horizon. Running sim plus results gives us this beautiful graph. Now I have to stand a little bit over here. What you're seeing here on the x-axis is just time, but remember what I said, it's 1 over 365 minus 1 in my case, so it's continuous. And you're saying, you know what my initial demand is at this point, but I have some other parameters and some other components, what could be the possible path of my demand or the end path and what could I expect at the end of the year, for the full year. Well, if we're following this as a time series, we see how it evolves, but we see this mean trajectory just declining. Some of the paths are increasing, some are decreasing, but on average we're landing over here. And now we have a histogram on the long side, it's pivoted, and this histogram just gives you the distribution of your simulated demand. So now when you have this one you can say okay on average my demand will be about this plus minus some range over here. You don't need to care about what it is at time T here or time T here, you're probably just interested in the final one. And after With that you can do your own analysis, you can draw your own conclusions. But to free you from making your own conclusions, I'm going to continue. And we're going to get the quantile paths. If we say where is 75% of the upper paths and 75% of the lower paths? What do they look like? I don't care about between, I want to know, you know, some summary statistics. I can execute this one. And those are the paths. You can see we're with 95% probability, what the lower bound will be, or what the lower bound is actually, because we just simulated it, what the 90% upper bound is, the 90% probability, or 90% of your generated simulations, and on average you will be here. But this is the range. So if your boss comes and says, you know what, I believe Trump's tariffs will affect us, then your simulations show that, you know what, it will affect us, and let's assume we have considered tariffs here, let's just assume it, then with 90% probability it will not be below this one, this line here. So the lowest demand we could expect is, I don't know, about 46,000. But it will definitely be decreasing. If you want to fill the area between, this is just another method of showing the distributions between the upper one, so the 90% upper and the 90% lower. We'll see it as well. It will be much clearer. We can also compute some descriptive statistics. The standard deviation of the 90% interval is 40,882. And the mean of the interval is 22,000. The third and fourth moments, which is kurtosis and skew, like is your distribution skewed? Does it have a flat tail? Does it have a large tail? The third and fourth moments of the 90% interval is for kurtosis, minus 0.35, and for skewness, minus 0.7, which could indicate a normal distribution. It could indicate, I'm not saying it is. We could also get the same thing for the smaller intervals. I don't know what's happening, I'm not seeing. We can do the same thing here as well. What this tells you is just that between this line here and this line, the area, what it looks like. Or from the previous case, between this line and that line. Any questions before we move on? No? Cool. And I want you to open, where is it? Still tutorials called economic order quantity, EOQ. I want you to open this one. What's going on? It's empty. Alright, what? So weird. Let's skip that one then. Let's go to something more visually appealing to you. Let's go to Supply Chain Digital Twin Network, Digital Twin Notebooks. For those of you who haven't been working with Digital Twins or Supply Chain, you can view it as a digital representation of your supply chain network or your logistics network. It is for us to, or the supply chain practitioner, to have a digital world of his physical supply chain. For instance, in this case, we will be looking at inventory between warehouses and stores. What this module will show you is we're approaching it both classically and with two new methods. One is based on, or not based on, but it's inspired by physics. We're going to use diffusion and potential field theories. We can also make a hybrid of them. I'm going to explain later why we do it or what the inspiration is. Let's execute this first one. We're then importing supply chain network, supply chain node, and as mentioned here we're going to create a multi echelon, or multi echelon sorry, supply chain network with warehouses and stores. So the structure of our network will show us warehouses, the upper echelon, stores, lower echelon, and we'll have some parameters for this multi echelon network. In this case, I'm going to assume we have two warehouses, warehouse A and warehouse B. And stores, we're going to have 15 stores ranging from, yeah, 1 to 15. I don't care about the numbers as of now or the names of them. We're going to have 15 stores and two warehouses. We're going to simulate for one year. You can start from which date you want. I'm starting from 2023. We're going to also start preparing some data, because as with everything, nobody's giving you a free meal, so data preparation is crucial. But here are the things we're going to do in this. We're going to initiate stock levels, demand forecast, historical sales data, and some operating parameters. Those are for the nodes, and the nodes will be warehouses and stores. Those are the nodes. For edge data, we're going to define flow capacities, how much flow can go between a warehouse and a store. We're going to look at some different effects, which you will see clearly from the visuals. The first thing we start with is we instantiate them as dictionaries. And then for warehouse in warehouses, so for each warehouse in warehouses, we're just going to state that the forecasted demand is Poisson distributed. A Poisson distribution gives us, what is it, it's truncated and it's discrete, meaning the values are 1, 2, 3, 4, 5, 6 and so on. And they are not negative. It's going to be of size N, and we define N as 365. And The input data for the warehouse, we're just going to assume stock level, 1000 multiplied by N. Forecasted demand will be the forecasted demand of this one. Actual sales, very simple, forecasted demand minus one. We're going to have a reorder point, and we're going to have a target stock, and we're going to assume it takes two days to receive new stock. So lead time, two days. We're going to do similar stuff for the stores. Now, we don't have warehouse C, only A and B, so let's execute this. Execute it. All right, since it's too large for me to see the visual, let's look at the visual first. Let's do this, network, simulate flow. Now, we're using the classical policy, which means as soon as you expect the inventory to fall below some level, you're going to reorder. Is it even visible from here? All right. The first thing we're going to look at is the aggregated, the system-wide demand and sales from this first subplot. From the second subplot here, stock levels over time for the warehouses, which means we started with 365 days, now we have simulated what could happen in our supply chain. For warehouse A, we expect it to decrease faster than warehouse B, but then there is a reorder point here. Somebody is reordering and filling, so we probably ordered somewhere here and it's refilled over here. And it's decreasing again and then increasing. Same thing for warehouse B&A. If we look at stores, a completely different behavior. It almost looks chaotic. The dashed red lines, the vertical ones, are stock outs. So we haven't even done anything in our physical world. we just simulated what could happen with our digital supply chain twin. All of these red dashed lines are stockouts. Now, we can also look at the stock levels density. Is warehouse A different from warehouse B? Probably not, right? So it's not on warehouse level probably, probably on store level or something else. The interpretation of this is for projected stock mode, which is traditional inventory management, we have a reorder point based system fixed order quantities if it falls below two pieces or 100 pieces please reorder we have standard lead times the expected behavior under this is regular ordering patterns which you saw from the warehouse there's a buffer stock maintenance we have potential bullwhip effects standard performance metrics standard performance metrics let's see No, we haven't defined it, we haven't printed it yet. This is under the classical policy, which I would say the majority of stores or warehouses uses. Those with a little bit more advanced methods, they probably use something else, but in this library, you could use a physics-based approach. So we're now going to activate diffusion. The expected behavior under diffusion, dynamic inventory redistribution, responsive to local demands, so if one store needs something, immediately do something. The flow patterns should be smooth, so that means we should continually, what do you call it, allocate and replenish stores. We should not do it like we did in the classical policy where we wait and then there is a peak. We wait, and there is a peak. It should be very smooth. Now we're doing diffusion mode. If you want to see performance metric, set this to true, but it will print a lot of things. So, this is for the physics-inspired approach. We see a metric here called kinetic energy, called system energy over time. For those of you who are familiar with physics, energy cannot be negative, but in this sense it makes, or in this case it makes sense. It's easy to, we can look at it if we have time, but in the module, while we view it as a negative, and the more negative it gets, the better flow between warehouses and stores. Because the system is, I'm not going to say learning, but in quote, learning. So the lower the values, the better. That means there are no bottlenecks in this system. The flow between warehouses and stores is very good. There are no built-up energy or built-up stock waiting somewhere, like reserved energy. It's all negative. Now, when we look at stock levels over time for the warehouses...

Speaker 2 [30:24]

Can you explain a little bit more about the kinetic energy at the very beginning? So from the very beginning it starts very small, like almost zero kinetic energy, then as we go like 300 days from the start, we see massive jumps from minus 50,000 back to zero and on and on. What's the meaning of this?

Speaker 1 [30:49]

You mean the meaning of the numbers, or you mean the variations?

Speaker 2 [30:53]

not really the meaning of numbers, but like what's actually happening. Yeah, okay, okay.

Speaker 1 [30:57]

Yeah, okay, so let's see if we can jump into it immediately. Did I jump? let's just make sure it's that one I think it's this one, 527 yeah, ok yes, 527 first of all Let's look at this part here, the inventory difference from stock, so from the warehouse to the store. And we're saying the diffusion flow rate, the diffusion coefficients, defined over here. You can define this as anything, it's just set at 0.1. And the inventory difference. What this shows you is, no stock is built up, it's not sitting there. It's moving constantly, right? It's moving constantly. Some variations increase, meaning, okay, there is no optimal solution currently for this time here, which means, okay, I cannot optimally allocate very good, so it builds up stock. This is very, this is classical to when there is a bank holiday and suddenly your third party truck delivery express says, you know what, we cannot deliver on that day. There's a similar, okay, that means they cannot optimally deliver to me, which means it builds up energy, meaning energy is sitting in the warehouse. It's not moving anywhere, right? A warehouse never wants to have, a warehouse and a store never wants to have inventory. You always want to sell what you have, right? You don't want to, or economically, you never want to have inventory building up or stocks building up. You always want to move it somewhere for selling. This is the representation of that.

Speaker 2 [33:27]

So that means basically whenever we see the energy drop down, this was the delivery to the stores and when the plot line jumps up again, it was the warehouse replenished basically.

Speaker 1 [33:42]

You could use that yeah, yeah, and if let's say like this if it increases again over here That means okay this policy Has a hard time around these days to allocate

Speaker 2 [33:57]

Why is it like the trend goes down?

Speaker 1 [34:00]

because I have set energy as negative. If it's positive, it will increase. That means, in this sense, I set it as negative because I say, I don't want to have any energy still in the warehouse. It should always be moving to the stores. Do not store energy, please, because built-up stock or inventory is basically a representation of stored energy. If you have 10 pallets of bananas in your warehouse, it shouldn't be there because the warehouse cannot sell. It should be in the store. right and you don't want to wait until the store orders you want to be doing this very smoothly like I'm gonna give you five this time for this time you're not gonna wait and say oh we order here's ten that is the meaning so when it drops them you can see this as okay there is no left there's no energy left in the warehouse, meaning it distributes properly. Let's move on. So then when we have the diffusion policy for the warehouses, the stock levels are different, there are more, what do you call it, more replenishment to the warehouse. So let's make something clear, we never spoke about logistics, we never spoke about the cost of logistics, we're now just talking about warehouses and stores this if we spoke with the logistics department they would say you know what I cannot afford having people in the warehouse receiving orders this frequently but they probably could for the classical policy but when we look at stores it looks very strange it looks very strange we basically never go below zero, so there's no stock out, no red lines, no red dash line sorry, but we have very weird peaks, so, and we haven't even said anything about promotion, this is just simulation, we're not simulating any promotions in the stores for this supply chain. These peaks, if that was reality, if you're governing a, let's say a Lidl store suddenly you receive you can only sell about 60 bananas per day maximum 80 suddenly you receive 100 bananas you would say what should I do with 100 bananas or 120 bananas this takes me four or five days to sell and by that time the fruit the bananas have come back so there is a third policy in this case. We'll go into that one as well. But to finalize this part is now warehouse B behaves differently from warehouse A. From the classical policy they were almost identical, so now they're starting to behaving differently under this policy. Same thing for the stores. You see that many of them behave differently. There is another mode called hybrid, let's go to the expected behavior under hybrid. So we're combining traditional and physics-based approach. We have a hierarchical control structure, we have modified flow rates, balanced dynamics, and that means we should expect a stable warehouse operation, flexible replenishment for the stores, reduced variations from what you saw from earlier, and optimal performance balance. So let's have a look at it. System energy still decreasing, similar to the pure diffusion policy. System one, high demand and sales. Stock levels over time looks quite similar to the pure diffusion approach. Stock levels over time with red dashed lines for stock outs, no stock outs, but some stores have peaks, but none of them are above 100. So this one is a bit tighter with less frequent peaks than the pure diffusion approach. Remember, this is still a simulation. So if you find this, oh, it looks very weird, this is just simulation. It's not even based on real sales. Warehouses still act differently or behave differently and stores as well. But there's a main difference here. The stock level now is between, let's say 30 and maximum 70 or 80. So let's say 30 and maximum 80, or somewhere here. For the diffusion policy, this one stretches far, so there is a small tail here, but it also goes from 20. It's very wide and for demand, that means that's bad, because suddenly you cannot give Give me a tight confidence about what we will sell. You're not saying we could sell anything from this range to that range. While for the classical policy, you could actually have a stock out. You see it's covering zero and negative values. And it also goes above 80. So when we combine both the classical and the diffusion approach, it tends to behave a bit better. So there are no stock outs. are some peaks but not as aggressive as the pure diffusion approach. You can also look at some metrics per store or per warehouse. You can get get filtered metrics, you can see the forecasted demand, actual sales, unused potential, total stock, so on. Since we have 20 minutes left, or like 50 minutes left, I'm going to try to catch the other ones as well. But what we can do, we can visualize this network. What we have done so far, we just visualized simulations. What could happen? What will happen? What does it look like? But this is the supply chain digital twin we actually worked with. This is it. Now you can see the potential flows from one warehouse to one store. Which store has the best flow? That store should probably also be a flagship store. If you think of Lidl, if you think of Aldi, they have small stores and large stores. They have stores in small gallerias, malls. They're not standard stores, so they shouldn't have better flow or they shouldn't have as good as flow as these large stores sitting in, I don't know, somewhere in Darmstadt or somewhere else. For instance, we can look at, I don't know, warehouse B to store 10. It has a high max flow, so the thicker the line, the edge, better flow. Or warehouse A, the flow to store 8, 52, still good, but the potential is 8%, meaning it's probably a small store. That's how it's defined. It's probably a small store sitting somewhere. The potential is very low. I cannot send so much from this warehouse. That is the digital twin notebook. Any questions or should we move on? No, but it can be, but in this case it's not, they're just overlapping, right? I know, but for example, there's store 10 and it cannot be receive stocks from warehouse A and B. That's what I'm... That's by definition. We defined it like that. But we can do it. We just change and say, you know what? Warehouse A can also send to store 10. Very easy. We just add it. And then it can do it. I just did it for more visuals to make it easily distinguished. Yeah. How about we do, this one is probably more, let's start with this one and we can finish with the geopolitical risk module. So if you open game theory and co-op game, we'll start with that one. I don't even see anything, or maybe I can look at it from this perspective, let's see. I'm trying to open from this side. All right. There is another module or another tutorial, and this one is not related to demand forecasting. It's more about, if you think about this example where you're working for a company and you're ordering from China, from Vietnam, from the US, from Africa, and you're afraid of the tariffs, the trade war, you're afraid of the conflict in the Middle East, and the potential conflict in Taiwan, and you want to simulate without speaking to your suppliers or whatever, somebody that is supplying something to you. You want to see who has the most power to disrupt this balance. Maybe you're working with four suppliers from China, one of them is very large, but do they have enough power to ruin their relationship with you and the other suppliers on the market? Could they just pull something from the market and suddenly nobody can supply it with anything? So we're going to use game theoretic approaches for that. We're going to look at the power structure. So we're going to look at it from our perspective as a user or as a company, and we're going We're going to look at partnerships, coalitions and their value, we're going to look at Shapley values power structure, we're going to look at Nash equilibrium, I'm going to tell you how we could interpret these things. And a simulation of cooperative evolution, so let me just import these things. So I would say cooperative games is probably very common in supply chain and logistics. Very common. No module in co-op game, oh, I need to, Dropbox, desktop supplies here, okay, let's see, no Oh, that was so fun. What's going on? Oh. My button, yeah, yeah, my button, thank you. Where is it, though? Game theory, let's look. I don't hear that well from it. Game theory, co-op game, all right. Thank you for correcting me. Okay, imported. We're going to create the actors in our game, right? In our supply chain structure. The first one will be a supplier. We're going to say the capacity of the supplier is 100, the production cost is 10, the cost of holding goods, 2, the setup cost is 1,000, and they have a market power of 0.7, so 70% of the market share is theirs. The next supplier here in our game is supplier 2, they have different parameters but they have a market power of 0.5, 50%. We also have player 3 which is a manufacturer, has a market power of 0.6. manufacturer of market power 0.40%. We're going to instantiate the game with the supplier 1, supplier 2, manufacturer 1 and manufacturer 2, but it could be anything from your perspective. It could be your parents-in-law, you know, your father-in-law, your mother-in-law, it could be, I don't know, it could be if you're playing football, as long as there is a structure to the relationships. So let's initialize this. Alright, before we jump into this, let's look at the partitions. This tells us if this power structure is dynamic, what the size is of the coalition, the coalition value. We see that Supplier 1 has a higher power structure than Supplier 2, while Manufacturer 1 has a higher power structure than Manufacturer 2. Let's do this one and then jump to the analysis or the explanation of it. We have a total Shapley value of 7 and a synergy value of 53. If we have too high, don't quote me on this one, if it's too high, that indicates a power structure which is instable. Let's look what the definitions are. The Shapley values distribution. It represents a fair distribution of the total coalition value based on each player's marginal contributions. So there is no asymmetric power structure. That means so far nobody's larger than the other in terms of market power, in terms of costs. Nobody can control the power dynamics more than the other. Let's analyze their market power by coalition, okay. The suppliers have a total power structure of 0.6, the manufacturers an average power structure of 0.5. But when we look at coalitions, that means one supplier can grab both manufacturers and say, you know what, do not deal with supplier two. If that is the case, we would see two coalitions. In this case, we only see one, meaning all four have a symmetric power structure, meaning the coalition is actually, it's fair, it's fair, nobody is controlling the other or doing some disruptions or manipulations. Let's see what could happen if we start simulating the coalition evolution. Evolution results. These are the results. Let's plot them. And this is how it looks like. And what it means, where is the text? Did I remove the text, by the way? So strange, the market power mean. All right. The thing is this. It has some local variations, but overall it's stable. around this value. I think I removed something, to be honest. Number of stable partitions found one, which is our coalition. If we move backwards, let's do it like this, and let's start from here. Having partners with low-cost setups tells us that a grand coalition, meaning one large coalition between all of them, gives the highest total value possible, benefiting from full synergies and optimal capacity usage overall. We can split the coalition, like I said, between suppliers, between manufacturers. If we do so, all right, this one does not do so. We can go back and we can define that one has a higher power structure than the other ones. But this is what it looks like in a simple matrix. Supplier 1 with manufacturer 1 have 21 market power structure. This one has about 8.4 power structure. Let's look at the graph of the coalitions like this. Supplier 1 cooperates well with Manufacturer 1. Supplier 2 with Manufacturer 2. And this is the coalition values. So this coalition is probably weaker than that one. But overall, they're working well together. All right, we're going to test how stable they are as well. As I mentioned, if you're working with suppliers in China or in South Africa or in the Middle East, you want to know something about the power of their market shares, the dynamics. This one tells us the partition stability is false. I'm not going to go deeper into it so we can have time for one more. Let's do it like this, let's make it asymmetric. Let's say that one of them actually have almost all the power. Let's do eight, let's call this one market power two, market power two, and market power, let's call this one one. Let's instantiate the game. Let's look at the partition analysis. As a large coalition, Supplier 1 has most of the power. We haven't started splitting them yet. So this should actually also give us a stable one. All right, the suppliers together have a high market power, the manufacturers low. Still a grand coalition. I think it's because of the costs. Let's do it like this. Let's reduce the cost of this one. Let's say it costs them two, but they have the most market power as well. Okay, now we have two different coalitions. one only has this manufacturer, M2. Let's look at why, perhaps. I don't know, maybe because, I don't know. Let's continue. There is only one manufacturer there and in this case we have two suppliers and one manufacturer. And this one shows a decrease in stability, meaning the market power structure is not stable. We did some adjustments. We said one supplier has low costs and high power. So we see that our stability trend is just decreasing, just decreasing. Number of stable partitions found finds three of them, because we have one which is, as As I mentioned, they have the most market power, they have less costs, let's skip this one. I think I designed this for some other combination, let's look at what they look like. the same. I think we even designed it like that. Okay, this should not give us the same values. Let's look. Yes, please. Yes. You mean in the beginning? Yeah. Here? Oh, sorry, capacity. Yeah, you're right, I didn't change the cost. Okay, let's say we have, I don't know, 500. Nice to point it out. I thought I reduced the costs. All right. Okay, high capacity, high market power structure, but not the cost. Let's reduce the production cost for this one. I just want to highlight one thing for you. Same thing again. It starts asymmetric, so it's not stable, decreasing, but then it starts to be stable. Now, this requires the practitioner who uses this, you have to know, you have to understand what you're working with. All right, let's start with the vertical coalition. Let's give this the last one. Both players have equal Shapley values, meaning the power structure, suggesting a balanced bargaining power, fair value distribution in their partnership in a vertical coalition. A Nash equilibrium analysis suggests that our configuration is stable. No player can benefit by changing coalitions, partnerships, and all of them are optimal for all players and potential improvements for none of them is valuable. So the improvements are zero. Which is not true for this coalition. If all of them are in one coalition, manufacturer two and manufacturer one can change the strategy in a coalition. Individually, supplier one has the highest payoff, and that's because we changed it. Meaning, if we now did this for real business, we would probably discuss between senior leadership like, hey, the supplier from our analysis shows that they have incentives to deviate from this supply chain market structure that we have created between the suppliers and the manufacturers, individually. In the coalition, manufacturer 1 and manufacturer 2 see a benefit from deviating from the coalition. Like if they're working with supplier 1 and supplier 2, there is a potential for them to improve it by doing something else. What did that one come from? Okay, this is from the graph. So in this graph, let's see. In this graph here, manufacturer one and supplier one have about 21 coalition values. Manufacturer two and supplier two have about eight. And when we look at it from another perspective and say, what is the value creation they provide over the other one? So we say supplier one, manufacturer one has this value, supplier two, manufacturer two, that value, those two together create about two and a half times more value than this supplier and that manufacturer together. That's what we get from this cooperative game module, the tutorial of it. Questions?

Speaker 3 [62:29]

maybe a quick question so is it also possible to add more parameters to this game like climatic conditions what would be the impact of can you say that

Speaker 1 [62:36]

Can you say that higher in here?

Speaker 3 [62:38]

like climatic conditions, can we also add more parameters to this game?

Speaker 1 [62:44]

No, but it's actually a good point to add, it's actually a good point, let's look at how it's defined, so Pydantic base model, nope, nope, but it could be added, it could be added. All right, now this, the last part I want to go through, this one is a little bit, I a little bit more interesting is, we're gonna do something different this time. We're gonna assume we have a shipment coming from somewhere, all right, and we are afraid of the Ukraine war, we are afraid of the Taiwan Sea conflict, so we're just practically gonna use an API called gTelt. gTelt gives you, I think, live news from all over the world. All over the world. I think you need these two libraries, by the way, if it doesn't work. So just do it like this. Write this command if it doesn't work. Quick conflict scenario, we're gonna So these things are predefined. It's still as I'm right here experimental There's a risk module we're gonna create a conflict scenario And it says added event Ukraine Russia Taiwan Strait Red Sea shipping crisis, right? I have this so when I create this was I think a year ago, I think think or maybe six seven months ago I had these these things were actual then like they were in the news then at least in Sweden we've added that to our risk module right now we're gonna do some new stuff we're gonna analyze commodity risk what type of thing semiconductors right and we want to generate conflict impact report and it tells us the semiconductor risk level is high and the conflicts affected by conflicts Taiwan straight tensions severity level high affected regions Taiwan South China Sea no sanctions of course no sanctions because what is it TSMC is supplying us and Europe on the conflict Ukraine Russia severity is critical lead time impact five times so if you if you expected to receive something in 10 days expect 50 days the cost impact it will bear on some cost to have is about seven times conflict Taiwan straight tensions severity high impact of on lead time is 95 percent cost impact hundred ten percent. And the same thing for the shipping crisis, risky shipping crisis. Now we're going to calculate the root risk. We're going to say origin Shanghai, destination Rotterdam, and it goes through Singapore, the Suez Canal, and the Mediterranean. What it gives us is the risk level is low, there are no impacted segments, no cost factor, no delay factor, no extra risk. We can do our own stuff with it, where we just instantiate it empty, there should be nothing in it. So here are some conflict types we could choose, armed conflict, civil unrest, economic warfare, for the risk could be economic, political, regulatory, security, trade, the risk level from critical to severe, sanctions, this is for you to do your own, you can add sanction impact, which type of items, alternative sources, cost increase factor, lead time increase, Reliability decrease, you see the comments here, explains what it does. Now we're going to add our own conflict zones. I'm just going to add it again. Say Ukraine-Russia conflict. It's an armed conflict. The affected regions, Ukraine-Russia, Belarus. It's going to start from 24th of February 2022. The risk level is critical. There is a displaced population of, I don't know, wait. Yeah, 8 million. Strategic commodities, grain, metals, energy, fertilizers, and the sanctions. We define the sanctions with this class. Let's do it. Let's look at them. Affected regions, Russia, Belarus, Ukraine, what type of conflict? Armed conflict. This is how you print out what it is. impact technology industrial equipment grain luxury goods now if you have a gen ai solution you could combine them together which just extracts for you automatically let's add taiwan's tension we do the same thing but with taiwan added event ukraine russia conflict in ukraine with risk level critical and the other event for taiwan is with risk level high so now we're going to generate an impact report. You're going to imagine you're Sweden, you buy grains from Russia, Belarus and Ukraine before the conflict. Suddenly you don't know what to do because grains are under sanctions, but you need to provide alternative sources. At the same time, you need to know the impact on lead time and costs. Let's run that one. It just gives you the same answers as before, but this time we defined it manually for ourselves. But let's expand on that one. Let's say, okay, I know the cost impact, I know the lead time, I want to monitor something else. There's an API in the library, which connects to the GDELT. See if this works. What we're saying here is I want to monitor region risks, which is Sweden, the past seven days. I don't know, say another country, give me another country. Germany, let's say Germany, the past seven days. Supply disruption gives us one white and black farmers still bear, I don't know what it says, Trump was once seen as an asset. So it divides the news into specific parts. So when it's supply disruption, that's one news article. And geopolitical, there's one news article. Infrastructure, nothing. Trade restrictions, nothing. No disasters. Okay, let's look at geopolitical. These are actually actual news articles. Actual ones. I don't know them. probably know about the Guardian. There's a title. Trump was once seen as an asset to right-wing something, Israeli strike on school turned shelter, I don't know, and so on and so on. And the date. Now we're gonna use some other library to, you know, extend what we just did. I'm using Transformers, which is a Hugging Face library. I'm gonna import sentiment analysis. Let's see if it works. It doesn't work, of course. Always error. This still does not appear to have a file name. Use from tf.true totally smaller from those weights. Okay. Of course, it doesn't work. I hope. All right. So let's assume I just imported this. These are the results for some news that we had. First we're putting the titles here as a variable, origins as a variable. We're doing sentiment analysis. So we take the pipeline and it gives us the origin country, the title, and it also does sentiment analysis, right. Origin country, United States, titled Trump and the Sick Man of Europe, 98% positive. Israel, at the table with Jeremy Berkovitz, the face of American colonial, tell Israel News, almost 100% positive. So this is just for demonstration, right, I think I took like a basic, I didn't even choose model, right. But as I mentioned, if you have a Gen-I solution, easily, easily extend this to that solution. German prisoner loses cool over criticism of his stance on NATO. Nord Stream. 100% negative, almost, yeah. Biden, foreign policy, legacy. So this is old, by the way. Sweden sentences Quran-burning activist Rasmus Paludan to jail. Negative. But I think if we have an LLM here, it's probably extracting much better. I think I'm going to finish there. There are other tutorials and other modules and examples, but I'm going to finish there, at least partially. We have any questions? Yes. In the other scenario about the market power, how would you, in a real-life scenario, how would you derive, how would you get the input parameter of market power? Valid question. This is for the practitioner, right? This is for the practitioner either by what they know of their domain or either by analysis, data analysis. It is not intended to be a user, so the library is user-friendly friendly in that sense but it's not user friendly in the domain like we don't know which do me you work in so to answer that question it has to either come from the practitioner itself or by data analysis or some common knowledgeable parameter which we all know of yeah okay thanks thank you anything else

Speaker 3 [74:27]

I've got three questions online. The first one is, among cost related to replenishment, inventory level slash density outage frequency, what are the metrics taken into account used to judge which policy is better?

Speaker 1 [74:45]

Also, one thing which is completely up to the domain and the practitioner. Let me jump to that one. Because this is not about, let's see, digital twin. So I assume you're speaking about these visuals, right? If the use is true, you'll get some, like how the whole flow works and some metrics. But to tell you which the best is, this is just stock levels and how the system as a whole distributes from warehouse to store. So there must be something else relevant to the domain. For instance, if we're working for Lidl, you'll probably think of, oh, I don't want to throw that much fruit every day. That's probably one metric. for fast fashion H&M, Zalando you probably want to look at the stock like am I selling the same product the next collection or not so it's completely up to the domain

Speaker 3 [75:49]

And the second question, it seems to be a multi-object optimization problem. Can you comment on how to deal with it? How to select the best metric, a scalar combining all or a Pareto optimum?

Speaker 1 [76:03]

for which module is the question related to?

Speaker 3 [76:08]

I think these were like questions which were in the online. I'm not really sure. I suppose it was related to cooperative game.

Speaker 1 [76:17]

So, I can state we have an optimization module with basic implementations, so they're practically done already. But those are probably at most it's just classical optimization, linear optimization. If they ask about the co-op game, it is not optimization in the sense of, for instance, if you use Groby or if you use OR tools from Google for, I don't know, which other modules did we go through yeah probably those two it's probably one related to one of those two but I cannot answer that because I don't know what specifically they mean

Speaker 3 [76:54]

Okay. And the last question, how to test which policy works better in real world using statistical testing, A-B testing or which, especially when there are multiple objectives?

Speaker 1 [77:07]

Yeah, so that's a valid question, yeah, it's probably related to the previous question

Speaker 3 [77:07]

Yeah.

Speaker 1 [77:12]

as well. This is just a plot, this is a visual, it is completely reliant on what you're optimizing for, or optimizing for distribution between one inventory and another, and this is probably a good way to start, but as with everything else, it probably requires some post-validation, so that could mean, yes, an A-B test, it could mean, I don't know, some pilot project, could mean a regression model to define between two groups, could be anything. It's completely up to the domain, I would say. These things are just to start with. It doesn't tell you this is the best way to do it.

Speaker 3 [77:52]

yeah thank you all right are there like any on-site questions we still have got some time any burning questions no all right okay i think uh thank you so much uh echo for uh this amazing presentation especially on the geopolitical thing because it's a burning topic right now and it was also very much relatable as well so a big round of applause to thank you

Speaker 1 [78:18]

Thank you for your time.

Jako Rostami

About — in the speaker's own words

I am a Machine Learning Engineer at H&M Group, former Data Scientist at Lidl Sweden, as a professional I am designing Machine Learning services, extracting insights and arranging meaningful stories for my clients by conducting high-quality modeling, engineering, data mining and analytics.

I have a Bachelor degree in Statistics and Probability theory from Uppsala University of Sweden. Because I am a Statistician at core I have good experience with Data Sciencr, Python, R, time series modeling, simulations, machine learning algorithms, SQL, Excel, Spark and database technologies, as well as good communication skills.

You’ll find two comprehensive Python libraries I have open-sourced. One is based on an emerging modern statistical hypothesis testing framework using e-values and martingales based on game-theoretic statistics. The other is for computational Supply Chain and Logistics. The first one is called ’expectation’ and the second one is called ’supplyseer’ and you can find both on my GitHub.

Social card for talk: supplyseer: Computational Supply Chain with Python