Happy new year

Happy New Year everyone! 2022 was my first full year of running my business, Data Driven Supply Chain LLC, after spending 15 years in the corporate world and military. I learned a tremendous amount. I met and worked with great people. I read a lot and wrote some.

I am grateful to have consulted for and trained several companies – Fortune 500, smaller market players, and startups – improve their supply chain through advanced analytics, data science, and artificial intelligence.

You can learn more about services and case studies here.

I am optimistic about 2023 and beyond, even as the world gives us plenty to be concerned about. We have only scratched the surface of how data, advanced analytics, and AI/ML techniques can make supply chains more nimble, robust, and future-proofed.

If you’re interested in a conversation about how you can do that – even if you’re not ready to engage now – please schedule a call here.

Thanks for reading, and I hope that 2023 is a year of growth for all.

End-to-end supply chain simulator

This is a guest post by Linnart Felkl M.Sc. and originally appeared on Supply Chain Data Analytics

It has been more than five years now that I graduated from university and entered the corporate world. Since then, I have dedicated most of my time to production and supply chain planning. Besides ERP-based model implementations, such as e.g. lot size optimization or production levelling in SAP, I have always been heavily involved with discrete-event simulation modeling. I have worked with several tools and in this article I will summarize a end-to-end simulation-based poultry supply chain analysis tool that I implemented in Python.

Simulation fosters better understanding of control logics

The simulation tool described by me in the article helped the client in several ways:

  • Better understanding of existing processes and dependencies throughout the supply chain
  • Common reference for discussion between the various internal stakeholder groups
  • Predict the impact of certain policy and control flow adjustments
  • End-to-end supply chain cost transparency
  • Tool for training new supply chain managers

The tool optimized a vertically integrated poultry meat processing business in the Mediterranean region. The regulatory framework for poultry meat farming is comprehensive, and while regulatory authorities were not involved in the development and deployment of this simulation tool it could very well serve regulatory authorities in similar ways. Regulatory constraints, such as e.g. All-In All-Out rules (also known in e.g. swine production), were however off course considered by the model and implemented accordingly.

Conceptional poultry supply chain model description

The poultry supply chain comprises many stages. Below figure provides an overview.

The relevant entities that I would like to highlight for a conceptual overview are the following:

  • Egg farmer. Produces and supplies eggs to the hatchery.
  • Hatchery. Hatches eggs in a series of processes, namely incubation, hatching, and brooding.
  • Farmer. Receives the chickens from the brooder and grows them in farm coops.
  • Slaughter facility. Receives or collects chicken from farm coops once they have reached slaughter-ready weight.
  • Meat processor. Pulls carcass demand for meat processing from slaughterhouse finished product storage.
  • Distributor. Places orders for finished product at the meat processor, temporarily stores and re-distributes processed meat to markets.
  • Market. Places orders at the distributor and sells processed meat in the market to end consumer.

Below conceptual model drawing provides another overview of the processes considered by the poultry supply chain simulation tool.

The poultry supply chain is a heavily regulated supply chain. As mentioned regulatory constraints are part of the model. Such rules e.g. aim at reducing the risk of disease spread and they are common to meat production beyond poultry meat production (e.g. swine production).

Control logics, regulations and information flow models

The simulation model comprises a wide range of control logics, rules and order-related information flows. Below table provides an overview.

Egg supplier, customer order logicEgg supplier ships based on order logWith a specified interval, the egg supplier checks the order book and ships the requested quantity
Egg supplier, order shipping logicFull order quantity shippedFull quantity is shipped the same day, but arrives after a specified transportation lead time
Hatchery, inventory management logicInventory for incoming eggs ahead of incubatorOrder point policies control the egg inventory. When demand falls below a specified level, an order is placed at the egg supplier that targets a fixed higher inventory level
Hatchery, incubation and hatching processIncubation and hatching black box processesIncubation and hatching have a specified duration and a specified production capacity. There also is a specified hatching success ratio and a specified mortality
Hatchery, brooding at brooderBrooder process follows incubation and successful hatchingBefore chicks are sent to a farm coop they stay at the brooder for a specified duration. Mortality rates are defined for this process, too
Hatchery, flock assignment to hatchery coopsAfter chicks have stayed at brooder for a minimum specified amount of time they are forwarded to a farm coopFarm coops must be ready for a new flock, and toms and hens cannot be mixed. Farm coops have different capacities, as they are located at different farms. Chickens should be assigned to coops with the least excess capacity
Farm coops, chicken growthChicken growth in farm coop differs from chicken species and sexChickens, depending on their sex and species, stay at the farm coop for a specified amount of time. This duration time models chicken growth until slaughter ready weight
Farm coops, forwarding chicken turkey to slaughterChickens forwarded to slaughterhouse when matureOnce chickens have reached slaughter-ready weight they are forwarded if the slaughterhouse has capacity. Otherwise they wait in the farm coop. After that the farm coop is sanitized. At this stage, relevant regulatory rules considered and embedded into the simulation model
Slaughterhouse, slaughter processDaily slaughter processSlaughterhouse slaughters chicken up to a specified maximum daily production capacity
Slaughterhouse, carcass inventoryProduction on stock, but demand-pulled inventoryThe meat processor pulls its carcass demand from the slaughterhouse inventory
Slaughterhouse, order backlogMeat processor places backlog at slaughterhouse if carcass inventory does not sufficeBacklog is satisfied in the upcoming production cycle and carcass is only produced on stock if no backlog orders are open
Slaughterhouse, external chicken purchaseExternal chicken are purchased if slaughterhouse inventory and current slaughter process volume is too lowIf demand for poultry carcass is higher than the carcass inventory and the carcass currently in production external poultry is purchased and slaughtered, occupying production capacity accordingly. Externally purchased poultry is always slaughtered first
Meat processor, carcass demandCarcass demand distribution, to be pulled from slaughterhouse carcass inventoryDifferent demand models can be implemented. For example, a deterministic or stochastic demand schedule can be implemented with specified demand by period

All of the logic summarized in above table was parametrized. Related values are adjustable in a configuration file. This allows users to run different scenarios, thereby gaining a better understanding of the supply chain.

Simulation model implementation in Python using SimPy

Throughout the past 5 years of model development, I have worked with various tools and software for discrete-event simulation modeling. Some popular tools are FlexSim, simio, AnyLogic, SIEMENS Plant Simulation, VisualComponents, Simul8 and many more. Many commercial simulation tools exist, and all of the just mentioned ones are commercial software. This model, however, I developed in SimPy, a discrete-event simulation framework in Python. This framework is free – but that was not the reason why I chose it.

SimPy is pure code. It does not have a graphical user interface (GUI) that the model developer can use for model development. It furthermore does not have any inbuilt model visualization. In other words, building and verifying a model in SimPy is highly abstract – but, since it is pure Python code, it is also highly flexible. For supply chain modeling, with many different entities and a wide range of possible control logics, this makes SimPy a good choice. In combination with object-oriented programming, that is. Object oriented programming is a requirement in this case, as it allows for framework development and appropriate structuring of the very complex task of modeling a supply chain with all its processes and entities. Users of the model do however need to have some understanding of Python.

Exemplary model output and results

In this section I display some exemplary model output that the poultry supply chain simulator generates. Data is collected and displayed in chicken units, i.e. unit neutral. This delivers a solid foundation for calculating relevant KPIs on top of that. Relevant KPIs could be costs and weight. Such KPIs can be implemented for clients on demand, by adding some few lines of code to the supply chain simulator.

Below chart shows inventory development at the slaughterhouse, i.e. carcass inventory. Too much inventory would result in high holding costs, and ultimately it would mean that carcass would have to be disposed of due to expiration dates and related policies.

Carcass inventory according to poultry supply chain simulator

Above chart shows inventory development at the slaughterhouse throughout one simulated year with 52 weeks (simulation periods). In this run, each week was one iteration of the simulation run. Inventory development at the slaughterhouse is directly connected to backlog development. This development can be seen on below graph.

Carcass backlog according to poultry production simulator

As becomes clear from above chart, no carcass inventory built up at the slaughterhouse because the slaughterhouse was always running behind meat processor demand, resulting in significant backlog.

Due to the existing backlog ordering policies at the slaughterhouse, high backlog triggered high purchasing orders at external poultry farms. Since externally purchased poultry is always slaughtered first, this resulted in excess inventory at the brooder, as it is waiting for farm coops to clear.

Brooder chicken population size resulting from poultry supply chain simulation

The brooder itself had no capacity limit, and the hatchery was thus not impacted by the production bottleneck ahead. This becomes clear from below inventory curve for eggs at the hatchery.

Inventory development in poultry supply chain simulation

Egg inventory development at the hatchery was stable.

Final remarks on poultry supply chain simulation

In this article, I demonstrated how discrete-event simulation is a powerful tool for modeling and analyzing poultry supply chains. The benefits of deploying a supply chain simulator are manifold, with all benefits ultimately aiming at supply chain cost reduction and availability (i.e. customer satisfaction) improvement. This is especially important in a poultry supply chain, as high inventory holdings result in e.g. carcass expiration and disposal. Deploying a supply chain simulator helped my client gain a better understanding about existing supply chain control logics and policies, and equipped the supply chain management team with an effective communication, training and analysis tool.

If you are interested in discrete-event simulation you may also be interested in some of the following related publications:

Success Story!

Another client success! If you’re interested in learning how Data Driven Supply Chain LLC can help you navigate the uncertain supply chain waters with supply chain modeling and advanced analytics, please email me for a free consultation:

I recently was brought in to help a client, a B2C segment leader with double-digit annual growth projections, facing major decisions in its first-mile network.

After working closely with the client team to understand its first-mile pain points and end-to-end product flow, I developed a bespoke supply chain network optimization model to enable rapid “what-if” scenario analysis, all using open source tools.

Working with the client team, we landed on several scenarios around port optimization, port risk mitigation, and make/buy decisions for key products.

As part of the project deliverables, the client received a custom-built dashboard app (using Shiny) of the scenario results, including maps, summary graphics, and detailed results, which facilitated further internal discussions.

Many thanks to this client and, if this is the kind of hands-on, in-depth modeling your supply chain could use, please reach out!

Project completed end-to-end using R, packages including: tidyverse, ggplot2, leaflet, gurobi, ompr, and Shiny

Announcement: Tool To Validate Your Latitude / Longitude

When I start a project with a new client, I request the locations of their facilities and, if applicable, their customers. Usually, the data I receive includes street address, ZIP code, and latitude and longitude. 

Unfortunately, the latitude & longitude are not always correct.  I take a “trust but verify” approach, mapping the locations using provided lat/long, and making a visual judgment.  (e.g., Antarctica is unlikely, as is Eastern Europe or central Asia for US-centric companies – all issues I’ve found with provided geocodes.  And don’t forget Null Island, at lat 0 / long 0.)

The trouble with the visual approach is that it is also quite error-prone; a location may be incorrectly geocoded but not immediately obvious.  For example, if your business has a lot of customers in Ohio, a pin that’s in northern Ohio but should be in southern Ohio, does not throw up red flags.  Even worse, if your business has a lot of customers throughout the Midwestern United States, a Minnesota address may have a Michigan pin – quite a distance away, yet also not immediately obvious.  These mistakes can be particularly troublesome if they involve higher-volume customers or facilities.

To help reduce some of this error, and speed up data validation, I have created a tool that takes as its input latitude and longitude, and returns the U.S. state or territory it is in, and what ZIP Code it is in (actually, ZIP Code Tabulation Area – ZCTA – similar to, but not exactly the same as, the ZIP code). If the lat/long is not in the U.S., or the tool cannot find the results in a short time, the tool returns “unknown”.

The tool is available as both a Shiny app and an API.  My hope is that the supply chain analyst community can use this tool to quickly validate geocoded latitude & longitude, comparing the lat/long’s state and ZCTA to the state and ZIP in a dataset, and flagging obvious problems for further investigation.

For a week or two, I’m opening the Shiny app and API for free, for initial use and feedback. After that, I will require a small usage fee, but for now my only request is your feedback!

How to use them:

Shiny app:  (redirects to

Instructions are in the app.  You can either upload a CSV, or directly copy/paste your latitude & longitude into a table. You can download results to CSV.

API endpoints (GET).  Replace (latitude 42, longitude -93) with your coordinates in the API call.

State (returns postal code abbreviation):

Thanks and hope this helps!  Please provide your feedback either in the comments or email

Free tools for spatial data visualization in R and Python

This is a guest post by Linnart Felkl, of

Supply chain network design can benefit greatly from spatial data visualization. For example, transparency in a warehouse relocation project can be greatly improved by visualizing material flows and critical transportation routes as well as e.g. spatial customer location distribution. In this blog post I present tools that can be used for this. All of the tools presented by me are available as packages or modules available in at least Python or R. Hence, they can be used for free. Moderate data analysis skills in R or Python are required to be able to apply these tools.

ggmap in R allows for map-based plots and animations

If you are used to R you will know ggplot2 for data visualization. You can think of ggmap as an extension of ggplot2. ggmap allows for map-based plots. Here is an example of a k-means density plot that I created as part of a research project for a major German university.

And here is another example, comparing different kernel density plot coloring themes for the same data.

ggmap applies the same “grammatics” as ggplot2. This means that if you are used to working with ggplot2 you will be able to generate plots in basically the same way as you are already used to. Another good thing about ggmap is that it (like ggplot2) is compatible with gganimate. This means that you can use ggmap in order to be able to create map-based animations. You can see how to do this in another blog post that I published on SCDA: Spatial data animation with ggmap & gganimate.

Leaflet is available in both R and Python (among other languages)

The Leaflet library can be accessed in R and Python. It enables you to draw good looking heatmaps. You can see an example below.

Above example shows a heatmap that illustrates a monte-carlo simulation in which I randomized customer locations to assess the risk associated with warehouse allocation. Below is another example comparing spatial distribution in Google search trends for two keywords.

Using Leaflet in R or Python, much like other tools, allows users to adjust the tiles and coloring themes of the map. It is also possible to adjust heatmap visualizations by e.g. adjusting the radius of overlapping circles. Below follows another exemplary visualization of the same data.

Markers or custom icons can be used for visualizing spatial distributions as well. Here is a marker plot that I created with Leaflet in R.

Back when I developed these examples I was comparing Google search trends for the keywords “Pizza” and “Hamburger” in Germany. Leaflet allows me to customize marker icons, as you can see in the plot below.

Visualizing and comparing spatial distributions in this way e.g. contributes to a better understanding of relevant customer groups and markets.

In R, Leaflet integrates nicely with Shiny R

Another great thing about Leaflet (in R) is that it integrates smoothly with Shiny R apps. Below is a screenshot of a very simple Shiny R app with a Leaflet heatmap visualization that I once made.

The Shiny app allows users to upload a csv-file with input data. That input data is then geocoded and eventually visualized in the form of Leaflet heatmap.

With leaflet.minicharts you can generate map-based charts

leaflet.minicharts is an extension to Leaflet maps and the Leaflet package in R. It currently supports three types of charts: Bar charts, pie charts and polar area charts. In the figure below you can see how I created a map-based pie chart visualization for a retailer of automotive spare parts. The map compares pump vs. sensor sales revenue by state. The bigger the pie, the bigger the total sales volume with the respective state.

The nice thing about leaflet.minichart is that it is compatible with both Leaflet (obviously) and Shiny R. Again, that means that it is possible to construct interactive Shiny R apps that offer responsive map-based charts.

The leaflet.minicharts package in R can also be used to create map-based animations. This is especially useful when communicating time-based spatial data trends. A package like leaflet.minicharts will allow you to walk through each year, month or day one by one, without having to plot multiple maps. It all can take place in just one map.

deckgl can be accessed in R and allows for 3D plots

Using deckgl in R spatial data can be visualized on top of mapbox tiles in 3D. Here is an example showing an artificially generated distribution in the form of 3D bars on top of a mapbox map.

Besides 3D bar plots other types of visualizations can be generated with deckgl. Here is another example showing a map-based scatterplot.

Flight routes (line paths), tuck routes (arcs), and much more can be visualized with deckgl, too. All of these plot types can be combined. For example, flight and truck routes can be visualized on a map that shows customer locations in the form of a scatter plot.

Concluding remarks on free tools for spatial data visualization

In this article I introduced a couple of free tools for spatial data visualization and analysis in R and Python: ggmap, Leaflet, leaflet.minicharts, and deckgl. These tools will enable you to communicate results from spatial data analysis. Where are my customers located? What are my main material flows? Which regions generate the most sales? Where would be a good place for a new sales store or distribution center? Questions like that call for spatial data visualization. And in this article I presented some tools that enable you to create such visualizations for free.